【发布时间】:2012-02-16 16:26:55
【问题描述】:
搜索了几天,但仍然没有解决方案。
我的情况
我正在使用这个命令转储一个 16+Gb(增长)的数据库(除了 2 个表都是 InnoDB)
转储每天通过 cron 运行一次,并位于一个小的 perl 脚本中
mysqldump -uuser -pxxx --single-transaction --quick DBNAME > DBBACKUP.sql
现在该网站有 2 个读/写非常繁重的主表(但是,当转储实际发生在早上时负载较低)
数据库有 54 个表(大多数在 10-20 MB 以下)
表 1 是 7100 万行 (9GB) 的 InnoDB 表
表 2 是 2500 万行 (3GB) 的 InnoDB 表
现在当转储运行时,应用程序(访问表 1 或 2)很好,直到转储大约 3 分钟,当我预计表 1 开始备份时,提交数据时的网站待插入Table 1 挂起大约9 分钟,然后再次工作,然后Table 2 开始转储,使用Table 2 的应用程序strong> 开始挂起。
--single-transaction 不应该锁定表
--quick 不应该在内存中缓冲
最后,当转储发生时,CPU 和 MEM % 非常低。
那么有没有人看到这个并知道解决方案或有任何建议?
系统规格
Processor: Dual Intel Xeon E5506 Quad Core
RAM: 12 Gb DDR3
HD1: 4 147 Gb SAS drives in a RAID 10 array
HD2: 500 Gb SATA Backup Drive
OS: Linux OS - CentOS 5 64-bit
MY.CNF
max_connections = 500
safe-show-database
skip-locking
key_buffer = 128M
max_allowed_packet = 16M
table_cache = 256
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 64M
thread_concurrency = 8
wait_timeout = 30
innodb_file_per_table
innodb_log_file_size = 10485760
open_files_limit = 8192
ft_min_word_len = 3
log-error=/var/log/mysql/mysql-error.log
log-slow-queries = /var/log/mysql/mysql-slow.log
long_query_time = 7
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
谢谢。
【问题讨论】:
-
一个更正:
--single-transaction确实锁定了表,这就是这个选项的重点:数据库在转储完成之前被“冻结”,这样您就可以拥有一致的数据库视图。
标签: mysqldump