patternsqlModerate
My.cnf with 64GB RAM
Viewed 0 times
withramcnf64gb
Problem
May the following my.cnf file be fine for a dedicated server with 64GB of RAM (on Debian)?
I'm running just one website on the server and on high load data insert in some table takes centuries...it seems that the DB can't handle some table lock (50Mb tables, not so much).
If it is fine, then i'll step to analyze every single query.
Any help would be truly appreciated!
[client]
I'm running just one website on the server and on high load data insert in some table takes centuries...it seems that the DB can't handle some table lock (50Mb tables, not so much).
If it is fine, then i'll step to analyze every single query.
Any help would be truly appreciated!
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld]
port = 3306
socket = /var/run/mysqld/mysqld.sock
back_log = 50
skip-networking
max_connections = 100
max_connect_errors = 10
table_open_cache = 4096
table-definition-cache = 4096
skip-external-locking
skip-name-resolve
max_allowed_packet = 32M
binlog_cache_size = 2M
max_heap_table_size = 64M
read_buffer_size = 4M
read_rnd_buffer_size = 32M
sort_buffer_size = 16M
join_buffer_size = 8M
thread_cache_size = 20
thread_concurrency = 16
query_cache_type=1
query_cache_size = 1024M
query_cache_limit = 2M
ft_min_word_len = 4
default-storage-engine = MYISAM
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 4G
log-bin=mysql-bin
binlog_format=mixed
slow_query_log
long_query_time = 2
server-id = 1
key_buffer_size = 16G
bulk_insert_buffer_size = 256M
myisam_sort_buffer_size = 246M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 12G
innodb_data_file_path = ibdata1:10M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192Solution
A good tool to help you tune MySQL config is the Percona Configuration Wizard for MySQL. This asks you some questions about your system and your workload, and gives you some approximate tuning values to start with.
Of course the term tuning suggests that further refinement may be beneficial, but this happens over time as you monitor your workload, resources usage, and bottlenecks. It's not something we can answer once and for all in a post like this one.
However, I have other comments about your config:
This is not going to take effect, because you override it with a smaller value later in your config file. See below.
This is 64x the default. Unless you have a good reason to increase it, don't. Note that the binlog cache is allocated per user thread, so if you have 100 concurrent transactions, this would use 200MB of RAM. Suggest you remove this line and use the default.
This constrains
This is 32x higher than the default. It's used only during table-scans of MyISAM tales. It would be better to create appropriate indexes and avoid table-scans. Suggest you remove this line and use the default.
This is 128x higher than the default, and 16x higher than the maximum allowed value of 2M. This is used only for MyISAM reads in MySQL 5.5 and earlier, and in MySQL 5.6 it's also used for multi-range reads. But it's probably not necessary to increase it. Suggest you remove this line and use the default.
This is 4x higher than the default. In MySQL 5.6, it's 16x higher than the default. This is also a buffer that is allocated for each user thread, so be careful how much you increase it. Suggest you remove this line and use the default.
This is 64x higher than the default, so be sure you have a good reason for increasing it. It's used during index scans and joins on unindexed columns. It would be better to index tables better. Keep in mind that the join buffer can be allocated for each user thread, so this 8MB amount can account for unpredictable memory growth. Suggest you remove this line and use the default.
Modern Linux kernels can create threads a lot faster than in the old days, so it's no longer as important to keep a thread cache. Suggest you remove this line and use the default.
Are you running on Solaris? If not, this variable has no purpose. Suggest you remove this line.
This is a lot of RAM to dedicate to the query cache, and it's probably overallocated. The query cache has some downsides, especially when you have many concurrent connections. Frequently we actually recommend to disable the query cache unless you can demonstrate you're getting a lot of bang for the buck.
Disable by setting both
This is the default. Suggest you remove this line and use the default.
Recommend to set the default storage engine to InnoDB.
I recommend against using MyISAM for anything. MyISAM supports table-locking only, it's susceptible to corruption in crashes, it's not being developed anymore, and it's gradually being phased out. Claims that MyISAM is faster than InnoDB are based on very old versions of MySQL. Even as far back as 2007, benchmarks show that InnoDB is faster than MyISAM under most workloads.
One of the last reasons to use MyISAM, fulltext indexes, is also obsolete. InnoDB is getting fulltext indexes (they were introduced in 5.6, but they're not really usable yet). Sphinx Search is better for fulltext search anyway.
This is actually lower than the default of 256K on 64-bit systems. Suggest you remove this line and use the default.
This is the default. Suggest you remove this line and use the default.
This is not going to allow any tmp tables higher than
These are used only by MyISAM, and you don't need them if you don't use MyISAM.
This is moot on modern Linux kernels, where dynamic memory allocation is actually more efficient than letting InnoDB preallocate memory. Suggest you remove this line and use the default.
```
innodb_buffer_
Of course the term tuning suggests that further refinement may be beneficial, but this happens over time as you monitor your workload, resources usage, and bottlenecks. It's not something we can answer once and for all in a post like this one.
However, I have other comments about your config:
max_allowed_packet = 32MThis is not going to take effect, because you override it with a smaller value later in your config file. See below.
binlog_cache_size = 2MThis is 64x the default. Unless you have a good reason to increase it, don't. Note that the binlog cache is allocated per user thread, so if you have 100 concurrent transactions, this would use 200MB of RAM. Suggest you remove this line and use the default.
max_heap_table_size = 64MThis constrains
tmp_table-size. See below.read_buffer_size = 4MThis is 32x higher than the default. It's used only during table-scans of MyISAM tales. It would be better to create appropriate indexes and avoid table-scans. Suggest you remove this line and use the default.
read_rnd_buffer_size = 32MThis is 128x higher than the default, and 16x higher than the maximum allowed value of 2M. This is used only for MyISAM reads in MySQL 5.5 and earlier, and in MySQL 5.6 it's also used for multi-range reads. But it's probably not necessary to increase it. Suggest you remove this line and use the default.
sort_buffer_size = 16MThis is 4x higher than the default. In MySQL 5.6, it's 16x higher than the default. This is also a buffer that is allocated for each user thread, so be careful how much you increase it. Suggest you remove this line and use the default.
join_buffer_size = 8MThis is 64x higher than the default, so be sure you have a good reason for increasing it. It's used during index scans and joins on unindexed columns. It would be better to index tables better. Keep in mind that the join buffer can be allocated for each user thread, so this 8MB amount can account for unpredictable memory growth. Suggest you remove this line and use the default.
thread_cache_size = 20Modern Linux kernels can create threads a lot faster than in the old days, so it's no longer as important to keep a thread cache. Suggest you remove this line and use the default.
thread_concurrency = 16Are you running on Solaris? If not, this variable has no purpose. Suggest you remove this line.
query_cache_type=1
query_cache_size = 1024MThis is a lot of RAM to dedicate to the query cache, and it's probably overallocated. The query cache has some downsides, especially when you have many concurrent connections. Frequently we actually recommend to disable the query cache unless you can demonstrate you're getting a lot of bang for the buck.
Disable by setting both
query_cache_type=0 and query_cache_size=0. ft_min_word_len = 4This is the default. Suggest you remove this line and use the default.
default-storage-engine = MYISAMRecommend to set the default storage engine to InnoDB.
I recommend against using MyISAM for anything. MyISAM supports table-locking only, it's susceptible to corruption in crashes, it's not being developed anymore, and it's gradually being phased out. Claims that MyISAM is faster than InnoDB are based on very old versions of MySQL. Even as far back as 2007, benchmarks show that InnoDB is faster than MyISAM under most workloads.
One of the last reasons to use MyISAM, fulltext indexes, is also obsolete. InnoDB is getting fulltext indexes (they were introduced in 5.6, but they're not really usable yet). Sphinx Search is better for fulltext search anyway.
thread_stack = 192KThis is actually lower than the default of 256K on 64-bit systems. Suggest you remove this line and use the default.
transaction_isolation = REPEATABLE-READThis is the default. Suggest you remove this line and use the default.
tmp_table_size = 4GThis is not going to allow any tmp tables higher than
max_heap_table_size, which you set to 32M earlier. So if you want large tmp tables, you must also increase that config variable to match. But be careful, because you could end up with multiple threads populating 4G tmp tables in memory, and then start swapping.key_buffer_size = 16G
bulk_insert_buffer_size = 256M
myisam_sort_buffer_size = 246M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recoverThese are used only by MyISAM, and you don't need them if you don't use MyISAM.
innodb_additional_mem_pool_size = 16MThis is moot on modern Linux kernels, where dynamic memory allocation is actually more efficient than letting InnoDB preallocate memory. Suggest you remove this line and use the default.
```
innodb_buffer_
Code Snippets
max_allowed_packet = 32Mbinlog_cache_size = 2Mmax_heap_table_size = 64Mread_buffer_size = 4Mread_rnd_buffer_size = 32MContext
StackExchange Database Administrators Q#57225, answer score: 10
Revisions (0)
No revisions yet.