码迷,mamicode.com
首页 > 数据库 > 详细

Mysql主从搭建(2)-热备-不锁表

时间:2015-08-08 11:41:22      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

Master上授权从库:

```
grant replication slave on *.* to slave1@ip identified by ‘password‘;
```

 

基于数据库hotcopy备份脚本处理:

```

[root@iZ232n10udnZ 20150806104509]# ls
backup-my.cnf SSS  ibdata1 ib_logfile0 ib_logfile1 abc  xtrabackup_binlog_info xtrabackup_binlog_pos_innodb xtrabackup_checkpoints xtrabackup_galera_info xtrabackup_info xtrabackup_logfile

[root@iZ232n10udnZ 20150806104509]# cat xtrabackup_binlog_pos_innodb
mysql-bin.000043 774365349

```

 

```
service mysql stop
rm -rf /var/lib/mysql/ib*
rm -rf /var/lib/mysql/abc
rm -rf /var/lib/mysql/SSS

cp -r /data/20150806104509/abc  /data/20150806104509/SSS ib* /data/mysql (将备份数据scp到slave上)

chown -R mysql:mysql /data/mysql (授权mysql用户)

service mysql start
```

 

重启slave Mysql,进行以下操作:

```
mysql -uroot -p

change master to master_host=‘ip‘, master_user=‘slave1‘, master_password=‘password‘, master_port=3306, MASTER_LOG_FILE=‘mysql-bin.000043‘, MASTER_LOG_POS=774365349;

slave start;

show slave status\G
```

出现两个Yes,配置成功,
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

Mysql主从搭建(2)-热备-不锁表

标签:

原文地址:http://www.cnblogs.com/martinjinyu/p/4712659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!