Amoeba: about the read-write separation of mysql
Today, read-write separation has been done with amoeba. The following steps are summarized:
Three linux:
1. 192.168.1.213 is used as an amoeba server
2. 192.168.1.184 is used in mysql database
3. 192.168.1.185 is used in mysql database
# service iptables stop
# setenforce 0
1. Java running environment is required to run amoeba, so install jdk environment first.
Rpm-ivh jdk-7u45-linux-i586.rpm
Vim / etc/profile tomcat configuration file
Add:
Export JAVA_HOME=/usr/java/jdk1.8.0_20
Export JAVA_BIN=/usr/java/jdk1.8.0_20/bin
Export PATH=$PATH:$JAVA_HOME/bin
Export CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
Source / etc/profile makes the modified file effective immediately
Java-version display version
At this point, the display of the version of java shows that it is a success.
2. Configure amoeba
Create a folder for amoeba
Mkdir / root/amoeba
Tar zxvf amoeba-mysql-binary-2.2.0.tar.gz-C / root/amoeba
Cd / root/amoeba
1. Modify dbServer.xml first
Vim / root/amoeba/conf/dbServer.xml / / modify the file
2. Next, we will modify amoeba.xml.
Vim / root/amoeba/conf/amoeba.xml
_
# # dividing Line #
The operation of ok and amoeba comes to this stage first.
Let's go to the database of .1.184.
Service mysqld start
Mysql-uroot-p
Mysql > grant all on *. * to admin@'%' identified by '123456 create a remote user and authorize it
Mysql > flush privileges
Mysql > create database lxl; / / create the database lxl, which was used in the amoeba configuration file just now
Mysql > create table lxl.t_test (id int (3)); / / create tables in lxl database
Mysql > insert into lxl.t_test values (1); / / insert 3 records
Mysql > insert into lxl.t_test values (2)
Mysql > insert into lxl.t_test values (3)
# # dividing Line #
The database preparation on .1.184 is complete. Let's go to. 1.185 to get ready.
Service mysqld start
Mysql-uroot-p
Mysql > grant all on *. * to admin@'%' identified by '123456 create a remote user and authorize it
Mysql > flush privileges
Mysql > create database lxl; / / create the database lxl, which was used in the amoeba configuration file just now
Mysql > create table lxl.t_test (id int (3)); / / create tables in lxl database
Mysql > insert into lxl.t_test values (4); / / insert 2 records
Mysql > insert into lxl.t_test values (5)
# # dividing Line # #
Switch to the amoeba server and start amoeba
Cd / root/amoeba/bin
. / amoeba start&
# # dividing Line # #
Use Telnet to amoeba
Mysql-uamoeba-p1234-P8066-h 192.168.1.213 / / Log in to the proxy side using the username and password of the amoeba agent
You can insert data now, because the data from the previous two databases are different, and you can clearly see the difference if you insert one.
The separation of reading and writing is over. I hope it will be helpful to you!
Ps: when I was doing the experiment today, I did a master replication for two databases first. As a result, although the amoeba configuration was successful, the two databases were inserted into the database and synchronized in real time, entangling for a long time.