gpt4 book ai didi

MySQL 不使用可用内存

转载 作者:可可西里 更新时间:2023-11-01 07:06:34 27 4
gpt4 key购买 nike

我正从共享网络托管公司转移到 VPS。我正在尝试为我的系统找到最佳配置。

对于具有 50 万条记录的 1 个特定表,在以前的服务器上需要几秒钟的 1 个查询现在需要几分钟。

我想提高我的服务器的响应时间,所以我买了更多的内存(我有 2GB 的 RAM,如果需要我仍然可以购买更多的资源和 2 个内核)。我也“作弊”了,把老公司的my.cnf复制到我的VPS上:

[mysqld]
read_buffer_size=8M
read_rnd_buffer_size=8M
sort_buffer_size=32M
innodb_additional_mem_pool_size=503M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=16M
innodb_buffer_pool_size=1007M
innodb_log_file_size=256M
innodb_thread_concurrency=8
innodb_autoextend_increment=128
max_connections=8059
max_user_connections=50
thread_cache_size=128
thread_stack=196608
binlog_cache_size=2M
net_read_timeout=30
net_retry_count=10
net_write_timeout=30
thread_concurrency=10
open_files_limit=9940
max_heap_table_size=32M
tmp_table_size=64M
key_buffer_size=512M
key_buffer=128M
myisam_sort_buffer_size=64M
join_buffer=16M
record_buffer=8M
wait_timeout=300
connect_timeout=10
max_allowed_packet=16M
max_connect_errors=100
table_cache=1024
query_cache_size=32M
query_cache_type=1
ft_min_word_len=4
datadir=/var/lib/mysql
tmpdir=/tmp
socket=/var/lib/mysql/mysql.sock
old-passwords=0
[mysqldump]
quick
max_allowed_packet=16M
[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M

问题是查询仍然很慢,而且服务器没有使用可用内存!

              total       used       free     shared    buffers     cached
Mem: 2002 1986 15 0 6 1079
-/+ buffers/cache: 901 1101
Swap: 1747 2 1745

有什么建议吗?

问候

最佳答案

你可以看看使用 https://github.com/rackerhacker/MySQLTuner-perl

你可以用它来分析 MySQL,它会输出推荐的设置。

对于 2GB 内存,您的设置似乎太高了。IE max_connections=8059这本身就需要比你拥有的更多的内存。

[mysqld]
max_connections=100
innodb_buffer_pool_size=256M
query_cache_size=256M
key_buffer_size=256M
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=128
tmp_table_size=256M
max_heap_table_size=256MB

对于 2gb RAM,您可以尝试在 MySQL 中使用这些设置这些是我目前使用的其中一台 2gb 服务器的推荐设置

关于MySQL 不使用可用内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7923683/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com