Production environment MySQL database master slave recovery from database

Source: Internet
Author: User

System hard disk damage, full reload

Faulty machine: 172.16.100.32

Recovery of the main machine according to; 172.16.100.31

1.

After the reload is complete, copy the Master Master Library Vs/program directory and empty the database data directory.

Make sure that the MySQL directory has an empty data directory, and that the owner group of the entire directory is Clouder

Chown-r clouder.clouder/home/clouder/vs/program/mysql/data/

2. Initializing MySQL database with Clouder user

scripts/mysql_install_db--user=clouder--basedir=/home/clouder/vs/program/mysql--datadir=/home/clouder/vs/ Program/mysql/data/pmp

3.

Modify the master configuration file master.cfg, just modify the Server-id to

Server-id = 112

4.

5.mysqldump Logical BACKUP Database

Log in to the main library and dump all the databases.

Mysqldump-h172.16.254.117-uroot-p5505-pengine2ocean-r--all-databases-r--master-data=2--flush-logs >/home/clo Uder/alldatabase ' Date +%f-%h-%m-%s '. sql

--all-databases: Backed up SQL statement containing build-up statements

-r: Stored procedures and triggers

6.

1 Recovering from a library

Start the service

/home/clouder/vs/program/mysql/bin/mysqld--DEFAULTS-FILE=/HOME/CLOUDER/VS/PROGRAM/MYSQL/CONF/MASTER.CNF &

1) Login

Mysql-uroot-p

2) Temporarily turn off the binary log

mysql> SET sql_log_bin = 0

3) Restore the database

Mysql> Source/home/clouder/backup/alldatabase2017-04-17-14-55-08.sql

4) Open Binary log

mysql> SET sql_log_bin = 1;

mysql> flush Privileges;

1) View the binary log files and their corresponding locations at the beginning of the mysqldump SQL file

--Change MASTER to master_log_file= ' mysql-bin.000005 ', master_log_pos=107;

2) Establish Master-slave replication

Change Master to master_host= ' 172.16.100.31 ', master_user= ' slave ', master_password= ' engine ', master_port=5505, master _log_file= ' mysql-bin.000005 ', master_log_pos=107;

3) Open Binary log

Start slave;

mysql> SET sql_log_bin = 1;

mysql> flush Privileges;

Production environment MySQL database master slave recovery from database

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.