1 下载
-
[root@hostnfsd :/usr/local/oneproxy]$ vi demo.sh
#/bin/bash
#
export ONEPROXY_HOME=/usr/local/oneproxy
# valgrind --leak-check=full \
${ONEPROXY_HOME}/bin/oneproxy --keepalive \
--proxy-address=192.168.1.6:3308 \
--admin-address=192.168.1.6:4041 \
--proxy-master-addresses=192.168.1.6:3307@group1 \
--proxy-slave-addresses=192.168.1.56:3307@group1 \
--proxy-user-list=testuser/950434F7872CB57A600E1B2B7237766FA7E95460@testbak \
--proxy-user-list=jonn/950434F7872CB57A600E1B2B7237766FA7E95460@testbak2 \ ---就这不同,用户指定默认数据库不一样罢了
--proxy-group-policy=group1:Read-balance \
--proxy-charset=utf8_chinese_ci \
--log-file=${ONEPROXY_HOME}/oneproxy.log \
--pid-file=${ONEPROXY_HOME}/oneproxy.pid
测试:
[root@hostnfsd :/root]$ mysql -ujonn -ptestuser -h192.168.1.6 --port=3308 -e "select * from test2" group1 ---读写分离
Warning: Using a password on the command line interface can be insecure.
+------+
| id |
+------+
| 106 |
+------+
[root@hostnfsd :/root]$ mysql -ujonn -ptestuser -h192.168.1.6 --port=3308 -e "select * from test2" group1
Warning: Using a password on the command line interface can be insecure.
+------+
| id |
+------+
| 56 |
+------+
[root@hostnfsd :/root]$ mysql -ujonn -ptestuser -h192.168.1.6 --port=3308 -e "select * from test2" group1
Warning: Using a password on the command line interface can be insecure.
+------+
| id |
+------+
| 106 |
+------+
[root@hostnfsd :/root]$ mysql -ujonn -ptestuser -h192.168.1.6 --port=3308 -e "insert into test2 values(111)" group1 ---插入主库
Warning: Using a password on the command line interface can be insecure.
[root@hostnfsd :/root]$ mysql -ujonn -ptestuser -h192.168.1.6 --port=3308 -e "select * from test2" group1
Warning: Using a password on the command line interface can be insecure.
+------+
| id |
+------+
| 56 |
+------+
[root@hostnfsd :/root]$ mysql -ujonn -ptestuser -h192.168.1.6 --port=3308 -e "select * from test2" group1
Warning: Using a password on the command line interface can be insecure.
+------+
| id |
+------+
| 106 |
| 111 |
+------+
[root@hostnfsd :/root]$ mysql -ujonn -ptestuser -h192.168.1.6 --port=3308 -e "select * from test2" group1
Warning: Using a password on the command line interface can be insecure.
+------+
| id |
+------+
| 56 |
+------+
[root@hostnfsd :/root]$ mysql -ujonn -ptestuser -h192.168.1.6 --port=3308 -e "select * from test2" group1
Warning: Using a password on the command line interface can be insecure.
+------+
| id |
+------+
| 106 |
| 111 |