- 论坛徽章:
- 0
|
大家好,环境:老的数据库有一台 192.168.1.200
两台mysql数据服务器 192.168.1.201 192.168.1.202
规划是 1.201为一个主,1.202为 一个从
情况是这样,我们需要讲老的数据库迁移到两台新的数据库服务器上,并且两台新服务器做主从复制。我的计划是把老数据库的数据停机拷贝到新的数据库主服务器上,然后通过设置另一台新服务器做从库同步过来完成迁移但是我遇到一个问题,我把老的数据库的文件拷贝到新的1.201主服务器上,然后启动数据库,记录binlog 和pos位置。
主服务器恢复后的数据库列表是这样的
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MAMA |
| eason_db |
| kuaiwenwu_db |
| mysql |
| performance_schema |
+--------------------+
查看主服务器的master状态是这样的:
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 | 610 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
(注意此时两台新服务器没有做主动关系,我的计划是老数据迁移到1.201服务器上后启动在建立主从关系 ),201的服务器
可以正常启动,数据迁移成功,我现在开始给这个主服务器配置一个1.202的从服务器,登录到202数据库操作命令如下
CHANGE MASTER TO
MASTER_HOST='192.168.1.202',
MASTER_PORT=3306,
MASTER_USER='repl',
MASTER_PASSWORD='123456',
MASTER_LOG_FILE='mysql-bin.000003',
MASTER_LOG_POS=610;
然后我启动start slave;
我立马show slave status\G;查看状态是正常的。
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.202
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 704
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 377
Relay_Master_Log_File: mysql-bin.000003
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: 704
Relay_Log_Space: 551
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: 102
Master_UUID: cab20793-c53d-11e7-9e5e-00155d017a00
Master_Info_File: /var/lib/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.01 sec)
ERROR:
No query specified
此时的202从服务器的列表为mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MAMA |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
PS 其中的MAMA数据库是我创建主从关系后在主创建的 可以正常同步 ,总结一句话就是 创建主从之后的操作都可以同步,创建主从关系之前的数据库都不同步了,请问是哪里除了问题,
是我的操作步骤 还是先把两台新服务器先建立主从关系后在去拷贝老数据到新主上呢。大神知道下感激不尽。
到此位置我发现个问题,我的从数据库完全不同步eason_db\kuaiwenwu_db,
|
|