patternsqlMinor
MySql my.cnf recommended settings
Viewed 0 times
recommendedmysqlsettingscnf
Problem
I did my research on google read some blogs but I found nothing that really works in my case.
After my, mysql crashed several times testing configurations, I have no option than ask for some help here.
Can somebody give me some hints about what values are recommended in my.cnf for a heavy duty database server (12 tables, more than 50G of data) with the following specifications:
root@blah:/etc/mysql# cat my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com
After my, mysql crashed several times testing configurations, I have no option than ask for some help here.
Can somebody give me some hints about what values are recommended in my.cnf for a heavy duty database server (12 tables, more than 50G of data) with the following specifications:
root@blah:/etc/mysql# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 16
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Stepping: 4
CPU MHz: 2600.092
BogoMIPS: 5200.18
Hypervisor vendor: Xen
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 20480K
NUMA node0 CPU(s): 0-15
root@blah:/etc/mysql# free -m
total used free shared buffers cached
Mem: 64237 2747 61490 19 189 1811
-/+ buffers/cache: 746 63491
Swap:
2047 0 2047
This server is used only as database so I don't have to worry about anything else. Just to make sure that MySql is getting all the juice and use all resources in the best possible way.
my.cnf file I have is looking like this:
``root@blah:/etc/mysql# cat my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com
Solution
I see you have 64GB RAM, and its all for MySQL server, which is nice. First I would suggest increasing your cache sizes, tmp_tables, etc, you can search those on Google. If you are using InnoDB tables, I suggest you tweak those too. Below I will give some suggestions, but ultimately its up to you what to do, and the best you can do is read up and test out different configs.
To check config params, use this query, modify like part or omit it at all, this way you know for sure if your settings are there:
Skip name resolve, this will make mysql faster as it doesn't need to resolve DNS, be sure that you use IP addresses when connecting to you server afterwords:
Recommended giving 64M for both values for every 1 GB of RAM on the server. This boosts performance, change these values to your needs
Log slow queries, long_query_time is number of seconds for query to be long, adjust accordingly
Some settings that you need to tweak I give below.
These are generally the main settings you need to tweak, numbers here are for your reference only, you should change/tweak them accordingly. Read Mysql docs for meaning of the each of those.
IF you are running phpMyAdmin, there will be Database Status, go there and it will show you red flags. Other than that you can manually check up on some parameters like this: SHOW GLOBAL STATUS LIKE 'Opened_tables';
Once in a while check if you have fragmented tables or if they need repair. This command solves it:
Another userful tool is mysqltuner, install and run it too.
Hope this helps.
To check config params, use this query, modify like part or omit it at all, this way you know for sure if your settings are there:
show variables like '%log%';Skip name resolve, this will make mysql faster as it doesn't need to resolve DNS, be sure that you use IP addresses when connecting to you server afterwords:
[mysqld]
skip-name-resolveRecommended giving 64M for both values for every 1 GB of RAM on the server. This boosts performance, change these values to your needs
tmp_table_size= 2000M
max_heap_table_size= 2000M
max_tmp_tables=300Log slow queries, long_query_time is number of seconds for query to be long, adjust accordingly
[mysqld]
slow-query-log = 1
slow-query-log-file = /var/log/mysql-slow.log
long_query_time = 1Some settings that you need to tweak I give below.
sort_buffer_size=10M
read_buffer_size=10M
table_open_cache=8000
query_cache_limit=50M
join_buffer=10MThese are generally the main settings you need to tweak, numbers here are for your reference only, you should change/tweak them accordingly. Read Mysql docs for meaning of the each of those.
IF you are running phpMyAdmin, there will be Database Status, go there and it will show you red flags. Other than that you can manually check up on some parameters like this: SHOW GLOBAL STATUS LIKE 'Opened_tables';
Once in a while check if you have fragmented tables or if they need repair. This command solves it:
mysqlcheck -u root --auto-repair --optimize --all-databasesAnother userful tool is mysqltuner, install and run it too.
Hope this helps.
Code Snippets
show variables like '%log%';[mysqld]
skip-name-resolvetmp_table_size= 2000M
max_heap_table_size= 2000M
max_tmp_tables=300[mysqld]
slow-query-log = 1
slow-query-log-file = /var/log/mysql-slow.log
long_query_time = 1sort_buffer_size=10M
read_buffer_size=10M
table_open_cache=8000
query_cache_limit=50M
join_buffer=10MContext
StackExchange Database Administrators Q#130809, answer score: 4
Revisions (0)
No revisions yet.