Setting MySql data synchronization for online database backup

Source: Internet
Author: User
Online Database Backup settings MySql data synchronization mysql provides the database replication function after version 3.23.15. This feature allows you to synchronize two databases, master-slave mode, and mutual backup mode.
  
The settings of the database synchronization replication function are reflected in the mysql settings file. Mysql configuration file (generally my. cnf)
In the unix environment, either in the/etc/mysql/my. cnf or in the mysql User's home directory my. cnf.
In the window environment, if the c: root directory contains the my. cnf file, the configuration file is used. When you run the mysql/bin/winmysqladmin.exe tool, this tool will name my. cnf in the c: root directory as mycnf. bak. Create my. ini in the winnt directory. The configuration file is read when the mysql server is started. Therefore, you can copy the content in my. cnf to the my. ini file and use the my. ini file as the mysql
The configuration file of the server.
  
Setting method:
Set the sample environment:
Operating system: window2000 professional
Mysql: 4.0.4-beta-max-nt-log
A ip: 10.10.10.22
B ip: 10.10.10.53
A: set
1. add the most synchronous user account:
Grant file on *. * TO backup @ '10. 10.10.53 'identified by '123'
2. add a database as the synchronization database:
Create database backup
B: set
1. add the most synchronous user account:
Grant file on *. * TO backup @ '10. 10.10.22 'identified by '123'
2. add a database as the synchronization database:
Create database backup
  
Master/slave mode: A-> B
A is the master
Modify the my. ini file of mysql. Add the following configuration to the mysqld configuration item:
Server-id = 1
Log-bin
# Set the log to be recorded. you can set log-bin = c:/mysqlbak/mysqllog to set the Directory of the log file,
# Mysqllog is the name of the log file. mysql creates several log files with different extensions named mysqllog.
Binlog-do-db = backup # specify the database for logs
  
Restart database service
Use the show master status command to view the logs.
  
B is slave
Modify the my. ini file of mysql B. Add the following configuration to the mysqld configuration item:
Server-id = 2
Master-host = 10.10.10.22
Master-user = backup # synchronize user accounts
Masters-password = 1234
Master-port = 3306
Master-connect-retry = 60 default retry interval 60 seconds
Replicate-do-db = backup tells slave to only update the backup database.
  
Restart database
Use show slave status to check the synchronization configuration.
  
Note: Because slave configuration information is set, mysql generates master.info in the Database Directory.
Therefore, if you want to modify the slave configuration, you must first delete the file. Otherwise, the modified configuration does not take effect.
  
Dual-host mutual standby mode
If you add slave settings to aand master settings to B, you can synchronize data between B and.
Add the following settings to the mysqld configuration item in the configuration file of:
Master-host = 10.10.10.53
Master-user = backup
Masters-password = 1234
Replicate-do-db = backup
Master-connect-retry = 10
  
Add the following settings to the mysqld configuration item in the configuration file of B:
Log-bin = c:/mysqllog
Binlog-do-db = backup
  
Note: *. err log file is generated when an error occurs. The synchronization thread exits. When an error is corrected, the synchronization mechanism should be executed to run slave start.
  
Restarting the AB machine enables two-way hot standby.
  
Test:
Batch insert AA (1872000) Big Data table to B
Database A can update 2500 data entries per second.

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.