Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql数据无法复制,但复制似乎很好_Mysql_Replication_Mariadb_Database Replication - Fatal编程技术网

mysql数据无法复制,但复制似乎很好

mysql数据无法复制,但复制似乎很好,mysql,replication,mariadb,database-replication,Mysql,Replication,Mariadb,Database Replication,我有一个运行mariadb 10.0.21的4机mysql集群。我有两个主控装置,它们相互独立。然后是分别从第一个和第二个db复制的两个只读从机 简而言之,其设置方式如下: db1 replicates -> db2 db1 replicates -> db3 db2 replicates -> db1 db2 replicates -> db4 这是一个相当基本的4dB设置 我遇到的问题是,我设置了一个nagios用户来监视第一个db上的集群 我检查了,我可以登录前3

我有一个运行mariadb 10.0.21的4机mysql集群。我有两个主控装置,它们相互独立。然后是分别从第一个和第二个db复制的两个只读从机

简而言之,其设置方式如下:

db1 replicates -> db2
db1 replicates -> db3
db2 replicates -> db1
db2 replicates -> db4
这是一个相当基本的4dB设置

我遇到的问题是,我设置了一个nagios用户来监视第一个db上的集群

我检查了,我可以登录前3个数据库,但不能使用nagios用户登录第4个数据库。我不需要在每个数据库上创建nagios用户就可以做到这一点,因为我正在前两台数据库机器上复制我的mysql数据库

但是由于某些原因,nagios用户从来没有像在db2上那样在db4上创建过,即使在所有节点上都可以进行复制

您可能还记得,我有一个复制到第四个db的db 2

如果我在db 2上显示主机状态,我可以看到我正在复制mysql db:

MariaDB [mysql]> show master status;
+--------------------+----------+------------------------------+------------------+
| File               | Position | Binlog_Do_DB                 | Binlog_Ignore_DB |
+--------------------+----------+------------------------------+------------------+
| mariadb-bin.000078 |      376 | jfwiki,jokefire,bacula,mysql |                  |
+--------------------+----------+------------------------------+------------------+
1 row in set (0.00 sec)
如果我检查nagios用户是否在第二个db上,它就是

 MariaDB [mysql]> select User,Host,Password from user where user like 'nagios';
    +--------+-------------+-------------------------------------------+
    | User   | Host        | Password                                  |
    +--------+-------------+-------------------------------------------+
    | nagios | 52.4.204.96 | *somepasswordhash                         |
    +--------+-------------+-------------------------------------------+
    1 row in set (0.00 sec)
这个用户不是在db2上创建的,而是因为复制而存在的

如果我检查db4上的从机状态,复制似乎完全正常:

[root@db4:~] #mysql -e "show slave status\G" | egrep "Slave_IO_State|Master_Host|Slave_IO_Running|Slave_SQL_Running|Last_Errno|Seconds_Behind_Master"
               Slave_IO_State: Waiting for master to send event
                  Master_Host: db2.example.com
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
                   Last_Errno: 0
        Seconds_Behind_Master: 0
如果我像在db2上那样检查db4上是否存在nagios用户,那么用户就不存在了:

MariaDB [mysql]> select User,Host from user where user like 'nagios';
Empty set (0.00 sec)
所以我的问题是,为什么nagios用户没有像从db1->db2和从db1->db3那样复制到db4?即使是db4上的从机复制似乎也没问题?我可以从监控主机使用nagios用户登录所有这些主机

下面是db4上的slave replication命令的完整输出,以防我之前从grep中漏掉任何内容:

MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: db2.example.com
                  Master_User: jf_slave
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mariadb-bin.000078
          Read_Master_Log_Pos: 376
               Relay_Log_File: db4-relay-bin.000044
                Relay_Log_Pos: 537
        Relay_Master_Log_File: mariadb-bin.000078
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 376
              Relay_Log_Space: 1121
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: Yes
           Master_SSL_CA_File: /opt/mysql/ca.crt
           Master_SSL_CA_Path:
              Master_SSL_Cert: /opt/mysql/db4.example.com.crt
            Master_SSL_Cipher:
               Master_SSL_Key: /opt/mysql/db4.example.com.key
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 2
               Master_SSL_Crl: /opt/mysql/ca.crt
           Master_SSL_Crlpath:
                   Using_Gtid: No
                  Gtid_IO_Pos:
1 row in set (0.00 sec)
我在db4上的mariadb日志中看到了一些错误,但是它们与我在nagios用户数据成功复制的前3个数据库中看到的错误没有什么不同

151004 15:34:36 [Note] Error reading relay log event: slave SQL thread was killed
151004 15:34:36 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)
151004 15:34:36 [Note] Slave I/O thread killed while reading event
151004 15:34:36 [Note] Slave I/O thread exiting, read up to log 'mariadb-bin.000078', position 376
151004 15:36:47 [Note] Slave SQL thread initialized, starting replication in log 'mariadb-bin.000078' at position 376, relay log './db4-relay-bin.000042' position: 537
151004 15:36:47 [Note] Slave I/O thread: connected to master 'jf_slave@db2.example.com:3306',replication started in log 'mariadb-bin.000078' at position 376
151007  4:24:12 [Note] Error reading relay log event: slave SQL thread was killed
151007  4:24:12 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)
151007  4:24:12 [Note] Slave I/O thread killed while reading event
151007  4:24:12 [Note] Slave I/O thread exiting, read up to log 'mariadb-bin.000078', position 376
151007  4:28:20 [Note] Slave SQL thread initialized, starting replication in log 'mariadb-bin.000078' at position 376, relay log './db4-relay-bin.000043' position: 537
151007  4:28:20 [Note] Slave I/O thread: connected to master 'jf_slave@db2.example.com:3306',replication started in log 'mariadb-bin.000078' at position 376
那么,当所有的复制指标看起来都正常时,为什么会出现这种数据库不一致性呢?为什么nagios用户不能像在前3个db上那样登录到db4


谢谢

,因为您需要在每台服务器的CNF文件中设置日志从属更新。

您的所有节点都有相同的硬件吗?是否所有节点都有不同的服务器ID?n另外,如果您在db4上失去连接,这通常是不可能的,那么在创建nagios用户时,连接是否丢失了?你为什么不在从机上创建这个用户呢?很难确切地知道为什么它没有在从机上创建…有一个像从机漂移这样的东西…Percona在mysql中构建了一个完整的工具来重新同步从机…它们都来自AWS上完全相同的ami。在操作系统、内存、磁盘、,等等,我检查了所有节点上的服务器id,它们是唯一的:检查db1服务器id=1 db2服务器id=2检查db3服务器id=3检查db4服务器id=4上的服务器id,我不只是在db4上创建nagios用户的原因是我以前见过这个问题。我使用db farm运行wiki。我注意到每隔一段时间,我会创建一个页面或修改一些文本。更改只会转到一个db节点。当我检查复制时,复制设置中的一切都正常。例如,我将进入wiki站点的配置,而不是使用db数组,我将一次只将配置指向一个db主机,直到找到“丢失”页面或更改的内容。在这一点上,我通常会从良好的数据库中转储该数据库,并将其导入到缺少所需更改的所有其他主机上。所以,我之所以对nagios的用户问题大做文章,是因为我认为这说明了我一直以来在丢失wiki页面方面遇到的问题。你如何建议在不向Percona掏钱的情况下打击奴隶漂流?谢谢percona工具重新同步从站是免费的。。。