Master上授权从库:
```
grant replication slave on *.* to slave1@ip identified by 'password';
```
逻辑备份:
```
mysqldump --single-transaction --master-data database -uroot -ppassword
|gzip > database_backup.sql.zip
```
解压:
```
gunzip -c database_backup.sql.zip > database_backup.sql
```
将导出的数据,导入slave服务器,
```
mysqladmin -uroot -p create database && mysql -uroot -p database <database.sql
```
重启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.000021', MASTER_LOG_POS=12312123123; (在database.sql文件30-40行之间)
slave start;
show slave status\G
```
出现两个Yes,配置成功,
Slave_IO_Running: Yes
Slave_SQL_Running: Yes