In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following mainly brings you how to use amoeba (amoeba) to successfully achieve mysql database read-write separation. I hope that using amoeba (amoeba) to successfully achieve mysql database read-write separation can bring you practical use, which is also the main purpose of my editing this article. All right, don't talk too much nonsense, let's just read the following.
Preparatory work:
1. Two databases, one master and one slave, master-slave synchronization
Master: 172.22.10.237 3306; the main library is responsible for the write operation
Slave: 10.4.66.58 3306; read from the library
Amoeba: 172.22.10.237 amoeba 8066; I installed amoeba to the CVM where the main database is located. Of course, you can also install it on the third CVM.
All CVM operating systems are centos7
two。 Configure and install jdk on the CVM where amoeba resides
I installed jdk1.8.
The path is: JAVA_HOME=/usr/local/java/jdk1.8.0_131
The above must be built and configured on your own, the master and slave work normally, and add the jdk environment variable: / etc/profile
There are many ways to install amoeba, so it's not a waste of breath here. I downloaded the amoeba-mysql-3.0.5-RC-distribution installation package and decompressed it directly to use it.
Extract the directory: / usr/local/amoeba/
Obviously, there are configuration files in conf and startup programs in bin.
I just mentioned that amoeba can do more than read-write separation, but if you only use read-write separation, you only need to configure these files: conf/dbServers.xml conf/amoeba.xml and bin/launcher.
Conf/dbServers.xml:
`3306 # set the port of the mysql database to be connected by Amoeba. The default is 3306 testdb # set the default database. When connecting to amoeba, the operation table must explicitly specify the database name, that is, in the way of dbname.tablename, use dbname is not allowed to specify the default database. Because the operation will dispatch to each backend dbserver test1 # to set the account and password for amoeba to connect to the backend database CVM, you need to create the user on all backend databases and authorize the amoeba CVM to connect 111111 # maximum number of connections. Default 500500 # maximum idle connections 1 # latest idle connections # set a backend writable database, which is defined here as writedb, which can be named arbitrarily Later, we will use 172.22.10.237 # to set the ip of the backend writable dbserver # set the backend readable database 10.4.66.58 # setting to define a virtual dbserver, which is actually equivalent to a dbserver group. Here, the readable database ip is uniformly put into a group, and the name of this group is myslave 1 # selection scheduling algorithm. 1 indicates replication equilibrium, 2 indicates weight, and 3 indicates HA. Here, select 1 slave01 # myslave group member`
Conf/amoeba.xml:
8066 # set the port for amoeba listening. The default is 8066 127.0.0.1 # configure the listening interface, if not By default, IP # needs to use the account set here when the client connects to amoeba (the account password here has nothing to do with the password of amoeba connecting to the backend database CVM) root 123456 myslave # sets the default pool of amoeba The two options set here to writedb master # are logged out by default and need to be uncommented. Here, they are used to specify the two read-write pools slave01 defined earlier.
Bin/launcher:
# start the script, you need to configure the jdk environment variable; # add: JAVA_HOME=/usr/local/java/jdk1.8.0_131 on the first line after the comment
Launcher is a startup script. If you do not configure JAVA_HOME, you may get an error even if you configure the environment variable in / etc/profile: the jdk environment variable is not configured
There is also a configuration file: jvm.properties
# memory usage profile #-Xss parameter must be greater than 228 to start JVM # modify: JVM_OPTIONS= "- server-Xms1024m-Xmx1024m-Xss256k-XX:PermSize=16m-XX:MaxPermSize=96m"
Experienced operators know that anything that has anything to do with jdk is basically related to memory tuning, and amoeba is no exception.
Now you can start:
After startup, you can see port 8066 of this machine:
At this point, you only need to connect to the database through port 8066 of the local ip and the account password set in your configuration file. The written data will be sent to the master, and the read data will be read from the slave.
Test:
Close the master database and still read: execute the select view command
Or
If you close the slave database, you can still write: execute update, inster commands
For the above about the use of amoeba (amoeba) to successfully achieve mysql database read-write separation, we do not think it is very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 292
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.