日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

amoeba mysql_mysql中间件-amoeba

發(fā)布時(shí)間:2023/12/18 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 amoeba mysql_mysql中间件-amoeba 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

中間件:一種提供在不同技術(shù)、不同的軟件之間共享資源的程序,更大化了利用了數(shù)據(jù)庫(kù)的性能,可以無(wú)限擴(kuò)展(注:真實(shí)環(huán)境中并非如此)

數(shù)據(jù)庫(kù)的中間件:

mysql proxy (官方版本)性能低,需要lua 腳本

atlas 性能低,響應(yīng)時(shí)間長(zhǎng)

amoeba 陳思儒研發(fā)

一、 先搭建一個(gè)主從關(guān)系的服務(wù)器

在主、從服務(wù)器上安裝mysql mysql-server

1. 開(kāi)啟二進(jìn)制日志

[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. 在主服務(wù)器上授權(quán),從服務(wù)器上保存授權(quán)信息,并開(kāi)啟從服務(wù)線(xiàn)程

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;

二、配置讀寫(xiě)分離

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目錄中,實(shí)現(xiàn)讀寫(xiě)分離功能,只需修改兩個(gè)配置文件,dbServers.xml和amoeba.xml。

[root@localhost /amoeba/amoeba-mysql-3.0.5-RC/conf]# cat dbServers.xml

${defaultManager}

64

128

3306  #數(shù)據(jù)庫(kù)端口

test  #指定連接的數(shù)據(jù)庫(kù)

root  #登錄使用的用戶(hù)名

123456  #登錄使用的密碼

500           #最大連接數(shù)

500          #最大空閑連接數(shù)

1           #最下空閑連接數(shù)

600000

600000

true

true

true

    #改名字可任意命名,后續(xù)有用

192.168.80.132  #數(shù)據(jù)庫(kù)ip

192.168.80.134  #數(shù)據(jù)庫(kù)ip

    #定義一個(gè)dbserver 組名

1    #選擇調(diào)度算法

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)聽(tīng)端口,默認(rèn)8066

192.168.80.133  #amoeba安裝地址

128

64

root  #設(shè)置客戶(hù)端連接amoeba所需的用戶(hù)名和密碼

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  #設(shè)置amoeba默認(rèn)池

write  #設(shè)置amoeba 寫(xiě)池,默認(rèn)注釋

read   #設(shè)置amoeba讀池,默認(rèn)注釋

true

5. 在主從服務(wù)器上授權(quán)

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. 啟動(dòng)

[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. 測(cè)試

[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,用來(lái)配置Amoeba服務(wù)的基本參數(shù),如Amoeba主機(jī)地址、端口、認(rèn)證方式、用于連接的用戶(hù)名、密碼、線(xiàn)程數(shù)、超時(shí)時(shí)間、其他配置文件的位置等。

數(shù)據(jù)庫(kù)服務(wù)配置文件?$AMOEBA_HOME/conf/dbServers.xml,用來(lái)存儲(chǔ)和配置Amoeba所代理的數(shù)據(jù)庫(kù)服務(wù)器的信息,如:主機(jī)IP、端口、用戶(hù)名、密碼等。

切分規(guī)則配置文件 $AMOEBA_HOME/conf/rule.xml,用來(lái)配置切分規(guī)則。

數(shù)據(jù)庫(kù)函數(shù)配置文件 $AMOEBA_HOME/conf/functionMap.xml,用來(lái)配置數(shù)據(jù)庫(kù)函數(shù)的處理方法,Amoeba將使用該配置文件中的方法解析數(shù)據(jù)庫(kù)函數(shù)。

切分規(guī)則函數(shù)配置文件 $AMOEBA_HOME/conf/ruleFunctionMap.xml,用來(lái)配置切分規(guī)則中使用的用戶(hù)自定義函數(shù)的處理方法。

訪(fǎng)問(wèn)規(guī)則配置文件 $AMOEBA_HOME/conf/access_list.conf,用來(lái)授權(quán)或禁止某些服務(wù)器IP訪(fǎng)問(wèn)Amoeba。

日志規(guī)格配置文件 $AMOEBA_HOME/conf/log4j.xml,用來(lái)配置Amoeba輸出日志的級(jí)別和方式。

總結(jié)

以上是生活随笔為你收集整理的amoeba mysql_mysql中间件-amoeba的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。