分类: Mysql/postgreSQL
2013-06-15 10:40:06
grant replication slave on *.* to repl_user@'%' identified by '123a' WITH GRANT OPTION;
mysql> flush tables with read lock;
Query OK, 0 rows affected (0.00 sec)
mysqldump -h127.0.0.1 -uye -p123a --all-databases > backup.sql
mysql> unlock tables;
Query OK, 0 rows
affected (0.01 sec)
scp backup.sql
192.168.1.241:/root/
Vim /etc/my.cnf
log-bin =master-bin
log-bin-index =master-bin.index
server-id =1
/etc/init.d/mysqld
restart
mysql -uye -p123a
< backup.sql
Vim
/etc/my.cnf
server-id =2
relay-log-index
=slave-relay-bin.index
relay-log =slave-relay-bin
slave_skip_errors = 1062(出现下面告警后添加该选项skip)
/etc/init.d/mysqld
restart
3 将slave连接到master
mysql>
change master to master_host='192.168.1.240',master_port=3306, master_user='repl_user',
master_password='123a';
Last_SQL_Error:
Error 'Duplicate entry '%-test-' for key 'PRIMARY'' on query
SLAVE