Mysql Master-slave replication configuration
First, the test environment
1. Software Environment
A) operating system:
CentOS 6.5 X64
b) mysql-server:
Mysql-server-5.1.73-3.el6_5.x86_64
2. network Environment
Each host has two network card, one of the network card and make a network card directly connected;
A) mater_db:
I.eth0:
192.168.99.11/24
Ii. Eth1:
10.1.1.11/24
b) slave_db:
I.eth0:
192.168.99.12/24
Ii. Eth1:
10.1.1.12/24
3.
Ii. Related Explanations
Third, the experimental process
A) master_db
I. Install mysql-server (slightly)
Ii. Configuration Mysql-server
1. Modify The root user password under Mysql;
2. Create a database for testing
3. Modify the configuration file
A) vim/etc/my.cnf
Add the following paragraph:
[Mysqld]
Server-id=1 # specifying service ID
Log-bin=log # turn on log
Binlog_do_db=luoyangbo # Select the database you want to synchronize
Binlog_ignore_db=test,mysql # Select a database that does not need to be synchronized
b) Restart the database
b) slave_db
1. Modify The root user password under Mysql;
2. Create a database of tests with the same name as the database that needs to be synchronized on the Materdb
3. Modify the configuration file
A) vim/etc/my.cnf
Add the following paragraph:
[Mysqld]
server-id=2 # Server ID
master-host=10.1.1.11 # Primary server address
MASTER-USER=SLAVE01 # Mysql user name connecting to the primary server master-password=7490283 # Mysql password to connect to the master server
master-port=3306 # Port connecting to the primary server
MASTER-CONNECT-RETRY=20 # If the connection fails, the retry time
Replicate-do-db=luoyangbo # Synchronized database name
Replicate-ignore-db=mysql,test # out -of-sync database name
b) Restart the database
4. Test Mysql master-slave configuration
A) Master DB
I. Create a table and insert row data;
Create tables Test (ID int,name char (10));
Insert into test values (1,hello);
b) Slave DB
I. retrieving test tables for synchronization
Show tables;
SELECT * FROMTEST;
This article is from the "Luo Old Three Road" blog, please be sure to keep this source http://robert283.blog.51cto.com/528368/1408662