Last active
April 23, 2019 21:02
-
-
Save aristidesneto/c28a882cb49600b8092a5551bd212c3a to your computer and use it in GitHub Desktop.
Tunning Mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Não utilize em seus servidores antes de saber o que cada comando faz | |
| ## Dica retirada de https://www.vivaolinux.com.br/etc/mycnf/ | |
| [mysqld] | |
| datadir=/var/lib/mysql | |
| socket=/var/lib/mysql/mysql.sock | |
| user=mysql | |
| # Disabling symbolic-links is recommended to prevent assorted security risks | |
| symbolic-links=0 | |
| [mysqld] | |
| back_log = 75 | |
| #skip-innodb | |
| max_connections = 512 | |
| myisam_sort_buffer_size = 64M | |
| join_buffer_size = 1M | |
| read_buffer_size = 1M | |
| sort_buffer_size = 2M | |
| table_cache = 1800 | |
| thread_cache_size = 384 | |
| wait_timeout = 7200 | |
| connect_timeout = 120 | |
| tmp_table_size = 64M | |
| max_heap_table_size = 64M | |
| max_allowed_packet = 64M | |
| max_connect_errors = 1000 | |
| read_rnd_buffer_size = 524288 | |
| bulk_insert_buffer_size = 8M | |
| query_cache_limit = 5M | |
| query_cache_size = 1M | |
| query_cache_type = 1 | |
| query_prealloc_size = 65536 | |
| query_alloc_block_size = 131072 | |
| #Slow query | |
| long_query_time = 1 | |
| slow_query_log = 8 | |
| slow_query_log_file = /var/log/mysql/slowquery.log | |
| log_queries_not_using_indexes = 1 | |
| general_log = on | |
| general_log_file=/var/log/mysql/general.log | |
| [mysqld_safe] | |
| log_error=/var/log/mysqld.log | |
| pid_file=/var/run/mysqld/mysqld.pid | |
| bind address = 127.0.0.1 | |
| nice = -5 | |
| open_files_limit = 8192 | |
| [mysqldump] | |
| quick | |
| max_allowed_packet = 16M | |
| [myisamchk] | |
| key_buffer = 128M | |
| sort_buffer = 64M | |
| read_buffer = 16M | |
| write_buffer = 16M | |
| # Split Tables | |
| #innodb_file_per_table = 1 | |
| key_buffer_size = 32M | |
| table_open_cache = 200 | |
| sort_buffer_size = 512K | |
| net_buffer_length = 8K | |
| read_buffer_size = 256K | |
| read_rnd_buffer_size = 512K | |
| myisam_sort_buffer_size = 8M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## https://www.vivaolinux.com.br/etc/my.cnf-fabio/ | |
| [client] | |
| port = 3306 | |
| socket = /var/run/mysqld/mysqld.sock | |
| [safe_mysqld] | |
| err-log = /var/log/mysql/mysql.err | |
| [mysqld] | |
| server-id=10 | |
| log-bin=/var/log/mysql/mysql-bin.log | |
| binlog-do-db=pop | |
| binlog-ignore-db=mailstats,mysql,pop.bak,radius,radius.bak,test | |
| user = mysql | |
| pid-file = /var/run/mysqld/mysqld.pid | |
| socket = /var/run/mysqld/mysqld.sock | |
| port = 3306 | |
| log = /var/log/mysql.log | |
| basedir = /usr | |
| datadir = /var/lib/mysql | |
| tmpdir = /tmp | |
| language = /usr/share/mysql/english | |
| skip-locking | |
| # key-buffer define quanto de memória será armazenado para | |
| # gravar dados de consultas do MySQL. Quanto maior a quantidade | |
| # de memória disponível, melhor será o desempenho do servidor | |
| set-variable = key_buffer=312M | |
| set-variable = max_allowed_packet=1M | |
| # table_cache é muito importante, este número deve ser o dobro | |
| # do número definido pela variável max_connections | |
| set-variable = table_cache=20000 | |
| set-variable = sort_buffer=1M | |
| set-variable = record_buffer=1M | |
| set-variable = myisam_sort_buffer_size=64M | |
| set-variable = thread_cache=8 | |
| set-variable = thread_concurrency=8 | |
| # max_connections vai definir quantos sub-processos e | |
| # consequentemente quantas conexões seu MySQL suportará | |
| # simultaneamente. Por incrível que pareça, quanto maior este | |
| # número, menor será o load do seu server. Tente restringir este | |
| # para um número baixo e você verá que loucura está fazendo | |
| set-variable = max_connections=10000 | |
| set-variable = net_write_timeout=30 | |
| set-variable = connect_timeout=2 | |
| set-variable = wait_timeout=30 | |
| # Read the manual if you want to enable InnoDB! | |
| skip-innodb | |
| [mysqldump] | |
| quick | |
| set-variable = max_allowed_packet=1M | |
| [mysql] | |
| [isamchk] | |
| set-variable = key_buffer=64M # era 16M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment