操作步骤九:确认并验证配置
使用 show slave status\G 查看从服务器状态。
使用 SHOW VARIABLES LIKE 'auto_inc%'; 查看自动递增设置。
在一台上创建测试表、插入和更新数据,到另外一台上是否被复制。
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: xxx.170
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 107
Relay_Log_File: s156-relay-bin.000002
Relay_Log_Pos: 253
Relay_Master_Log_File: mysql-bin.000001
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: 107
Relay_Log_Space: 408
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_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: 170
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'auto_inc%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 2 |
| auto_increment_offset | 1 |
+--------------------------+-------+
2 rows in set (0.00 sec)
mysql> use test
Database changed
mysql> create table test1 (id integer not null primary key);
Query OK, 0 rows affected (0.00 sec)
在另外一台看看是否复制过来了
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| test1 |
+----------------+
1 rows in set (0.00 sec)
更多的确认测试可自行进行,比如:insert/update/delete等操作。
操作步骤十:恢复应用运行
与操作步骤一对应,要把应用程序和定时任务恢复过来。
比如:
1. tomcat等应用服务器。
2. crontab中的与数据库有关的定时任务。
3. 其他与数据库有关的程序。
配置结束,大功告成!
