CentOS下基于Amoeba实现MySQL读写分离(2)

3、创建一个测试书库库查看MySQLmaster进程,显示已经发送二进制日志给salve

mysql> create database reliacatedb; mysql> show processlist\G *************************** 1. row *************************** Id: 1 User: root Host: localhost db: NULL Command: Query Time: 0 State: init Info: show processlist *************************** 2. row *************************** Id: 3 User: dbsync Host: slave:33608 db: NULL Command: Binlog Dump GTID Time: 259 State: Master has sent all binlog to slave; waiting for binlog to be updated Info: NULL

二、amoeba节点安装配置
1、配置Java环境

# yum install -y java-1.6.0-openjdk # vim /etc/profile.d/jdk.sh export JAVA_HOME=/usr/ export PATH=$PATH:$JAVA_HOME/bin # source /etc/profile.d/jdk.sh

2、安装ameoba
https://sourceforge.net/projects/amoeba/files/Amoeba%20for%20mysql/

# wget https://sourceforge.net/projects/amoeba/files/Amoeba%20for%20mysql/2.2.x/amoeba-mysql-binary-2.2.0.tar.gz/download # mkdir !$ mkdir /usr/local/amoeba-2.2.0 # tar xvf amoeba-mysql-binary-2.2.0.tar.gz -C /usr/local/amoeba-2.2.0

3、修改ameoba配置文件
amoeba前端访问配置

# vim /usr/local/amoeba-2.2.0/conf/amoeba.xml <property name="port">3306</property> # 将默认端口8066改为3306,便于实现前端程序连接数据库的透明性 <property name="ipAddress">0.0.0.0</property> # 有多块网卡时可按此设置,表示绑定任意地址,即amoeba对外访问的IP地址 <property name="user">root</property> # 客户端连接amoeba的代理使用的用户 <property name="password">mypass</property> # 客户端连接amoeba的代理使用的密码 <property name="defaultPool">master</property> # 默认访问节点 <property name="writePool">master</property> <property name="readPool">slave</property> # 读写分离配置,读池和写池和dbServer.xml中配置的节点相关

4、amoeba后端代理配置

# vim /usr/local/amoeba-2.2.0/conf/dbServers.xml <property name="user">root</property> # 默认连接mysql server的用户 <property name="password">pass</property> # 默认连接mysql server的密码,以上两项如不在下文中的dbserver中单独定义,则直接继承此处定义 <dbServer name="master" parent="abstractServer"> <factoryConfig> <property name="ipAddress">192.168.0.172</property> </factoryConfig> </dbServer> <dbServer name="slave" parent="abstractServer"> <factoryConfig> <property name="ipAddress">192.168.0.173</property> </factoryConfig> </dbServer> <dbServer name="multiPool" virtual="true"> #服务组,轮询策略 <poolConfig class="com.meidusa.amoeba.server.MultipleServerPool"> <!-- Load balancing strategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA--> <property name="loadbalance">1</property> <!-- Separated by commas,such as: server1,server2,server1 --> <property name="poolNames">master,slave,slave,slave</property> </poolConfig> </dbServer>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b62f7f464990cc7c7e3098cb0fa3a8d3.html