Two machines, 192.168.162.128 (master) 192.168.162.130 (from)
Configuring the master configuration file
Vi/etc/my.cnf
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/8F/D0/wKiom1jsyRqCIwWwAAC8YJawgOg672.png-wh_500x0-wm_ 3-wmp_4-s_666601601.png "title=" 1.png "alt=" Wkiom1jsyrqciwwwaac8yjawgog672.png-wh_50 "/>
Create a replication user and authorize the slave server
grant replication Slave on * * to 'rpl' @ ' 192.168.162.130 ' identified by ' 123456 ';
Restart the primary server Mysql/etc/init.d/mysqld restart
-
View master information: Enter MySQL show master status \g;
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8F/CE/wKioL1jsy7WQyTeJAAA_ N7oczoc906.png-wh_500x0-wm_3-wmp_4-s_3047961795.png "title=" 1.png "alt=" wkiol1jsy7wqytejaaa_n7oczoc906.png-wh_50 "/>
Modify the From library configuration file
Vi/etc/my.cnf
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8F/D0/wKiom1jsyr3TeZCPAABWe1BNPbI928.png-wh_500x0-wm_ 3-wmp_4-s_756287969.png "title=" 1.png "alt=" Wkiom1jsyr3tezcpaabwe1bnpbi928.png-wh_50 "/>
Restart MySQL from server, enter MySQL
-
Specify the primary server IP, etc.
change Master to master_host= ' 192.168.162.128 ', master_user= ' RPL ', master_password= ' 123456 ', master_log_file= ' mysql-bin.000001 ', master_log_pos=647;
Start slave: Startslave;
View slave status: Show slave status \g;
Error last_io_error:fatal error:the slave I/O thread stops because master and slave have equal MySQL server UUIDs; These uuids must be different for replication
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8F/CF/wKioL1jszITztAIvAACPCC4KGGY151.png-wh_500x0-wm_ 3-wmp_4-s_3169590262.png "title=" 1.png "alt=" Wkiol1jszitztaivaacpcc4kggy151.png-wh_50 "/>
It means that both the Lord and the slave must have different uuid, and we go to the next master's UUID separately.
Master: server-uuid=4e6c5a78-1e9a-11e7-8c65-000c29426312
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8F/D0/wKiom1jszQDhD3ZMAACB80HbAQM050.png-wh_500x0-wm_ 3-wmp_4-s_1275673249.png "title=" 1.png "alt=" Wkiom1jszqdhd3zmaacb80hbaqm050.png-wh_50 "/>
View from library UUID from library uuid:server-uuid=4e6c5a78-1e9a-11e7-8c65-000c29426312
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8F/CF/wKioL1jszVbBKhnwAABdgcFp-SQ600.png-wh_500x0-wm_ 3-wmp_4-s_1416409111.png "title=" 1.png "alt=" Wkiol1jszvbbkhnwaabdgcfp-sq600.png-wh_50 "/>
Can be seen is true, the reason is that I first installed a virtual machine and loaded MySQL, after the copy again, as from the server, so that caused the UUID is the same.
The next step is to solve this UUID problem, which will be backed up from the auto.cnf on the library. Then reboot from the library. And look at the UUID from the library.
[Auto]
server-uuid=2e9c834a-1eb2-11e7-864b-000c2928472e
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/8F/CF/wKioL1jszgSCYwyPAAAPrLrnlso141.png-wh_500x0-wm_ 3-wmp_4-s_2479968937.png "title=" 1.png "alt=" Wkiol1jszgscywypaaaprlrnlso141.png-wh_50 "/>
View from library status again
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8F/D0/wKiom1jszkOCkwgBAACI2rriH40927.png-wh_500x0-wm_ 3-wmp_4-s_1192738443.png "title=" 1.png "alt=" Wkiom1jszkockwgbaaci2rrih40927.png-wh_50 "/>
From the library state is fine.
11. Test master and slave is normal
Create a test library on the main library, test:create database test;
To create a test table:
CREATE TABLE Test.test (
ID int,
Username varchar (10)
) engine= ' InnoDB '
12. View from library:
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8F/D0/wKiom1jszt-TnxS5AAAbyuhAsiA911.png-wh_500x0-wm_ 3-wmp_4-s_1246727120.png "title=" 1.png "alt=" Wkiom1jszt-tnxs5aaabyuhasia911.png-wh_50 "/>
Normal, indicating the success of the master-slave construction
MySQL Master-slave replication