主机开两个窗口,一个进入mysql,一个是shell
主机阻断写操作
-
mysql> FLUSH TABLES WITH READ LOCK;
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
mysql>
-
-
mysql>
-
-
mysql> SHOW MASTER STATUS;
-
-
+------------------+----------+--------------+------------------+
-
-
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
-
-
+------------------+----------+--------------+------------------+
-
-
| mysql-bin.000002 | 1529881 | openser | mysql,test |
-
-
+------------------+----------+--------------+------------------+
-
-
1 row in set (0.00 sec)
另外一个窗口导出主机数据库
-
mysqldump -u root -p123456 openser > openser20121203.sql
刚才的窗口主机解锁
-
mysql> UNLOCK TABLES;
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
mysql>
打包数据文件到从机
-
drop database openser;
-
-
create database openser;
-
-
mysql -u root -p123456 openser < openser20121127.sql
从机操作
-
SLAVE STOP;
-
-
reset slave;
-
-
CHANGE MASTER TO MASTER_HOST='192.168.21.26',
-
-
MASTER_USER='repl_user',
-
-
MASTER_PASSWORD='123456',
-
-
MASTER_LOG_FILE='mysql-bin.000002',
-
-
MASTER_LOG_POS=1529881;
-
-
start slave;
-
-
show slave status\G
阅读(814) | 评论(0) | 转发(0) |