MYSQL master/slave data synchronization configuration _ MySQL

Source: Internet
Author: User
MYSQL masterslave data synchronization configuration my test environment. basically, data is synchronized instantly. I hope to help you with redhat9.0mysql3.23.57mysql data synchronization and backup A server: 192.168.1.2 master server masterB server: 192.168.1.3 slave server slaveA server settings # mysql-uroot-pmysqlGRANTFILEO MYSQL master/slave data synchronization configuration
  
In my testing environment, data is basically synchronized in an instant and I hope it will be helpful to you.
  
Redhat 9.0
Mysql3.23.57
  
   Mysql data synchronization backup
  
Server A: master server 192.168.1.2
  
Server B: 192.168.1.3 slave server slave
  
Server A settings
  
# Mysql-u root-p
Mysql> grant file on *. * TO backup@192.168.1.3 identified by '20140901 ';
Mysql> \ exit
  
In the above example, the Master opens an account backup password 1234 to the IP address: 192.168.1.3 and has the permission to process the file.
  
Mysqladmin-u root-p shutdown
  
Back up all the databases on the Master. tar commands are usually used.
  
# Tar-cvf/tmp/mysql.tar/var/lib/mysql
  
Note: When tar is used, MySQL must be stopped.
  
Modify/etc/my. cnf on machine
  
Add parameters in the [mysqld] Section
  
Log-bin
Server-id = 1
SQL-bin-update-same
Binlog-do-db = vbb
  
   Restart Server A mysql
  
In this case, the index is generated because the log-bin parameter is added. The/var/lib/mysql directory contains the. index file to record the change log of the database.
  
Server B settings
  
Set/etc/my. cnf
  
Add in the [mysqld] Section
  
Master-host = 192.168.1.2
Master-user = backup
Masters-password = 1234
Master-port = 3306
Server-id = 2
Master-connect-retry = 60 default retry interval 60 seconds
Replicate-do-db = vbb tell slave to only update the vbb database
Log-slave-updates
  
Copy mysql.tar on A to B
  
Use ftp to transfer B's/tmp
  
9. extract
# Cd/var/lib/
  
   Condition test
  
1. when both A and B networks and services are normal, the data changes from A side to B side to view data and check whether replication is performed ?!
  
2. simulate B as A machine, or B may not always need to be connected to.
  
After the data changed on the side is viewed on the B side, point B should have no data changes.
  
# Tar xvf/tmp/mysql-snapshot.tar
# Chown-R mysql: mysql
  
1. restart mysql of server B.
  
Master.info appears in the/var/lib/mysql directory, which records the information of the Master MySQL server.
  
   Condition test
  
1. when both A and B networks and services are normal, the data changes from A side to B side to view data and check whether replication is performed ?!
  
2. simulate B as A machine, or B may not always need to be connected to.
  
After the data changed on the side is viewed on the B side, point B should have no data changes.

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.