我有数据库(仅 30mb)和这个数据库使用 4gb 内存!我的网站最多允许 10 人在线。我认为这是不好的cnf.my。
mysql> 显示变量,如 '%size%'; +---------------------------------+---------------- --------+ | 变量名 | 价值 | +---------------------------------+---------------- --------+ | binlog_cache_size | 32768 | | bulk_insert_buffer_size | 8388608 | | 延迟队列大小 | 1000 | | innodb_additional_mem_pool_size | 1048576 | | innodb_buffer_pool_size | 8388608 | | innodb_log_buffer_size | 1048576 | | innodb_log_file_size | 5242880 | | join_buffer_size | 4194304 | | key_buffer_size | 268435456 | | key_cache_block_size | 1024 | | 大页面大小 | 0 | | max_binlog_cache_size | 18446744073709547520 | | max_binlog_size | 1073741824 | | max_heap_table_size | 268435456 | | max_join_size | 18446744073709551615 | | max_long_data_size | 1048576 | | max_relay_log_size | 0 | | myisam_data_pointer_size | 6 | | myisam_max_sort_file_size | 9223372036853727232 | | myisam_mmap_size | 18446744073709551615 | | myisam_sort_buffer_size | 8388608 | | preload_buffer_size | 32768 | | profiling_history_size | 15 | | 查询分配块大小 | 8192 | | 查询缓存大小 | 268435456 | | query_prealloc_size | 8192 | | range_alloc_block_size | 4096 | | 读取缓冲区大小 | 131072 | | read_rnd_buffer_size | 262144 | | 排序缓冲区大小 | 20971520 | | sql_max_join_size | 18446744073709551615 | | 线程缓存大小 | 4 | | tmp_table_size | 41943040 | | transaction_alloc_block_size | 8192 | | transaction_prealloc_size | 4096 | +---------------------------------+---------------- --------+ 一组 35 行(0.00 秒)
而我的.cnf:
[mysqld]
local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
long_query_time=1
log-slow-queries=/var/log/mysql/log-slow-queries.log
interactive_timeout=180
wait_timeout=180
max_connections=100
innodb_buffer_pool_size=256M
query_cache_size=256M
key_buffer_size=256M
sort_buffer_size=20M
innodb_flush_log_at_trx_commit=0
innodb_flush_method=O_DIRECT
query_cache_type=1
query_cache_limit=2M
table_cache=1024
join_buffer_size=4M
thread_cache_size=4
tmp_table_size=40M
max_heap_table_size=256MB
user=mysql
symbolic-links=0
#bind-address=127.0.0.1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
在我的 vps 中,我有 5.7 GB 内存
如何减少内存使用?