17.1 MySQL Master-slave introduction 17.2 Preparation 17.3 Configure Master 17.4 configuration from 17.5 to test master-Slave synchronization

Source: Internet
Author: User
Tags create database

17.1 MySQL Master-slave introduction
18.
The main application scenario
1. Data backup
2. Use as a read library to reduce the pressure on the main library
17.2 preparatory work
Will master and slave both start the MySQL service, linux-01 as the main mysql,linux-02 as from MySQL
17.3 Configuring the Master
Operation in the Lord
Modify MY.CNF, add server-id=130 and Log_bin=aminglinux1

After modifying the configuration file, start or restart the Mysqld service
/etc/inir.d/mysqld restart
View MySQL directory will generate Aminglinux1.index index file with aminglinux1.000001 log file, also generate more log files, this file is the root of the master and slave, very important, no this file master and slave is no way to complete.

Back up the MySQL library and restore it to the aming library, as the test data, the following is the operation
Mysql-uroot Entering the database
Mysqldump-uroot MySQL >/tmp/mysql.sql, backing up the database
MYSQL-UROOT-E "CREATE Database Aming"
Mysql-uroot aming </tmp/mysql.sql recovery database
Create a user to use to synchronize data
Grant replication Slave on .To ' Repl ' @192.168.137.129 identified by ' password '; Specify the privilege and IP
Flush tables with read lock; Lock the table so that it doesn't write to the data, and the state stays here first.
Show master status;

Back up the primary Sync database and copy it to the machine.

17.4 Configuration from

View my.cnf, configuring server-id=132, requirements not the same as the master
Vi/etc/my.cnf

After modifying the configuration file, start or restart the Mysqld service
/etc/init.d/mysqld restart
Sync the Lord Aming library to the top
SCP 192.168.137.128:/tmp/*.sql/tmp/Copy the Master Library to the/tmp/from

Enter from the database
Mysql-uroot
Create a library aming,zrlog. Blog

Recovering data

Mysql-uroot
Stop slave;
Change Master to master_host= ', master_user= ' repl ', master_password= ', master_log_file= ', master_log_pos=xx

Determine whether the master and slave have succeeded

And go to the Lord. Perform unlock tables resume write operations
17.5 testing master-Slave synchronization

Specify a library later or ignore a library, with these 2 parameters can be
replicate_wild_do_table=//As aming.%, wildcard% supported
replicate_wild_ignore_table=

17.1 MySQL Master-slave introduction 17.2 Preparation 17.3 Configure Master 17.4 configuration from 17.5 to test master-Slave synchronization

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.