我有一臺4機mysql羣集運行mariadb 10.0.21。我有兩個主人設置,彼此奴役。然後分別從第一個和第二個數據庫中複製兩個只讀的從站。mysql數據不復制,但複製似乎很好
總之,方法其設置是這樣的:
db1 replicates -> db2
db1 replicates -> db3
db2 replicates -> db1
db2 replicates -> db4
這是一個非常基本的4 DB設置。
我遇到的問題是我設置了一個nagios用戶來監視第一個數據庫上的集羣。
我檢查了一下,我可以登錄前3個數據庫,但沒有第4個與nagios用戶。我可以這樣做,而不是在每個數據庫上創建nagios用戶,因爲我在前兩臺數據庫機器上覆制了我的mysql數據庫。
但由於某種原因,nagios用戶從來沒有在db4上創建,就像在db2上一樣,即使複製在所有節點上看起來都不錯。
正如你可能還記得,我有db 2複製到第四分貝。
如果我做DB 2顯示主人身份,我可以看到我複製MySQL數據庫:
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的用戶有2號分貝,它是。
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從屬地位,複製似乎完全沒問題:
[[email protected]:~] #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
如果我檢查的DB4 Nagios的用戶的存在我在DB2上做的方式,用戶只需ISN 「T有:
MariaDB [mysql]> select User,Host from user where user like 'nagios';
Empty set (0.00 sec)
所以我的問題是,爲什麼Nagios的用戶不會複製到DB從DB1的方式一樣 - > DB2和DB1 - > DB3?即使在db4上從屬複製似乎沒問題?我可以使用監控主機中的nagios用戶登錄所有主機。
下面是從複製命令對DB4全力輸出的情況下,我錯過了什麼,從我的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 '[email protected]: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 '[email protected]:3306',replication started in log 'mariadb-bin.000078' at position 376
那麼爲什麼會有這種數據庫不一致,當所有的複製指標看起來好嗎?爲什麼nagios用戶不能以第一個3分貝的方式登錄到db4?
感謝
做所有的節點都有相同的硬件?你所有的節點有不同的服務器? n如果你的db4連接失去連接,在創建nagios用戶的過程中經常不可能連接失敗?爲什麼不在奴隸上創建該用戶?它很難確切知道它爲什麼沒有被創建在奴隸...有奴隸漂移這樣的事情...... Percona建立了一個完整的工具來重新同步mysql中的奴隸... – BK435
他們都從完全相同AWS上的ami。在操作系統,內存,磁盤等方面都是一樣的。我檢查了所有節點上的server-id,它們是唯一的:檢查db1上的服務器ID server-id = 1 檢查db2上的服務器ID server-id = 2 上DB3檢查服務器ID 的server-id = 3 上DB4檢查服務器ID 服務器ID = 4 而且我不只是創造上DB4 Nagios的用戶的原因是,我見過這個問題之前。我使用db farm來運行wiki。我已經注意到,偶爾,我會創建一個頁面或修改一些文本。並且更改將只轉到一個數據庫節點。 – bluethundr
而當我去檢查複製時,複製設置中的所有操作都可以。例如,我會進入wiki站點的配置,而不是使用db數組,我一次只將配置指向一個db主機,直到找到「丟失」頁面或更改內容。那時我通常會從「好」數據庫轉儲數據庫,並將其導入到所有缺少我所做更改的其他主機上。 所以,我對這個nagios用戶問題做了大量的理由,是因爲我認爲它說明了我一直在丟失維基頁面的問題。 – bluethundr