标签:使用 注意 nav server 日志 lis res 同步数据 select
主机名
|
系统版本
|
MySQL版本
|
主机IP
|
master
|
CentOS 6.8
|
MySQL 5.6
|
172.24.8.10
|
slave01
|
CentOS 6.8
|
MySQL 5.6
|
172.24.8.11
|
slave02
|
CentOS 6.8
|
MySQL 5.6
|
172.24.8.20
|
1 [root@Slave02 ~]# yum list installed | grep mysql #查看是否存在其他MySQL组件 2 [root@Slave02 ~]# yum -y remove mysql-libs.x86_64 #为避免冲突引发报错,卸载已存在的组件 3 [root@Slave02 ~]# wget http://mirrors.ustc.edu.cn/mysql-repo/mysql-community-release-el6-5.noarch.rpm 4 [root@Slave02 ~]# rpm -ivh mysql-community-release-el6-5.noarch.rpm 5 [root@Slave02 ~]# yum install mysql-community-server -y 6 [root@Slave02 ~]# chkconfig --list | grep mysqld #查看MySQL是否加入启动项 7 [root@Slave02 ~]# chkconfig mysqld on
1 [root@Master ~]# service mysqld start 2 [root@Master ~]# mysql_secure_installation 3 [root@Master ~]# service iptables stop 4 [root@Master ~]# chkconfig iptables off
1 [root@Master ~]# mysql -uroot -px120952576 2 mysql> flush tables with read lock; #锁定主库的表 3 mysql> show master status\G
1 [root@Master ~]# mysqldump -R -u root -p mysqltest >/tmp/mysqltest.sql 2 Enter password:
1 [root@Master ~]# mysql -uroot -px120952576 2 mysql> unlock tables;
1 [root@Master ~]# scp /tmp/mysqltest.sql root@172.24.8.20:/tmp
1 [root@Master ~]# mysql -uroot -p 2 Enter password: 3 mysql> create database mysqltest02; 4 mysql> use mysqltest02; 5 mysql> create table user02(id int(5),name char(10)); 6 mysql> insert into user02 values (00002,‘lisi‘); 7 mysql> grant replication slave on *.* to ‘repl_user‘@‘172.24.8.%‘ identified by ‘x12345678‘;
1 [root@Slave02 ~]# vi /etc/my.cnf 2 [mysqld] 3 server-id=3 4 log-bin=mysql-bin 5 relay_log=mysql-relay-bin 6 log_slave_updates=1 7 read_only=1 8 [root@Slave02 ~]# service mysqld restart
1 [root@Slave02 ~]# mysql -uroot -px120952576 2 mysql> create database mysqltest; 3 mysql> use mysqltest; 4 mysql> source /tmp/mysqltest.sql; 5 mysql> select * from mysqltest.user; #查看验证
1 [root@Slave02 ~]# mysql -uroot -px120952576 2 mysql> change master to master_host=‘172.24.8.10‘, 3 master_user=‘repl_user‘, 4 master_password=‘x12345678‘, 5 master_log_file=‘mysql-bin.000003‘, 6 master_log_pos=120; 7 mysql> start slave;
1 [root@Slave ~]# mysql -uroot -px120952576 2 [root@Slave02 ~]# mysql -uroot -px120952576 3 mysql> select * from mysqltest02.user02; 4 #两台slave上均验证master第二次创建的测试库是否正常复制过来。
1 [root@Slave ~]# mysql -uroot -px120952576 2 mysql> stop slave; 3 mysql> show slave status\G
1 [root@Slave01 ~]# mysqldump -R -u root -p mysqltest >/tmp/mysqltest.sql 2 Enter password:
1 [root@Slave01 ~]# scp /tmp/mysqltest.sql root@172.24.8.20:/tmp
1 [root@Master ~]# mysql -uroot -p 2 Enter password: 3 mysql> create database mysqltest02; 4 mysql> use mysqltest02; 5 mysql> create table user02(id int(5),name char(10)); 6 mysql> insert into user02 values (00002,‘lisi‘); 7 mysql> grant replication slave on *.* to ‘repl_user‘@‘172.24.8.%‘ identified by ‘x12345678‘;
1 [root@Slave02 ~]# mysql -uroot -px120952576 2 mysql> change master to master_host=‘172.24.8.10‘, 3 master_user=‘repl_user‘, 4 master_password=‘x12345678‘, 5 master_log_file=‘mysql-bin.000003‘, 6 master_log_pos=932; 7 mysql> start slave;
标签:使用 注意 nav server 日志 lis res 同步数据 select
原文地址:https://www.cnblogs.com/drizzle-xu/p/10276307.html