Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为Ubuntu配置mysql配置(RAM:4GB CPU:2VCPU SSD磁盘:80GB)_Mysql_Ubuntu 16.04 - Fatal编程技术网

如何为Ubuntu配置mysql配置(RAM:4GB CPU:2VCPU SSD磁盘:80GB)

如何为Ubuntu配置mysql配置(RAM:4GB CPU:2VCPU SSD磁盘:80GB),mysql,ubuntu-16.04,Mysql,Ubuntu 16.04,我正在努力提高mysql的性能。所以我增加了更多的记忆。但在某些方面仍然缓慢。Im最左边的连接和更新 我的数据库有40GB的数据 我当前的mysql配置是: key_buffer = 1024M max_connections = 3000 query_cache_size = 256M query_cache_limit = 512M thread_stack = 32M innodb_buffer_p

我正在努力提高mysql的性能。所以我增加了更多的记忆。但在某些方面仍然缓慢。Im最左边的连接和更新

我的数据库有40GB的数据

我当前的mysql配置是:

key_buffer              = 1024M
max_connections         = 3000
query_cache_size        = 256M
query_cache_limit       = 512M
thread_stack            = 32M 
innodb_buffer_pool_size =  512M
innodb_lock_wait_timeout= 150

table_cache = 2048
max_allowed_packet = 16M
max_heap_table_size = 64M
binlog_cache_size = 1M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
thread_stack = 192K
query_cache_size = 128M
query_cache_type = 1
query_cache_limit = 2M
tmp_table_size = 64M
key_buffer_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2G
问题是。这是最好的配置吗

我的发球正在进行:Digitalocean/Ubuntu16.04

内存:4GB CPU:2VCPU
SSD磁盘:80GB

根据原始问题中发布的有限信息,为您的my.cnf-ini[mysqld]部分提供建议

thread_cache_size=50  # from 8 and monitor threads_created
thread_concurrency=16  # from 8 and monitor response time

# LEAD the following lines to allow DEFAULTS to work for you
# key_buffer=1024M  # lead with # to ignore, you have only 4G RAM
# max_connections=3000  # lead with # for default of 151, until more needed
# sort_buffer_size=8M
# read_buffer_size=2M
# read_rnd_buffer_size=8M
# join_buffer_size=8M
# thread_stack=32M
在www.mysqlcalculator.com上花两分钟的时间来了解上述内容是如何实现的 值会不必要地增加每个连接的RAM占用空间。
默认值通常对您非常有效。

根据我的个人经验,最好的方法是分析一些最慢的查询,并检查它们为什么慢。有时使用的是没有任何索引的“where”(查询条件),有时添加/更新值后需要更新的索引太多

请注意,每个字段都应该基于您正在运行的内容。一个非常虚假的例子。允许的最大数据包数=16M


如果没有批处理查询或不使用blob,可以将其缩小。但是,如果你存储的是大的blob,那么你需要足够大的blob来容纳你要存储的更大的附件。

答案主要是基于观点的,最好的办法是测试你自己不同的onfig,看看哪一个更适合你的需要,欢迎使用SO。关于如何根据可用内存配置mysql参数,互联网上有几本指南。那么,它有点模糊,什么是慢连接?您是否在表上设置了适当的索引?供参考: