Experimental topology:
Address assignment:
Client 192.168.1.1
Amoeba 192.168.1.2
Mysql-master 192.168.1.3
Mysql-slave1 192.168.1.4
Mysql-slave2 192.168.1.5
1, Configuration Time synchronization
1) on master, use Yum to install NTP and modify its profile/etc/ntp.conf to start the service. Open the iptables exception for UDP port 123.
2) perform/usr/sbin/ntpdate 192.168.1.3 on both slave to synchronize time synchronization with master.
2, master-slave replication
Note: The iptables exception for TCP port 3306 is required on all three MySQL databases.
1) configuration of master server master
Configuration of the/ETC/MY.CNF
Restart MYSQLD Service
Execute mysql-u root-p log in to the MySQL database and authorize the server
2) configuration from server slave (two from server configuration)
Configuration of the/ETC/MY.CNF
Restart Services (Service mysqld restart), log in to MySQL configuration startup slave
Show slave status\g to see if the master-slave copy is running properly. Master-slave replication relies on both the SQL process and the IO process, which means "yes" for normal operation.
3. Read/write separation
MySQL read-write separation can be implemented in two ways, based on the internal implementation of program code and middleware-based implementation, this time using amoeba is one of the methods based on middleware implementation.
1) configuration of Amoeba middleware server
Installing the JDK
Modify/etc/profile
The execution source/etc/profile takes effect immediately, java-version to see if the installation is complete.
Installing Amoeba
Modify the Amoeba configuration file/usr/local/amoeba/conf/amoeba.xml
Modify the Amoeba configuration file/usr/local/amoeba/conf/dbservers.xml
Start Amoeba, view ports
So the amoeba middleware needs to turn on TCP port 8066iptables exceptions.
2) Three MySQL need to give Aomeba authorization (three same operation)
4, the Client connection amoeba. (normal should add-p8066 after the command, I later changed the port to 3306, you do not have to add the port number in the back)
Note: Enter the password for ' amoeba ' at the horizontal line ' 123456b ', while the password for ' Chen ' in the command is ' 123456c '.
In summary, the final result is:
1) on the slave log on to the local MySQL write data, will not sync to master, and write data on master, you can sync to slave.
2) Turn off the master-slave copy, write the data on the client, you can see the data on Master, slave (because the client writes the data directly to master).
3) after the master-slave replication is turned off, log on to the local MySQL write data on master, the client cannot read the data, but the client can read the local write data on the slave (because the client read data is read from slave).
MySQL master-slave replication and read-write separation