本文共 3021 字,大约阅读时间需要 10 分钟。
实验环境:
两台centos7服务器做mysql主服务器:master01/master02;
两台centos7服务器做mysql从服务器:slave01/slave02;
一台centos7服务器做监控服务器:monitor
问题一:master01 创建新的数据库abc,slave01上查看,未进行未进行数据同步。
master01数据库查询如下:
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| abc |
| mysql |
| performance_schema |
| test |
slave01数据库查询如下:
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
//新建的数据表未进行同步
解决过程:
1、查看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
2、配置文件中进行查看
vim /etc/my.cnf //发现与master01的server-id都设置成了1
进行修改为不同的server-id
3、重新启动服务
[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
4、使用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'
解决过程:
1、看报错信息,可以得知是我在之前进行主主服务器同步情况测试时,创建删除的school数据库,由于slave从服务器还未进行同步,进程卡住,无法进行下一步操作,所以,部署才未能成功。
2、在从服务器上手动创建一个新的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 |
+--------------------+
3、如果还是不行,则退出数据库,进行重启服务
MariaDB [(none)]> quit
Bye
[root@slave02 ~]#
[root@slave02 ~]# systemctl restart mariadb.service
4、再次进入数据库查看,school数据库已自动删除,且与master01数据库相同。
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| abc |
| mysql |
| performance_schema |
| test |
+--------------------+
5、使用监控服务器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)
试验成功。
转载地址:http://kfnzx.baihongyu.com/