Table of contents
2. Read and write separation operation process
1. Check the Java version in the system (because only Java 1.4-1.6 is supported)
2. Configure environment variables
Fourth, change the configuration file
5. View the status of the listening port
I. Overview
The read data is provided from the service, and the write is written to the master, and only the written things are accepted on the master.
One client, one amoeba proxy, one master master node, two slave nodes
Load balancing is required when reading, the first query 1 and the second query 2.
2. Read and write separation operation process
1. Check the Java version in the system (because only Java 1.4-1.6 is supported)
The current version of Java is 1.8
Install
successfully installed
Put the path under the current path
Move the file to this path, check the Java version, and check the current Java location
kill him and check
2. Configure environment variables
1. Export is to set a global variable jdk1.6 in usr/local, and Java is in this place
2. This command is to set the storage path of the command
Put the path of Java jdk into echo ¥PATH
The system will rename the "jdk1.6.0_14" folder to "jdk1.6"
Write the file to vim /etc/profile
write to the end
Do not refresh at this step
3. Install Amoeba
decompress
Put in usr/local/amoeba
After the decompression is complete, no configuration is required
source /etc/profile refresh
java -version Check if the version is back to 1.6
So far the Java version and amoeba have been successfully configured
Check
Centralized storage command optimization, this operation is directly written (50 points for the video on the 28th)
Configure the permissions granted to 755
Enter the first configuration file of vim /usr/local/amoeba/conf/amoeba.xml
Fourth, change the configuration file
Change user password master and slaves a node
Save and exit after modification
Change the dbServer.xml configuration file
Enter vim /usr/local/amoeba/conf/dbServers.xml to enter the change
Change to fill in the ip of the main service
Change fill in the ip of the slave service
Save and exit after the configuration is complete
Back to the three database configurations
输入 grant all on *.* to 'test'@'192.168.100.%' identified by '1234.Com';
to refresh
5. View the status of the listening port
So far, it will be automatically synchronized to each server, and then turn off the Slave function on each server, and insert statement tests respectively.
6. Verification
The master library creates a hy database (two slave libraries can be successfully queried)
Enter hy to create a table with content mpy
Both slaves can successfully read
Stop one of the services, and the main creation can be successfully read on another server.
Create and write a table content on the fifth client, which can be successfully queried in the main library (if the slave library is closed, it will not be synchronized, if the slave library is not closed, it will be synchronized), this is reading and writing separate! !
3. Load balancing
(In order to balance the load of the server), the read content will be alternated, the first access to the first slave library, and the second access to the second slave library.
first query
second query
third query
fourth query
If written, the server always exists when querying.
This is load balancing