建议和调查

xjreopfe  于 2021-06-21  发布在  Mysql
关注(0)|答案(2)|浏览(352)

简介:我有一个带ssd和512mb ram(1024mb突发)的Debian8VPS,只与mysql一起使用。我已经关闭了所有不必要的服务,并提供了数据库和系统上的所有资源。我只有5个工作站。ping和网络稳定。
主要问题是,如果我连续进行10次这样的查询:

(SELECT IFNULL(SUM(Qtty), 0) FROM operations
WHERE blablabla
FROM (goods LEFT JOIN store ON goods.ID = store.GdID)
WHERE Deleted <> -1
GROUP BY goods.ID;

随机5-6个执行2秒,其余执行8秒以上!我看没有理由这样做。当我激活slow\u query\u log时,它只有相同的查询,没有其他内容。
我的innodb数据是98mb,有没有理由给innodb提供更多的ram\u缓冲区\u池\u大小或者128就足够了?
innodb日志文件大小必须为25%-50%,哪个大小对我更合适?
tmp dir是tmpfs,所以如果tmp\u table\u size放在那里,有没有理由给它更多的ram或者足够使用1m呢?
table\u open\u cache-我有大约200个表,是否有任何理由按照mysqltuner的建议将其设置为20000个?
我能换点别的吗?

我的.cnf

skip-external-locking
skip-name-resolve
performance_schema = OFF
thread_stack = 192K
thread_cache_size = 10 #this is managed globally and is equal to max_connections
max_connections = 10
max_connect_errors = 10
connect_timeout = 20
wait_timeout = 20
interactive_timeout = 20
sql_mode = TRADITIONAL
default_storage_engine = InnoDB
innodb_buffer_pool_instances = 1
innodb_buffer_pool_size = 250M
innodb_log_file_size = 100M
innodb_strict_mode = ON
innodb_flush_method = O_DIRECT
innodb_flush_neighbors = 0
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_io_capacity = 2000
innodb_io_capacity_max = 3000
key_buffer = 128K
delay_key_write = ON
tmp_table_size = 10M # 32M = 53% temp
max_heap_table_size = 10M
query_cache_type = 0
query_cache_size = 0
table_open_cache = 5000
table_definition_cache = 3000
vc9ivgsu

vc9ivgsu1#

为您的my.cnf[mysqld]部分考虑的建议

max_connections=20  # from 10 to affect thread_cache_size

. 因为mysql使用了8个线程+5 concurrent=13,您会有一些额外的线程,请

tmp_table_size=16M  # from 10M   to reduce 41% temp tables created on disk
max_heap_table_size=16M  # from 10M  should always be = tmp_table_size
innodb_read_io_threads=64  # from 4 to let the ponies run
innodb_write_io_threads=64  # from 4 to push on through

如需更多帮助,请参阅我的个人资料,clk on network profile获取联系信息。

goqiplq2

goqiplq22#

再次感谢您的详细答复,并对延误表示抱歉。不幸的是,我经常在没有互联网的情况下旅行,通过skype联系几乎是不可能的。
我注意到一些有用的东西:通常,即使运行很小的查询,服务器也会以“error 2006(hy000):mysql server has gone away”作为响应。如果我再做一次手术-一切都好。问题出在服务器上,而不是数据库中?
db大约是100mb,所以我将允许的最大\u包增加到512mb,innodb io \u线程增加到64。我试着将netu read\u timeout、netu write\u timeout、wait\u timeout和interactive\u timeout增加到28800,这是一个改进。现在是我的暂停时间,改变什么有意义吗?

connect_timeout             120
delayed_insert_timeout      300
innodb_flush_log_at_timeout 1
innodb_lock_wait_timeout    50
innodb_rollback_on_timeout  OFF
interactive_timeout         28800
lock_wait_timeout           31536000
net_read_timeout            30
net_write_timeout           60
slave_net_timeout           3600
thread_pool_idle_timeout    60
wait_timeout                28800

相关问题