Enable master-slave replication for MySQL master Hot Backup

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.