1、停掉从库
2、备份主库、停止主库
3、将主库/data/mysql 拷贝到 从库/data/mysql
scp -r /data/mysql root@10.81.21.50:/data/
4、配置主库文件
添加[mysqld]
log-bin=mysql-bin
log_bin = /data/mysql/mysql-bin.log
log_bin_index = /data/mysql/mysql-bin.log.index
server-id = 1
5、配置从库文件
添加[mysqld]
log-bin=mysql-bin
log_bin = /data/mysql/mysql-bin.log
log_bin_index = /data/mysql/mysql-bin.log.index
log-bin-trust-function-creators=1
max_binlog_size=1024M
server-id = 3838
relay-log=/data/mysql/replicate
relay-log-index=/data/mysql/replicate.index
read-only=1
replicate-ignore-db=mysql
log-slave-updates
6、开启主库,并查看master状态
service mysqld start;mysql -e -ppassword 'show master status;'
得到log_pos
7、主库设置帐号
GRANT REPLICATION SLAVE ON *.* TO 'slave'@'10.81.21.%' IDENTIFIED BY 'Wsjhdsuywad';
10.81.21.50
8、开启从库,启动从服务,查看状态
slave start;
发现开不起来,因为没有设置住服务器
# change master to master_user='slave',master_password='
Wsjhdsuywad',master_host='10.84.50.4',master_log_file='mysql-bin.000001',master_log_pos=xxxx;
show slave status\G;
阅读(1315) | 评论(0) | 转发(0) |