amoeba mysql_mysql中间件-amoeba
中間件:一種提供在不同技術、不同的軟件之間共享資源的程序,更大化了利用了數(shù)據(jù)庫的性能,可以無限擴展(注:真實環(huán)境中并非如此)
數(shù)據(jù)庫的中間件:
mysql proxy (官方版本)性能低,需要lua 腳本
atlas 性能低,響應時間長
amoeba 陳思儒研發(fā)
一、 先搭建一個主從關系的服務器
在主、從服務器上安裝mysql mysql-server
1. 開啟二進制日志
[root@localhost ~]# vim /etc/my.cnf
...
log-bin=mysql-bin
server-id = 132...
[root@localhost ~]# vim /etc/my.cnf
...l
og-bin=mysql-bin
server-id = 134...
2. 在主服務器上授權,從服務器上保存授權信息,并開啟從服務線程
mysql> grant replication slave on *.* to root@'192.168.80.134' identified by '123456';
mysql> show master status;
mysql>change master to-> master_user='root',-> master_password='123456',-> master_host='192.168.80.132',-> master_log_file='mysql-bin.000008',-> master_log_pos=260;
Query OK,0 rows affected (0.35sec)
mysql>start slave;
Query OK,0 rows affected (0.01sec)
mysql> show slave status\G;
二、配置讀寫分離
1. 安裝 gcc 環(huán)境
[root@localhost ~]# yum -y install gcc*
2. 安裝jdk
[root@localhost ~]# tar -zxvf jdk-8u231-linux-x64.tar.gz /amoeba/[root@localhost/amoeba]# ln -s jdk1.8.0_231/jdk
[root@localhost/amoeba]# vim /etc/profile
JAVA_HOME=/amoeba/jdk
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
[root@localhost/amoeba]# source /etc/profile
3. 安裝amoeba
[root@localhost ~]# wget https://jaist.dl.sourceforge.net/project/amoeba/Amoeba%20for%20mysql/3.x/amoeba-mysql-3.0.5-RC-distribution.zip
[root@localhost ~]# mkdir /amoeba
[root@localhost~]# unzip amoeba-mysql-3.0.5-RC-distribution.zip -d /amoeba
4. 配置amoeba
amoeba 的配置文件位于安裝目錄下的conf目錄中,實現(xiàn)讀寫分離功能,只需修改兩個配置文件,dbServers.xml和amoeba.xml。
[root@localhost /amoeba/amoeba-mysql-3.0.5-RC/conf]# cat dbServers.xml
${defaultManager}
64
128
3306 #數(shù)據(jù)庫端口
test #指定連接的數(shù)據(jù)庫
root #登錄使用的用戶名
123456 #登錄使用的密碼
500 #最大連接數(shù)
500 #最大空閑連接數(shù)
1 #最下空閑連接數(shù)
600000
600000
true
true
true
#改名字可任意命名,后續(xù)有用
192.168.80.132 #數(shù)據(jù)庫ip
192.168.80.134 #數(shù)據(jù)庫ip
#定義一個dbserver 組名
1 #選擇調度算法
server1 #write組成員
1
server1,server2
[root@localhost /amoeba/amoeba-mysql-3.0.5-RC/conf]# catamoeba.xml<?xml version="1.0" encoding="gbk"?>
8066 #amoeba監(jiān)聽端口,默認8066
192.168.80.133 #amoeba安裝地址
128
64
root #設置客戶端連接amoeba所需的用戶名和密碼
123456
${amoeba.home}/conf/access_list.conf
128
500
utf8
60
com.meidusa.toolkit.net.AuthingableConnectionManager
${amoeba.home}/conf/dbServers.xml
${amoeba.home}/conf/rule.xml
${amoeba.home}/conf/ruleFunctionMap.xml
${amoeba.home}/conf/functionMap.xml
1500
write #設置amoeba默認池
write #設置amoeba 寫池,默認注釋
read #設置amoeba讀池,默認注釋
true
5. 在主從服務器上授權
mysql> grant all on *.* to 'root'@'192.168.80.133' identified by '123456';Query OK, 0 rows affected (0.00 sec)
6. 修改jvm.properties
[root@localhost /amoeba/amoeba-mysql-3.0.5-RC]# vim jvm.properties
JVM_OPTIONS="-server -Xms1024m -Xmx1024m -Xss256k -XX:PermSize=16m -XX:MaxPermSize=96m"
7. 啟動
[root@localhost /amoeba/amoeba-mysql-3.0.5-RC]# nohup bash +x /amoeba/amoeba-mysql-3.0.5-RC/bin/launcher &
[root@localhost /amoeba/amoeba-mysql-3.0.5-RC]# tail -f nohup.out2019-12-24 18:34:02,897 INFO context.MysqlRuntimeContext - Amoeba for Mysql current versoin=5.1.45-mysql-amoeba-proxy-3.0.4-BETA
log4j:WARN ip access config load completed fromfile:/amoeba/amoeba-mysql-3.0.5-RC/conf/access_list.conf2019-12-24 18:34:03,331 INFO net.ServerableConnectionManager - Server listening on /192.168.80.133:8066.
Java HotSpot(TM)64-Bit Server VM warning: ignoring option PermSize=16m; support was removed in 8.0Java HotSpot(TM)64-Bit Server VM warning: ignoring option MaxPermSize=96m; support was removed in 8.0
2019-12-24 18:59:15 [INFO] Project Name=Amoeba-MySQL, PID=7607, starting...
log4j:WARN log4j config load completed fromfile:/amoeba/amoeba-mysql-3.0.5-RC/conf/log4j.xml2019-12-24 18:59:16,333 INFO context.MysqlRuntimeContext - Amoeba for Mysql current versoin=5.1.45-mysql-amoeba-proxy-3.0.4-BETA
log4j:WARN ip access config load completed fromfile:/amoeba/amoeba-mysql-3.0.5-RC/conf/access_list.conf2019-12-24 18:59:16,669 INFO net.ServerableConnectionManager - Server listening on /192.168.80.133:8066.
[root@localhost ~]# netstat -antp |grep 8066tcp60 0 192.168.80.133:8066 :::* LISTEN 7607/java
[root@localhost ~]# firewall-cmd --zone=public --add-port=8066/tcp
[root@localhost~]# firewall-cmd --zone=public --add-port=8066/tcp --permanent
8. 測試
[root@localhost ~]# mysql -uroot -p123456 -P8066 -h192.168.80.133Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 151281375Server version:5.1.45-mysql-amoeba-proxy-3.0.4-BETA Source distribution
Copyright (c)2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type'help;' or '\h' for help. Type '\c' to clearthe current input statement.
mysql>use test;
Database changed
mysql> select *from ceshi2;+--------+
| name |
+--------+
| master |
| amoeba |
+--------+
2 rows in set (0.01sec)
mysql> select *from ceshi2;+--------+
| name |
+--------+
| master |
| slave |
| amoeba |
+--------+
3 rows in set (0.01sec)
mysql> select *from ceshi2;+--------+
| name |
+--------+
| master |
| amoeba |
+--------+
2 rows in set (0.01sec)
mysql> select *from ceshi2;+--------+
| name |
+--------+
| master |
| slave |
| amoeba |
+--------+
3 rows in set (0.01sec)
mysql> select *from ceshi2;+--------+
| name |
+--------+
| master |
| amoeba |
+--------+
2 rows in set (0.01sec)
mysql> select *from ceshi2;+--------+
| name |
+--------+
| master |
| slave |
| amoeba |
+--------+
3 rows in set (0.02 sec)
三、amoeba配置文件
主配置文件?$AMOEBA_HOME/conf/amoeba.xml,用來配置Amoeba服務的基本參數(shù),如Amoeba主機地址、端口、認證方式、用于連接的用戶名、密碼、線程數(shù)、超時時間、其他配置文件的位置等。
數(shù)據(jù)庫服務配置文件?$AMOEBA_HOME/conf/dbServers.xml,用來存儲和配置Amoeba所代理的數(shù)據(jù)庫服務器的信息,如:主機IP、端口、用戶名、密碼等。
切分規(guī)則配置文件 $AMOEBA_HOME/conf/rule.xml,用來配置切分規(guī)則。
數(shù)據(jù)庫函數(shù)配置文件 $AMOEBA_HOME/conf/functionMap.xml,用來配置數(shù)據(jù)庫函數(shù)的處理方法,Amoeba將使用該配置文件中的方法解析數(shù)據(jù)庫函數(shù)。
切分規(guī)則函數(shù)配置文件 $AMOEBA_HOME/conf/ruleFunctionMap.xml,用來配置切分規(guī)則中使用的用戶自定義函數(shù)的處理方法。
訪問規(guī)則配置文件 $AMOEBA_HOME/conf/access_list.conf,用來授權或禁止某些服務器IP訪問Amoeba。
日志規(guī)格配置文件 $AMOEBA_HOME/conf/log4j.xml,用來配置Amoeba輸出日志的級別和方式。
總結
以上是生活随笔為你收集整理的amoeba mysql_mysql中间件-amoeba的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 迷之Konigsberg七桥问题
- 下一篇: C网跟G网是什么意思?