MySQL Version: 5.6
ip:192.168.134.178 of the primary server
ip:192.168.134.180 from the server
Now the master-slave machine installed MySQL version 5.6, the installation process is omitted;
1 Modify the MySQL configuration file for the master server:
#vi/etc/my.cnf
[Mysqld]
Log-bin=mysql-bin//[must] enable binary logging
server-id=222//[must be] server unique ID, default is 1, usually take IP last paragraph
2 modifying from server slave:
#vi/etc/my.cnf
[Mysqld]
Log-bin=mysql-bin//[not required] enable binary logging
server-id=226//[must be] server unique ID, default is 1, usually take IP last paragraph
READ_ONLY = 1//read-only mode
3 User replication user to create MySQL on master
CREATE USER ' copy ' @ ' 192.168.134.180 ' identified by ' password ';
GRANT REPLICATION SLAVE on * * to ' copy ' @ ' 192.168.134.180 ' identified by ' copy ';
To view the primary server status:
SHOW MASTER STATUS;
4 to operate from the server:
Start MySQL:
Service mysqld Start
Execute in MySQL:
Change MASTER to master_host= ' 192.168.134.178 ', master_user= ' copy ', master_password= ' copy ', Master_port=3306,master_ Log_file= ' mysql-bin.000001 ', master_log_pos=506,master_connect_retry=10;
Start the replication process from the server:
Execute in MySQL:
START SLAVE
View from server Status:
Execute in MySQL:
SHOW SLAVE Status\g;
5 Viewing slave Server status
View
Tail-10/usr/local/mysql/data/slave.err
See the following message stating that the replication process started successfully
39076 [Note] Slave I/O thread:connected to master ' [email protected]:3306 ', replication started in log ' mysql-bin.000001 ' At position 506
6 Testing
Create a table in the master Server Test library Test1
CREATE table Test1 (name varchar (10));
INSERT into test1 values (' Qwer ')
Commit
To see if the synchronization was successful on the server
SELECT * from Test.test1;
Configuring Master-slave replication for MySQL