标签:实现 eth start $path erp replica 打开 buffers emc
Amoeba是一个以MySQL为底层数据存储,并对应用提供MySQL协议接口的proxy,它集中地响应应用的请求,依据用户事先设置的规则,将SQL请求发送到特定的数据库上执行.基于此可以实现负载均衡、读写分离、高可用性等需求,与MySQL官方的MySQL Proxy相比,作者强调的是amoeba配置的方便.
1.主从服务器需要配置好主从关系,主从服务器都需要安装MySQL.
[root@localhost ~]# yum install -y mysql mysql-server
2.启动MySQL服务,并设置初始化密码(主从都要重启).
[root@localhost ~]# systemctl restart mysqld
[root@localhost ~]# mysqladmin -uroot password 123
3.修改主配置文件/etc/my.cnf
并再次重启MySQL(主从都要修改).
[root@localhost ~]# vim /etc/my.cnf
log-bin=mysql-bin #开启二进制日志文件
server-id=148 #声明本台MySQL服务器ID号
4.登陆主数据库,创建用于从服务器登陆的用户(主服务器).
[root@localhost ~]# mysql -uroot –p
mysql> grant replication slave on *.* to '用户名'@'%' identified by '密码'; #创建从服务器用户
mysql> show master status; #查看二进制文件名
5.登陆从数据库,确认从主服务器同步数据(从服务器).
[root@localhost ~]# mysql -uroot –p
mysql> change master to master_host='主服务器IP',master_user='用户',master_password='密码',master_log_file='二进制文名',master_log_pos=文件空间大小;
mysql> start slave; #启动同步功能
mysql> show slave status\G; #查看同步状态
注意:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes #只用在两个选项都为YES才证明开启
1.本台服务器也应安装MySQL用于登录测试,不需要启动.
[root@localhost ~]# yum install -y mysql mysql-server
2.解压相应软件并改名.
[root@localhost ~]# tar -xzvf jdk-7u40-linux-x64.gz -C /usr/local/ #解压到jdk目录
[root@localhost ~]# mv /usr/local/jdk1.7.0_40/ /usr/local/jdk #重命名JDK目录
3.配置JAVA环境变量,写入/etc/profile
文件中,使其开机生效.
[root@localhost ~]# vim /etc/profile #设置开机自加载
#--------------------------------------------------------------------
#Java-SE-JDK
JAVA_HOME=/usr/local/jdk
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH
export CLASSPATH
#--------------------------------------------------------------------
[root@localhost ~]# source /etc/profile #刷新配置文件
[root@localhost ~]# java -version #测试java是否可用
4.进入主从MySQL分别创建Amoeba使用的账号(主从服务器都要创建).
[root@localhost ~]# grant all privileges on *.* to 'master'@'%' identified by '123'; #创建主服务器登陆账号
[root@localhost ~]# grant all privileges on *.* to 'slave1'@'%' identified by '123'; #创建从服务器登陆账号
5.安装Amoeba并设置权限.
[root@localhost ~]# unzip amoeba-mysql-1.3.1-BETA.zip -d /usr/local/amoeba #解压Amoeba
[root@localhost ~]# chmod -R a+x /usr/local/amoeba/bin/ #赋予可执行权限
6.编辑主配置文件,配置Amoeba.
[root@localhost ~]# vim /usr/local/amoeba/conf/amoeba.xml
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE amoeba:configuration SYSTEM "amoeba.dtd">
<amoeba:configuration xmlns:amoeba="http://amoeba.meidusa.com/">
<server>
<property name="port">8066</property> #指定Amoeba端口
<property name="ipAddress">192.168.22.147</property> #指定(Amoeba)本机IP
<property name="readThreadPoolSize">20</property>
<property name="clientSideThreadPoolSize">30</property>
<property name="serverSideThreadPoolSize">30</property>
<property name="netBufferSize">128</property>
<property name="tcpNoDelay">true</property>
<property name="user">root</property> #指定Amoeba登陆账号
<property name="password">123</property> #指定Amoea登陆密码
<property name="queryTimeout">60</property>
</server>
<connectionManagerList>
<connectionManager name="defaultManager" class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">
<property name="subManagerClassName">com.meidusa.amoeba.net.AuthingableConnectionManager</property>
</connectionManager>
</connectionManagerList>
<dbServerList>
#**********************************以下是主机区域******************************************
<dbServer name="server1"> #指定第1个server区域
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="manager">defaultManager</property>
<property name="port">3306</property> #指定主机1端口
<property name="ipAddress">192.168.22.148</property> #指定主机1 IP
<property name="schema">test</property> #同步的数据库
<property name="user">zhu1</property> #同步账号
<property name="password">123</property> #同步密码
</factoryConfig>
<poolConfig class="com.meidusa.amoeba.net.poolable.PoolableObjectPool">
<property name="maxActive">200</property>
<property name="maxIdle">200</property>
<property name="minIdle">10</property>
<property name="minEvictableIdleTimeMillis">600000</property>
<property name="timeBetweenEvictionRunsMillis">600000</property>
<property name="testOnBorrow">true</property>
<property name="testWhileIdle">true</property>
</poolConfig>
</dbServer>
<dbServer name="server2"> #指定第2个server区域
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="manager">defaultManager</property>
<property name="port">3306</property> #指定主机2端口
<property name="ipAddress">192.168.22.149</property> #指定主机2IP
<property name="schema">test</property> #同步的数据库
<property name="user">cong1</property> #同步账号
<property name="password">123</property> #同步密码
</factoryConfig>
<poolConfig class="com.meidusa.amoeba.net.poolable.PoolableObjectPool">
<property name="maxActive">200</property>
<property name="maxIdle">200</property>
<property name="minIdle">10</property>
<property name="minEvictableIdleTimeMillis">600000</property>
<property name="timeBetweenEvictionRunsMillis">600000</property>
<property name="testOnBorrow">true</property>
<property name="testWhileIdle">true</property>
</poolConfig>
</dbServer>
#*****************************************************************************************
#*******************************以下是主机命名区域****************************************
<dbServer name="master" virtual="true"> #主机命名区域1
<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
<property name="loadbalance">1</property>
<property name="poolNames">server1</property> #主机1区域名
</poolConfig>
</dbServer>
<dbServer name="slave" virtual="true"> #主机命名区域2
<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
<property name="loadbalance">1</property>
<property name="poolNames">server2</property> #主机2区域名
</poolConfig>
</dbServer>
</dbServerList>
#*****************************************************************************************
#**********************************以下是读写池区域***************************************
<queryRouter class="com.meidusa.amoeba.mysql.parser.MysqlQueryRouter">
<property name="ruleConfig">${amoeba.home}/conf/rule.xml</property>
<property name="functionConfig">${amoeba.home}/conf/functionMap.xml</property>
<property name="ruleFunctionConfig">${amoeba.home}/conf/ruleFunctionMap.xml</property>
<property name="LRUMapSize">1500</property>
<property name="defaultPool">master</property> #指定默认区域
<property name="writePool">master</property> #指定写池
<property name="readPool">slave</property> #指定读池
<property name="needParse">true</property>
</queryRouter>
</amoeba:configuration>
#*****************************************************************************************
7.打开amoeba配置文件.
[root@localhost ~]# vim /usr/local/amoeba/bin/amoeba
修改以下内容↓
DEFAULT_OPTS="-server -Xms256m -Xmx256m -Xss256k
8.启动amoeba
[root@localhost ~]# nohup bash -x /usr/local/amoeba/bin/amoeba &
9登陆数据库测试.
[root@localhost ~]# mysql -uroot -p -h 192.168.22.147 -P 8066
标签:实现 eth start $path erp replica 打开 buffers emc
原文地址:https://www.cnblogs.com/LyShark/p/10851176.html