首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >配置不良的mysql服务器

问配置不良的mysql服务器
EN

Database Administration用户
提问于 2020-06-24 17:41:36
回答 2查看 86关注 0票数 0

最近,我将我们拥有的所有MySQL服务器都放在了几台服务器上,并为MySQL提供了一个单独的VPS。作为信息来源,我使用了Aurimas电子书"Speedemy MySQL配置调优手册“来配置服务器。这一切看上去都很棒,直到我意识到它正在蚕食交换(而且可能会缓慢地进行)。然后,我转到配置文件,并将建议的内存减少到存储innodb_buffer_pool_size的值,甚至低于建议的80%。

今天我去那里检查服务器做得如何,并注意到它又吃了一堆我的交换,因为我不相信自己,所以我决定在这里问我可能做错了什么。

服务器是一个VPS,有16 is的RAM和6核。

这是我的免费输出:

代码语言:javascript
复制
              total        used        free      shared  buff/cache   available
Mem:       16393988    13286624     2009964         876     1097400     2798976
Swap:        975868      610360      365508

这是我的配置文件(忽略葡萄牙语注释):

代码语言:javascript
复制
#   Arquivo de configuração do mysql
#   Criado por Guilherme Richter, 19/05/2020

[client]
#   Usado apenas para casos especificos
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

[mysql]
#   Configurações do cliente
auto-rehash                     # Auto completar        (DEFAULT: FALSE)

[mysqld]
#   Configuração do servidor
pid_file            = /var/run/mysqld/mysqld.pid
socket              = /var/run/mysqld/mysqld.sock
datadir             = /var/lib/mysql
log_error           = /var/log/mysql/error.log
user                = mysql
bind_address        = 0.0.0.0       # Ouve todos os endereços

#   Configurações genericas do servidor
max_allowed_packet          = 32M       # Tamanho maximo do pacote. (DEFAULT: 64M)
max_connections             = 2000      # Maximo de coneções        (DEFAULT: 151)
open_files_limit            = 10000     # Maximo de arquivos abertos    (DEFAULT: 10000)
tmp_table_size              = 64M       # Limite tamanho tabela em mem  (DEFAULT: 16M)
max_heap_table_size         = 64M       # Limite tamanho tabela em mem  (DEFAULT: 16M)
tmpdir                      = /tmp      # Diretorio /tmp/       (DEFAULT: /tmp/)
default_storage_engine      = InnoDB    # Engine default        (DEFAULT: InnoDB)
skip_name_resolve                       # Desabilita resolução DNS  (DEFAULT: FALSE)

#   Configurações de log binario
log_bin                         # Log binario ativo     (DEFAULT: TRUE)
server_id                   = 1     # Identifica servidor para log  (DEFAULT: 1)
max_binlog_size             = 256M      # Tamanho maximo log binario    (DEFAULT: 1G)
binlog_expire_logs_seconds  = 604800    # Max tempo log binario     (DEFAULT: 2592000)
sync_binlog                 = 0     # Somente pra replicação    (DEFAULT: TRUE)

#   Configurações especificas do InnoDB
innodb_buffer_pool_size         = 10000M    # Tamanho do buffer (<80% mem)  (DEFAULT: 128M)
#http://www.speedemy.com/mysql/17-key-mysql-config-file-settings/innodb_log_file_size/ (Verificar a melhor configuração quando o servidor estiver no ar.
innodb_log_file_size                = 256M      # Tamanho do log de recovery    (DEFAULT: 48M)
innodb_log_buffer_size              = 16M       # Tamanho do buffer     (DEFAULT: 16M)
innodb_flush_log_at_trx_commit      = 0     # Commita o banco a cada evento (DEFAULT: 1)
innodb_flush_method                 = O_DIRECT  # Evita double buffer       (DEFAULT: fsync)
innodb_buffer_pool_instances        = 8     # Regioes que dividem o buffer  (DEFAULT: 8)
innodb_thread_concurrency           = 12        # Limita o numero de threads    (DEFAULT: 0)
innodb_io_capacity                  = 800       # Quantas escritas por segundo  (DEFAULT: 200)
innodb_io_capacity_max              = 3000      # Quantas escritas/s stress (DEFAULT: 2000)
innodb_stats_on_metadata            = 0     # Estatisticas redundantes  (DEFAULT: 0)
innodb_buffer_pool_dump_at_shutdown = 1     # Restart mais rapido       (DEFAULT: 1)
innodb_buffer_pool_load_at_startup  = 1     # Restart mais rápdio       (DEFAULT: 1)
innodb_buffer_pool_dump_pct         = 75        # Restart mais rápido       (DEFAULT: 25)
innodb_adaptive_hash_index_parts    = 16        # Partições de Index        (DEFAULT: 8)
innodb_checksum_algorithm           = crc32         # Aceleração de hardware    (DEFAULT: crc32)
innodb_read_io_threads              = 16        # Threads de leitura        (DEFAULT: 4)
innodb_write_io_threads             = 8     # Threads de escrita        (DEFAULT: 4)
innodb_file_per_table                       # Arquivo por tabelas       (DEFAULT: True)

#   Slow query log 
slow_query_log              = 1     # Guarda queries lentas     (DEFAULT: False)
long_query_time             = 1.0       # Tempo lite da query       (DEFAULT: 10s)

#   Função
log_bin_trust_function_creators     = 1;

我也有一些来自zabbix的度量标准,但我不知道如何解释它。

对于我做错了什么,以及如何解决它,有什么想法吗?

EN

回答 2

Database Administration用户

回答已采纳

发布于 2020-06-26 05:01:22

交换性的默认值为60;将其更改为1:http://mysql.rjweb.org/doc.php/memory#swappiness

票数 0
EN

Database Administration用户

发布于 2020-06-24 17:58:27

交换是正常的,并不一定表示出问题。

但是,您可以确保缓冲池不会被交换掉。在启动时分配10 in的巨大页面,并指示MySQL从那里分配它的innodb_buffer_pool (my.cnf中的大页面=1)。巨大的页面是不可交换的,因此这将确保您的缓冲池永远不会被交换掉。

票数 0
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/269817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档