1.编辑配置文件/etc/my.cnf
# 确保有如下行
server-id = 1
log-bin=mysql-bin
binlog-do-db=mysql #需要备份的数据库名,如果备份多个数据库,重复设置这个选项即可
binlog-ignore-db=mysql #不需要备份的数据库名,如果备份多个数据库,重复设置这个选项即可
log-slave-updates #这个参数一定要加上,否则不会给更新的记录些到二进制文件里
slave-skip-errors #是跳过错误,继续执行复制操作
2.建立用户
mysql> grant replication slave on *.* to slave@192.168.0.2 identified by ‘111111′;
# grant replication slave on *.* to ‘用户名'@'主机' identified by ‘密码';
# 可在Slave上做连接测试: mysql -h 192.168.0.1 -u test -p
3.锁主库表
mysql> FLUSH TABLES WITH READ LOCK;
4.显示主库信息
记录File和Position,从库设置将会用到
=====================
mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_do_db | Binlog_ignore_db |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 106 | | |
+------------------+----------+--------------+------------------+
原载于:
全文:
阅读(1148) | 评论(0) | 转发(0) |