實驗環境:mysql
兩臺centos7服務器作mysql主服務器:master01/master02;sql
兩臺centos7服務器作mysql從服務器:slave01/slave02;數據庫
一臺centos7服務器作監控服務器:monitorvim
問題一:master01 建立新的數據庫abc,slave01上查看,未進行未進行數據同步。centos
master01數據庫查詢以下:bash
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | abc | | mysql | | performance_schema | | test |
slave01數據庫查詢以下:服務器
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ //新建的數據表未進行同步
解決過程:ide
一、查看slave01的配置狀況:
測試
MariaDB [(none)]> show slave status\G Last_IO_Error: error connecting to master 'replication@192.168.109.129:3306' - retry-0 message: Access denied for user 'replication'@'192.168.109.159' (using password: YES) //看不懂... //從新啓動服務,出現新的報錯 MariaDB [(none)]> stop slave; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> start slave -> ; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> show slave status\G; Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave s does not always make sense; please check the manual before using it). //大概意思爲使用了相同的server-id
二、配置文件中進行查看ui
vim /etc/my.cnf //發現與master01的server-id都設置成了1 進行修改成不一樣的server-id
三、從新啓動服務
[root@localhost ~]# systemctl stop mariadb.service [root@localhost ~]# systemctl start mariadb.service [root@localhost ~]# systemctl start mysql-mmm-agent.service [root@localhost ~]# systemctl enable mysql-mmm-agent.service
四、使用moniror查看同步狀況
[root@localhost mysql-mmm]# mmm_control show ERROR: Can't connect to monitor daemon! //仍是不行!!
問題二:moniror服務器沒法獲取節點狀況,報錯以下:
MariaDB [(none)]> show slave status\G Last_Error: Error 'Can't drop database 'school'; database doesn't exist' on query. Default databasool'. Query: 'drop database school'
解決過程:
一、看報錯信息,能夠得知是我在以前進行主主服務器同步狀況測試時,建立刪除的school數據庫,因爲slave從服務器還未進行同步,進程卡住,沒法進行下一步操做,因此,部署才未能成功。
二、在從服務器上手動建立一個新的school數據庫,讓系統識別到後,自動刪除一次次數據庫就能夠了
MariaDB [(none)]> create database school; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | school | | test | +--------------------+
三、若是仍是不行,則退出數據庫,進行重啓服務
MariaDB [(none)]> quit Bye [root@slave02 ~]# [root@slave02 ~]# systemctl restart mariadb.service
四、再次進入數據庫查看,school數據庫已自動刪除,且與master01數據庫相同。
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | abc | | mysql | | performance_schema | | test | +--------------------+
五、使用監控服務器monitor查看節點成功
[root@localhost mysql-mmm]# mmm_control show db1(192.168.109.129) master/ONLINE. Roles: writer(192.168.109.188) db2(192.168.109.160) master/ONLINE. Roles: db3(192.168.109.162) slave/ONLINE. Roles: reader(192.168.109.189) db4(192.168.109.159) slave/ONLINE. Roles: reader(192.168.109.190)
試驗成功。