简体   繁体   English

MySQL(MariaDB-10.0.16-MariaDB-1(Debian)奇怪的性能问题

[英]MySQL (MariaDB - 10.0.16-MariaDB-1 (Debian) strange performance issues

I am running version 10.0.16-MariaDB-1 (Debian GNU/Linux 8.1 (jessie)) on Dual Xeon CPU, total 32 cores with 128 GB of RAM. 我在Dual Xeon CPU上运行版本10.0.16-MariaDB-1(Debian GNU / Linux 8.1(jessie)),共有32个核,具有128 GB的RAM。 This is a dedicated DB server and has been recently migrated over from Percona DB server. 这是一台专用的数据库服务器,最近已从Percona数据库服务器迁移过来。 My configuration looks like this, 我的配置看起来像这样,

################################################################################
# DATE: 19-01-2014
# DESCRIPTION: MySQL config
# RAM: 128GB RAM dedicated server
# Connections: 1000 connections
################################################################################

[mysql]
# CLIENT #
port                           = 1979
socket                         = /var/run/mysqld/mysqld.sock

[mysqld]

## Files
back_log            = 300
open-files-limit        = 8192
#open-files             = 1024  

# GENERAL #
user                           = mysql
default-storage-engine         = InnoDB
port                           = 1979
socket                         = /var/run/mysqld/mysqld.sock
pid-file                       = /var/run/mysqld/mysql.pid

# DATA STORAGE #
datadir                        = /var/lib/mysql

# LOGGING #
log-error                      = /var/log/mysql/mysql-error.log
log-queries-not-using-indexes  = 0
slow-query-log                 = 0
slow-query-log-file            = /var/log/mysql/mysql-slow.log

## Per-Thread Buffers * (max_connections) = total per-thread mem usage
thread_stack            = 512K    #default: 32bit: 192K, 64bit: 256K
sort_buffer_size        = 2M      #default: 2M, larger may cause perf issues
read_buffer_size        = 2M      #default: 128K, change in increments of 4K
read_rnd_buffer_size        = 2M      #default: 256K                
join_buffer_size        = 2M      #default: 128K
binlog_cache_size       = 128K    #default: 32K, size of buffer to hold TX queries
## total per-thread buffer memory usage: 17664000K = 17.250GB

## Query Cache
query_cache_size        = 64M   #global buffer
query_cache_limit               = 2M    #max query result size to put in cache

## Connections
max_connections = 900   #multiplier for memory usage via per-thread buffers
max_connect_errors      = 1000  #default: 10
concurrent_insert = 2
connect_timeout         = 10    #default -5.1.22: 5, +5.1.22: 10
max_allowed_packet      = 32M   #max size of incoming data to allow

## Default Table Settings
sql_mode            = NO_AUTO_CREATE_USER

## Table and TMP settings
max_heap_table_size         = 1G    #recommend same size as tmp_table_size
bulk_insert_buffer_size         = 1G    #recommend same size as tmp_table_size
tmp_table_size                  = 1G    #recommend 1G min
tmpdir                         = /dev/shm        #Recommend using RAMDISK for tmpdir

## Table cache settings
#table_cache            = 512   #5.0.x <default: 64>
#table_open_cache       = 512   #5.1.x, 5.5.x <default: 64>

query-cache-type = 1

## Thread settings
thread_concurrency      = 32  #recommend 2x CPU cores
thread_cache_size       = 400 #recommend 5% of max_connections

## InnoDB Plugin Independent Settings
innodb_data_home_dir            = /var/lib/mysql
innodb_data_file_path       = ibdata1:128M;ibdata2:10M:autoextend
innodb_log_file_size        = 768M  #64G_RAM+ = 768, 24G_RAM+ = 512, 8G_RAM+ = 256, 2G_RAM+ = 128 
innodb_log_files_in_group   = 4 #combined size of all logs <4GB. <2G_RAM = 2, >2G_RAM = 4
innodb_buffer_pool_size     = 96G   #global buffer
innodb_additional_mem_pool_size = 8M    #global buffer
innodb_status_file          #extra reporting
innodb_file_per_table           #enable always
innodb_flush_log_at_trx_commit = 2
innodb_table_locks      = 0 #preserve table locks
innodb_log_buffer_size      = 128M  #global buffer
innodb_lock_wait_timeout = 600
#innodb_thread_concurrency = 0
innodb_commit_concurrency = 8   #recommend 4x num disks
innodb_flush_method     = O_DIRECT_NO_FSYNC    #O_DIRECT = local/DAS, O_DSYNC = SAN/iSCSI
innodb_support_xa       = 0        #recommend 0, disable xa to negate extra disk flush
innodb_fast_shutdown = 1
skip-innodb-doublewrite
skip-host-cache
# skip-name-resolve

## Binlog sync settings
## XA transactions = 1, otherwise set to 0 for best performance
sync_binlog         = 0

## TX Isolation
#transaction-isolation      = REPEATABLE-READ #REPEATABLE-READ req for ACID, SERIALIZABLE req XA

## Per-Thread Buffer memory utilization equation:
#(read_buffer_size + read_rnd_buffer_size + sort_buffer_size + thread_stack + join_buffer_size + binlog_cache_size) * max_connections

## Replication
#server_id           = 1
#log_bin             = /var/log/mysql/mysql-bin.log
#log_bin_index       = /var/log/mysql/mysql-bin.log.index
#relay_log           = /var/log/mysql/mysql-relay-bin
#relay_log_index     = /var/log/mysql/mysql-relay-bin.index
#expire_logs_days    = 10
#max_binlog_size     = 100M
#log_slave_updates   = 1
#auto-increment-increment = 2
#auto-increment-offset = 1

## Global Buffer memory utilization equation:
# innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size + key_buffer_size + query_cache_size
long_query_time = 3
innodb_checksum_algorithm=NONE
interactive_timeout = 300
wait_timeout = 40
myisam_repair_threads = 8
myisam-block-size = 8096
innodb_adaptive_hash_index = off
innodb_use_sys_malloc
innodb_sync_array_size = 4
innodb_read_ahead_threshold = 56
innodb_purge_threads = 4
innodb_adaptive_flushing = off
innodb_use_native_aio = off
innodb_random_read_ahead
optimizer_search_depth = 24
table_definition_cache = 400
table_open_cache = 2048
delay-key-write = ALL
innodb_checksum_algorithm = innodb
innodb_write_io_threads = 64
innodb_read_io_threads = 64
thread_pool_size = 16
thread_handling = pool-of-threads

innodb_disable_sort_file_cache
innodb_buffer_pool_instances = 32
innodb_adaptive_hash_index = off

[mysqldump]
quick
quote-names
max_allowed_packet      = 128M

I have multiple hosts connecting to the server and initiating queries. 我有多个主机连接到服务器并启动查询。 The problem I am facing is that randomly the DB server stops accepting connections. 我面临的问题是,数据库服务器随机停止接受连接。 All connections start piling up and in around 3 or 5 seconds it comes back to normal. 所有连接开始堆积,并在大约3或5秒钟内恢复正常。 When I run show processlist I see a lot of connections piled up waiting on to be connected but since the DB server stops accepting connections, eventually the connection pool becomes full, no further connections are allowed. 当我运行show processlist我看到很多连接堆积起来等待connected但是由于DB服务器停止接受连接,最终连接池已满,不允许再有其他连接。

During this blackout period, I am not able to see what's going on the DB server because i just won't give me any info even if the connection is established already. 在此停电期间,我无法查看数据库服务器上发生的情况,因为即使连接已经建立,我也不会提供任何信息。 iostat -d -x 1 won't show anything unusual with the disks, CPU is also mostly idle. iostat -d -x 1不会显示磁盘异常,CPU也大部分处于空闲状态。 TCP connections piles up since the clients wants to open connections because they need to push data. TCP连接堆积如山,因为客户端需要打开数据,因为它们需要推送数据。

I am not able to figure out what's wrong here. 我无法弄清楚这里出了什么问题。 Is this something specific to my DB, or the machine or the config. 这是我的数据库,机器或配置专用的东西吗? I need some help here on where and what to look for to identify and rectify the issue. 在这里,我需要一些帮助,以查找在何处以及寻找什么以找出并纠正该问题。

Thanks. 谢谢。

thread_stack = 512K #default: 32bit: 192K, 64bit: 256K thread_stack = 512K#默认:32位:192K,64位:256K

I have not heard of needing more than 256K. 我还没有听说需要超过256K。 Did you discover a need for 512K? 您是否发现需要512K? Together with 和...一起

max_connections = 900 max_connections = 900

You potentially need 500MB for processes. 您可能需要500MB的进程。 (Granted, this is not a big deal since you have 128GB of ram.) (当然,这不是什么大问题,因为您拥有128GB的内存。)

Back to the problem... 回到问题...

Turn on the slow_log with long_query_time = 1. After the next occurrence, run pt-query-digest against the slowlog. 用long_query_time = 1打开slow_log。在下一次出现之后,对slowlog运行pt-query-digest。 There may be some surprises there. 那里可能会有一些惊喜。 Note that queries hung across the 3-5 second pause will register as taking several seconds, even if they should take only milliseconds. 请注意,在3-5秒的暂停时间内挂起的查询将注册为花费几秒钟,即使它们只需要几毫秒。 There's still a risk that it won't point the finger at the real cause of the Pause. 仍然存在无法将手指指向暂停的真正原因的风险。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM