2.3、重启多实例
[iyunv@localhost data]# /etc/init.d/mysqld_multi restart
[iyunv@localhost data]# /etc/init.d/mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3307 is running
MySQL server from group: mysqld3308 is running
[iyunv@localhost data]#
2.4、登录3307端口主mysql,并建立账户并授权slave
[iyunv@localhost data]# mysql -u root -h127.0.0.1 -P3307 -plila3307
mysql> GRANT REPLICATION SLAVE ON *.* to 'slave'@'%' identified by 'lilaslave';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> 查看master状态信息
mysql> show master status
-> ;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 | 590 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> use ceshi_db;
Database changed
mysql> create table home(id int(10) not null,name char(10));
Query OK, 0 rows affected (0.11 sec)
mysql>
2.7、查看slave服务器是否有ceshi_db数据库和home表,及表结构是否相同
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ceshi_db |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.06 sec)
mysql> use ceshi_db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+--------------------+
| Tables_in_ceshi_db |
+--------------------+
| home |
+--------------------+
1 row in set (0.00 sec)
mysql> desc home;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| id | int(10) | NO | | NULL | |
| name | char(10) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.03 sec)