【问题标题】:mysqldump hangs server [closed]mysqldump挂起服务器[关闭]
【发布时间】:2011-12-14 10:31:26
【问题描述】:

我有问题。我在我的一台服务器 (eAthena) 上运行开源游戏软件,他们使用 MySQL 作为首选数据库。但是,每次我运行 mysqldump

mysqldump -u backup -p*** eathena > test-backup.sql

它最终会挂起服务器。 eAthena 软件挂起,并在完成后关闭。这是尺寸问题吗?看到数据库是4.7gb,我不知道该怪什么。我的mysqldump有什么替代品吗?

我正在运行 CentOS 6 64 位,MySQL 版本 5.1.52。

【问题讨论】:

  • 假设它是一个 64 位的 mysql,4.7gb 应该是一个(长)眨眼时间。什么类型的桌子?如果他们是 myisam,您可以尝试使用 check tablerepair tables 检查是否存在损坏。

标签: mysql centos mysqldump centos6


【解决方案1】:

您的 mysql 安装似乎内存不足。检查 /etc/my.cnf 或 /etc/mysql/my.cnf(或 CentOS 上的任何位置)。

增加 table_cache 和 key_buffer_size 。查看mysql安装自带的confs示例:my-huge.cnf’,my-large.cnf',my-medium.cnf’, andmy-small.cnf'。将您的 confs 与此进行比较:

[mysqld]
# Reduced to 200 as memory will not be enough for 500 connections.
# memory=key_buffer+sort_buffer_size+read_buffer_size)*max_connections
# which is now: 64 + (1 + 1) * 200 = 464 MB
# max_connections = approx. MaxClients setting in httpd.conf file
# Default set to 100.
max_connections = 100
max_allowed_packet = 1M
max_connect_errors = 10
key_buffer = 512M # 128M for 1GB, 256M for 2GB, 512 for 4GB
join_buffer_size = 4M # 1M for 1GB, 2M for 2GB, 4M for 4GB
read_buffer_size = 4M # 1M for 1GB, 2M for 2GB, 4M for 4GB
sort_buffer_size = 2M # 1M for 1GB, 2M for 2GB, 4M for 4GB
# myisam_sort_buffer_size used for ALTER, OPTIMIZE, REPAIR TABLE commands.
myisam_sort_buffer_size = 32M
# Checked opened tables and adjusted accordingly after running for a while.
table_cache = 1024
# thread_concurrency = 2 * (no. of CPU)
thread_concurrency=4
thread_cache_size = 286
# log slow queries is a must. Many queries that take more than 2 seconds.
# If so, then your tables need enhancement.
log_slow_queries=/var/log/mysqld.slow.log
long_query_time=2
# Reduced wait_timeout to prevent idle clients holding connections.
wait_timeout = 10
connect_timeout = 10
interactive_timeout = 10
# Enable it for vast improvement and it may be all you need to tweak.
query_cache_limit = 1M
query_cache_size = 128M
query_cache_type = 1
[mysqld_safe]
open_files_limit = 8192
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer = 256M # 64M for 1GB, 128M for 2GB, 256 for 4GB
sort_buffer = 256M # 64M for 1GB, 128M for 2GB, 256 for 4GB
read_buffer = 64M # 16M for 1GB, 32M for 2GB, 64M for 4GB
write_buffer = 64M # 16M for 1GB, 32M for 2GB, 64M for 4GB
[mysqlhotcopy]
interactive-timeout

重试前别忘了重启mysql服务器

【讨论】:

  • 这确实有效,但我认为为了节省空间/带宽,我不会备份不必要的日志/表(这也解决了我的问题)。
  • 添加 --single-transaction 对我有用
猜你喜欢
  • 2012-12-29
  • 1970-01-01
  • 2012-12-25
  • 1970-01-01
  • 2015-04-08
  • 2011-01-15
  • 1970-01-01
  • 1970-01-01
  • 2014-02-28
相关资源
最近更新 更多