电商平台--Mysql主从搭建(2)

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

posted @ 2015-08-08 10:21  Martin2  阅读(241)  评论(0编辑  收藏  举报