1. Enable binlog
Mysql
Servers-id = 151
Log-bin =/opt/soft/mysql/binlog/mysql-bin
Binlog_format = MIXED
2. obtain basic backup
/Opt/soft/mysql/bin/mysqldump-p123456 -- single-transaction -- master-data = 2 AdDataCenter | gzip> AdDataCenter. SQL .gz
3. Activate the user for binlog Replication
Grant replication slave on *. * TO 'repat152' @ '192. 192.% 'identified by '123 ';
4. Restore the database from the machine
Gzip-cd AdDataCenter. SQL .gzip | opt/soft/mysql/bin/mysql-p123456 AdDataCenter
5. Set the database replication Option
Gzip-cd AdDataCenter. SQL .gz | grep-I "CHANGE MASTER"
Binlog file and binlog pos are obtained.
Changemaster to MASTER_HOST = 'master _ host_name ', MASTER_USER = 'replication _ user_name', MASTER_PASSWORD = 'replication _ password', MASTER_LOG_FILE = 'recorded _ log_file_name ', ASTER_LOG_POS = recorded_log_position;
6. Enable slave Database Replication
Start slave