MySQL 每 25 天左右就会被操作系统杀死一次

MySQL 每 25 天左右就会被操作系统杀死一次

大约 4 个月前,我们从微软SQL服务器MySQL 5.5。从那时起,我们大约每 25 天就会遇到一次 CentOS 内存不足并导致 MySQL 终止的问题。 MySQL 安全地重新启动 mysql,因此数据库只会完全关闭一两分钟,但在 CentOS 杀死 mysqld 线程之前,我们可能会遭受性能和连接损失几个小时。

我们通常会在凌晨 1 点到 5 点之间看到问题,但绝不会在白天流量最高的时候进行,这才是这种情况真正令人困惑的地方。尽管通常会在凌晨 1 点到凌晨 5 点出现连接和性能问题,但 mysql 服务器通常会在凌晨 4 点或 5 点左右被终止,大约在 mysqldump 运行的时间。

我们认为mysqldump可能是罪魁祸首。然而,它每天凌晨 4 点开始,但在某些晚上我们早在凌晨 1 点就发现了问题。也mysqldump与交换机一起运行--opt,因此在转储过程中不应缓冲大量数据。

我们还考虑了我们正在使用的备份应用程序,它获取转储文件并将其备份到磁带。我们将运行时间更改为早上 6 点,问题没有改变。

我们有几个作业会在整个晚上定期运行,但没有一个作业是资源密集型的,并且运行起来根本不需要很长时间。

以下是我们正在处理的内容以及my.cnf文件中当前条目的一些统计信息。对于我们可以尝试的任何帮助或建议,我们将不胜感激。

服务器统计:

  • 英特尔(R) 至强(R) CPU E5530 @ 2.40GHz
  • CPU核心数:4
  • 内存:12293480(12GB)

操作系统:

  • CentOS 5.5
  • Linux 2.6.18-274.12.1.el5 #1 SMP 11 月 29 日星期二 13:37:46 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

我的CNF:

[client]
port = 3306
socket = /var/lib/mysql/mysql.sock

[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock

skip-name-resolve

ssl-ca=<file location>
ssl-cert=<file location>
ssl-key=<file location>

back_log = 50
max_connections = 500
table_open_cache = 2048
table_definition_cache = 9000
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 130
thread_concurrency = 16
query_cache_size = 64M
query_cache_limit = 1M
ft_min_word_len = 4
default-storage-engine=INNODB
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M
log-bin=/log/mysql/mysql-bin
expire_logs_days=7
binlog_format=mixed
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 7G
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 70
innodb_lock_wait_timeout = 120

[mysql]
no-auto-rehash

[mysqld_safe]
open-files-limit = 8192

答案1

  1. 你应该检查 MySQL 错误日志

  2. ulimit -a检查该值是否与打开的文件相同:

    int my.cnf 
    [mysqld_safe]
    open-files-limit = 8192
    

答案2

你的配置有问题。

这里用这个工具。它会告诉您自定义配置需要多少内存 RAM?

正如你所提到的,你当前的 RAM 是,12GB但你需要31.6GB500 个活跃的 MySQL 连接。

Session variables
max_allowed_packet 16.0 MB
sort_buffer_size 8.0 MB
net_buffer_length 16.0 KB
thread_stack 192.0 KB
read_rnd_buffer_size 16.0 MB
read_buffer_size 2.0 MBSession variables
max_allowed_packet 16.0 MB
sort_buffer_size 8.0 MB
net_buffer_length 16.0 KB
thread_stack 192.0 KB
read_rnd_buffer_size 16.0 MB
read_buffer_size 2.0 MB
join_buffer_size 8.0 MB
Total (per session)50.2 MB
Global variables
innodb_log_buffer_size 1.0 MB
query_cache_size 64.0 MB
innodb_buffer_pool_size 7.0 GB
innodb_additional_mem_pool_size 16.0 MB
key_buffer_size 32.0 MB
Total 7.1 GB
Total memory needed (for 500 connections): 31.6 GB

相关内容