Chinaunix首页 | 论坛 | 博客
  • 博客访问: 99736
  • 博文数量: 26
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 322
  • 用 户 组: 普通用户
  • 注册时间: 2013-03-27 13:38
文章分类

全部博文(26)

文章存档

2014年(4)

2013年(22)

我的朋友

分类: Mysql/postgreSQL

2013-06-15 10:40:06

MASTER 

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

SLAVE

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  


change master to 
master_host = 'ip/hostname',
master_port = port,
master_password = 'password',
master_user = 'master_user';

start slave;
阅读(1106) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~