I. Amoeba
It can realize load balancing Read / write separation , high availability, etc.
1.1 installation of JDK
(1) Upload JDK
(2) Unzip
[root@localhost java]# tar -xvf jdk-8u51-linux-x64.tar.gz
(3) Modify system environment variables
[root@localhost java]# vim /etc/profile
(4) Load JDK configuration
[root@localhost java]# source /etc/profile
(5) Monitoring JDK
1.2 installing Amoeba
(1) Upload Amoeba compressed package
(2) Unzip files
1.3 use FileZilla to configure Amoeba
(1) Connect
(2) Linux system directory and local directory
(3) configure the dbserver.xml file under the conf folder
<?xml version="1.0" encoding="gbk"?> <!DOCTYPE amoeba:dbServers SYSTEM "dbserver.dtd"> <amoeba:dbServers xmlns:amoeba="http://amoeba.meidusa.com/"> <!-- Each dbServer needs to be configured into a Pool, If you need to configure multiple dbServer with load balancing that can be simplified by the following configuration: add attribute with name virtual = "true" in dbServer, but the configuration does not allow the element with name factoryConfig such as 'multiPool' dbServer --> <dbServer name="abstractServer" abstractive="true"> <factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory"> <property name="connectionManager">${defaultManager}</property> <property name="sendBufferSize">64</property> <property name="receiveBufferSize">128</property> <!-- mysql port --> <property name="port">3306</property> <!-- mysql schema --> <property name="schema">test</property> <!-- mysql user Define public user name and password --> <property name="user">root</property> <property name="password">root</property> </factoryConfig> <poolConfig class="com.meidusa.toolkit.common.poolable.PoolableObjectPool"> <property name="maxActive">500</property> <property name="maxIdle">500</property> <property name="minIdle">1</property> <property name="minEvictableIdleTimeMillis">600000</property> <property name="timeBetweenEvictionRunsMillis">600000</property> <property name="testOnBorrow">true</property> <property name="testOnReturn">true</property> <property name="testWhileIdle">true</property> </poolConfig> </dbServer> <dbServer name="master" parent="abstractServer"> <factoryConfig> <!-- mysql ip --> <property name="ipAddress">172.88.1.61</property> </factoryConfig> </dbServer> <dbServer name="slave01" parent="abstractServer"> <factoryConfig> <!-- mysql ip --> <property name="ipAddress">172.88.1.62</property> </factoryConfig> </dbServer> <dbServer name="multiPool" virtual="true"> <poolConfig class="com.meidusa.amoeba.server.MultipleServerPool"> <!-- Load balancing strategy: 1=ROUNDROBIN polling , 2=WEIGHTBASED weight(Send requests to servers with small load) , 3=HA--> <property name="loadbalance">1</property> <!-- Separated by commas,such as: server1,server2,server1 --> <property name="poolNames">slave01,master,slave01</property> </poolConfig> </dbServer> </amoeba:dbServers>
(4) configure the amoeba.xml file under the conf folder
<?xml version="1.0" encoding="gbk"?> <!DOCTYPE amoeba:configuration SYSTEM "amoeba.dtd"> <amoeba:configuration xmlns:amoeba="http://amoeba.meidusa.com/"> <proxy> <!-- service class must implements com.meidusa.amoeba.service.Service --> <service name="Amoeba for Mysql" class="com.meidusa.amoeba.mysql.server.MySQLService"> <!-- port --> <property name="port">8066</property> <!-- bind ipAddress --> <!-- <property name="ipAddress">127.0.0.1</property> --> <property name="connectionFactory"> <bean class="com.meidusa.amoeba.mysql.net.MysqlClientConnectionFactory"> <property name="sendBufferSize">128</property> <property name="receiveBufferSize">64</property> </bean> </property> <property name="authenticateProvider"> <bean class="com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator"> <property name="user">root</property> <property name="password">root</property> <property name="filter"> <bean class="com.meidusa.toolkit.net.authenticate.server.IPAccessController"> <property name="ipFile">${amoeba.home}/conf/access_list.conf</property> </bean> </property> </bean> </property> </service> <runtime class="com.meidusa.amoeba.mysql.context.MysqlRuntimeContext"> <!-- proxy server client process thread size --> <property name="executeThreadSize">128</property> <!-- per connection cache prepared statement size --> <property name="statementCacheSize">500</property> <!-- query timeout( default: 60 second , TimeUnit:second) --> <property name="queryTimeout">60</property> </runtime> </proxy> <!-- Each ConnectionManager will start as thread manager responsible for the Connection IO read , Death Detection --> <connectionManagerList> <connectionManager name="defaultManager" class="com.meidusa.toolkit.net.MultiConnectionManagerWrapper"> <property name="subManagerClassName">com.meidusa.toolkit.net.AuthingableConnectionManager</property> </connectionManager> </connectionManagerList> <!-- default using file loader --> <dbServerLoader class="com.meidusa.amoeba.context.DBServerConfigFileLoader"> <property name="configFile">${amoeba.home}/conf/dbServers.xml</property> </dbServerLoader> <queryRouter class="com.meidusa.amoeba.mysql.parser.MysqlQueryRouter"> <property name="ruleLoader"> <bean class="com.meidusa.amoeba.route.TableRuleFileLoader"> <property name="ruleFile">${amoeba.home}/conf/rule.xml</property> <property name="functionFile">${amoeba.home}/conf/ruleFunctionMap.xml</property> </bean> </property> <property name="sqlFunctionFile">${amoeba.home}/conf/functionMap.xml</property> <property name="LRUMapSize">1500</property> <property name="defaultPool">multiPool</property> <!-- Pool to write database --> <property name="writePool">master</property> <!-- Pool to read database --> <property name="readPool">multiPool</property> <property name="needParse">true</property> </queryRouter> </amoeba:configuration>
(6) configure the jvm.properties configuration file under the Amoeba folder
# app name APP_NAME=Amoeba-MySQL # app version number APP_VERSION=3.0.0-beta # Log output path, the referential parameter ${project.output} in log4j APP_OUTPUT_PATH=$PROJECT_HOME/logs # PID file storage path of the application, which is stored in ${project.home}/${APP_NAME}.pid by default #APP_PID_PATH=/temp/logs/$APP_NAME # Console output to log file APP_CONSOLE_LOG=$APP_OUTPUT_PATH/console.log # Program related configuration parameters #APP_OPTIONS="-DmyParam=value1 -DmyParam2=value2" # startup parameter #APP_ARGS="args0 " # JVM related parameters, including memory configuration and garbage collection policy # Xms256m: initialize the memory size when the program starts # Xmx1024m: maximum memory setting # Xss196k: the size of thread space in jvm JVM_OPTIONS="-server -Xms256m -Xmx1024m -Xss256k -XX:PermSize=16m -XX:MaxPermSize=96m" # The list of signals ignored by the application program is separated by commas, and the signal of program shutdown is 15 (kill-15 PID can be used to make the shutdown of program civilization, please do not fill in 15 here) IGNORE_SIGNALS=1,2
(7) Turn off firewall
[root@localhost ~]# service iptables stop
(8) Launch Amoeba