MySQL Replication正在运行,现已破裂

时间:2013-07-23 18:33:37

标签: mysql ubuntu replication

所以一个月前我设置了从我的一个Web服务器到m个本地LAN服务器的复制。我有2个本地LAN服务器,它们是主Web服务器(falcon)的从属服务器(四核和十六进制)。几周以来,复制工作没有问题。

然后我在本周早些时候注意到I / O线程没有在quad或hex上运行。所以我一遍又一遍地重新启动它们,因为对于至少一个从属设备来说,一切都会正常运行,持续时间长达几分钟。然后I / O线程将再次停止工作。我试图通过phpmyadmin在两台局域网机器上重新配置主机,而phpmyadmin则报告从机已连接到主机。 phpmyadmin给了我现在的选项(那不是昨天)同步奴隶DB和主人的。我运行它并在几秒钟内页面停止加载但没有给出响应(错误或其他)。

所有涉及的机器都在Ubuntu 12.04上运行LAMP堆栈。 Web服务器是12.04服务器,而LAN机器是12.04桌面。我怀疑我在局域网机器上运行apt-get update / upgrade而忽略了我的猎鹰。所以今天早上我在三台机器上运行它。仍然I / O线程不会运行。

SQL线程始终在运行。有时,主站显示其中一个从站(十六进制)已连接。但它没有保持联系。

就像我说的那样,这个问题已经持续数周没有问题。然后最近停了下来。所以这就是为什么我怀疑在最近的更新/升级中有什么东西打破了这一切。

任何人都知道如何使用它?

由于

根据请求添加 - 来自falcon的my.cnf:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port            = xxxx
socket          = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = xxxx
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = xxx.xxx.xxx.xxx
#
# * Fine Tuning
#
key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries       = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size         = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name

# Replication per phpmyadmin - falcon is the MASTER
server-id=8503668
log-bin=mysql-bin
log-error=mysql-bin.err

#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#

# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet      = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer              = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

另外,根据请求添加来自my.cnf的四行线路,用于复制

# Replication per phpmyadmin
server-id=1369932901
report-host=quad
replicate-ignore-db=visits

my.cnf的其余部分是默认的,除了绑定地址是quad的LAN IP 192.168.1.70。十六进制上的my.cnf与server-id不同,report-host是十六进制,它忽略了访问数据库。并且,与quad一样,绑定地址是本地LAN IP 192.168.1.60。

周末更新 这个问题浮出水面4天,没有回答如何修复曾经工作过的破碎复制。我发布了my.cnf(或至少相关部分),但没有人对修复内容有任何建议。在这个问题已经存在的4天中,2个是周末,所以我没想到太多。

昨晚奇怪的是,我第100次对两个奴隶做了一个完整的奴隶开始,终于开始了。这两个奴隶整夜都没有问题,现在报告他们被主人赶上了(落后0秒)。我在主人身上创建了一个垃圾数据库来测试一切都在运行。它几乎立即出现在两个奴隶身上。

我仍然不知道为什么它首先停止工作。有人建议需要经常监控MySQL复制。为此目的,有没有一个好工具? (奴隶是Ubuntu,我主要用PHP编写代码。)

1 个答案:

答案 0 :(得分:0)

  • 如果Slave I/O thread不再在此服务器上运行,请检查slave的错误日志中是否有可能指示此线程可能已停止的消息。
  • 检查错误日志的最后100行,看看是否提供了线索。通常问题是CHANGE MASTER TO命令中给出的错误位置。通常最简单的解决方法是再次设置从站,就像它是一个新的从站一样。 最后一个错误可以由Last Error NumberLast Error
  • 确定
  • 检查您是否能够从从服务器ping / telnet到Master。