<!-- service class must implements com.meidusa.amoeba.service.Service --> <servicename="Amoeba for Mysql"class="com.meidusa.amoeba.net.ServerableConnectionManager"> <!-- Amoeba 端口号 ,客户端client 链接amoeba端口号,不能和主从数据库 冲突--> <propertyname="port">8066</property>
<!-- Each ConnectionManager will start as thread manager responsible for the Connection IO read , Death Detection --> <connectionManagerList> <connectionManagername="clientConnectioneManager"class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper"> <propertyname="subManagerClassName">com.meidusa.amoeba.net.ConnectionManager</property> <!-- default value is avaliable Processors <property name="processors">5</property> --> </connectionManager> <connectionManagername="defaultManager"class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper"> <propertyname="subManagerClassName">com.meidusa.amoeba.net.AuthingableConnectionManager</property>
<!-- default value is avaliable Processors <property name="processors">5</property> --> </connectionManager> </connectionManagerList>
<!-- default using file loader --> <dbServerLoaderclass="com.meidusa.amoeba.context.DBServerConfigFileLoader"> <propertyname="configFile">${amoeba.home}/conf/dbServers.xml</property> </dbServerLoader>
./amoeba The stack size specified is too small, Specify at least 228k Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
#再次启动 ./amoeba start log4j:WARN log4j config load completed from file:/opt/amoeba/conf/log4j.xml 2019-06-02 01:08:48,521 INFO context.MysqlRuntimeContext - Amoeba for Mysql current versoin=5.1.45-mysql-amoeba-proxy-2.2.0 log4j:WARN ip access config load completed from file:/opt/amoeba/conf/access_list.conf 2019-06-02 01:08:49,517 INFO net.ServerableConnectionManager - Amoeba for Mysql listening on /192.168.1.101:8066. 2019-06-02 01:08:49,522 INFO net.ServerableConnectionManager - Amoeba Monitor Server listening on /192.168.1.101:39401.
#在amoeba机器上执行 (注意amoeba客户端端口-在上面的配置文件里面) mysql -h 192.168.1.101 -P8066 -uroot -proot Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 1186796719 Server version: 5.1.45-mysql-amoeba-proxy-2.2.0 #注意观察这里不一样
#2. 编译安装LUA #从http://www.lua.org/download.html下载源码包并安装 wget http://www.lua.org/ftp/lua-5.3.5.tar.gz -O /opt/ tar -zxf lua-5.3.5.tar.gz && cd lua-5.3.5 make linux && make install #注意发生错误的先执行make clean 编译过程中遗留的文件 # make[1]: 进入目录“/opt/lua-5.3.5/src” # make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" # make[2]: 进入目录“/opt/lua-5.3.5/src”
$vi /etc/init.d/mysql-proxy #!/bin/sh # mysql-proxy This script starts and stops the mysql-proxy daemon # chkconfig: - 78 30 # processname: mysql-proxy # description: mysql-proxy is a proxy daemon to mysql # Source function library. . /etc/rc.d/init.d/functions
# Source mysql-proxy configuration. if [ -f /etc/sysconfig/mysql-proxy ]; then . /etc/sysconfig/mysql-proxy fi
PATH=$PATH:/usr/bin:/usr/local/bin:$PROXY_PATH # By default it's all good RETVAL=0
# See how we were called. case "$1" in start) # Start daemon. echo -n $"Starting $prog: " $NICELEVEL $PROXY_PATH/mysql-proxy $PROXY_OPTIONS --daemon --pid-file=$PROXY_PID --user=mysql RETVAL=$? echo if [ $RETVAL = 0 ]; then touch /var/lock/subsys/mysql-proxy fi ;;
#1.启动nysql-proxy和赋值权限 chmod 755 /etc/init.d/mysql-proxy chmod 600 /etc/mysql-proxy.cnf /etc/init.d/mysql-proxy start /etc/init.d/mysql-proxy status # ● mysql-proxy.service - SYSV: mysql-proxy is a proxy daemon to mysql # Loaded: loaded (/etc/rc.d/init.d/mysql-proxy; bad; vendor preset: disabled) # Active: active (running) since 日 2019-06-02 21:29:00 CST; 2s ago
netstat -tlnp # Active Internet connections (only servers) # Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name # tcp 0 0 0.0.0.0:4040 0.0.0.0:* LISTEN 12741/mysql-proxy # tcp 0 0 0.0.0.0:4041 0.0.0.0:* LISTEN 12741/mysql-proxy
#2.登录主库建立一个test用户从数据库中暂时关闭主从复制的功能 % | test | mysql_native_password | #注意认证插件 mysql> grant select on *.* to 'test'@'%'; #从库在停止主从前执行 mysql> stop slave; Query OK, 0 rows affected (0.00 sec) mysql>flush privileges; Query OK, 0 rows affected (0.01 sec)
#3. 登录mysql-porxy管理段主从查看状态(与/opt/mysql-proxy/lua/rw-splitting.lua 配置文件有关) MySQL [(none)]> SELECT * FROM help; +------------------------+------------------------------------+ | command | description | +------------------------+------------------------------------+ | SELECT * FROM help | shows this help | | SELECT * FROM backends | lists the backends and their state | +------------------------+------------------------------------+ 2 rows inset (0.00 sec)
MySQL [(none)]> SELECT * FROM backends; #有可能需要登录有多个终端才能触发从库up +-------------+--------------------+-------+------+------+-------------------+ | backend_ndx | address | state | type | uuid | connected_clients | +-------------+--------------------+-------+------+------+-------------------+ | 1 | 192.168.1.100:3306 | up | rw | NULL | 1 | | 2 | 192.168.1.100:3307 | up | ro | NULL | 1 | +-------------+--------------------+-------+------+------+-------------------+ # up:表示读写分离生效 # unKnown:还没生效
#4.连接连接MySQL-Proxy并且插入数据到主库(注意这里是数据库的账号密码) $mysql -h 192.168.1.101 -P 4040 -utest -pweiye!@#888 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 22 Server version: 8.0.16 MySQL Community Server - GPL
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主, 将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!