OneProxy安装后目录类似如下:
[root@bogon oneproxy]# ls -l
总计 64
drwxr-xr-x 2 root root 4096 01-26 19:13 bin
drwxr-xr-x 2 root root 4096 01-29 09:43 conf
-rw-r--r-- 1 root root 160 01-26 19:13 demo.sh
drwxr-xr-x 2 root root 4096 01-28 15:40 log
-rwxr-xr-x 1 root root 869 01-27 11:42 oneproxy.service
-rw-r--r-- 1 root root 797 2015-04-21 README
-rw-r--r-- 1 root root 483 2015-05-16 testadmin.sql
-rw-r--r-- 1 root root 2159 01-10 21:07 testproxy.sql
新的版本主要规划了三个目录文件分别存放可运行程序、配置文件和日志文件,并且增加了新的运行方式:可以直接通过启动服务的方式来运行程序,使用上会更友好。
本次是测试步骤如下:
0、在测试之前准备了两台linux(redhat5.4)虚拟机(机器1:bogon,IP:10.122.3.73;机器2:bogon_2,IP:10.122.3.69),分别安装了MySQL5.6.27。
1、 安装OneProxy到bogon 的/usr/local/oneproxy目录下。
2、 修改配置文件proxy.conf,将两台机器设置成一个group,内容如下:
[oneproxy] keepalive = 1 event-threads = 4 log-file = log/oneproxy.log pid-file = log/oneproxy.pid lck-file = log/oneproxy.lck
mysql-version = 5.6.27 proxy-address = :3307 proxy-master-addresses.1 = 10.122.3.73:3306@server1 proxy-slave-addresses.1 = 10.122.3.69:3306@server1
proxy-user-list = test/1378F6CC3A8E8A43CA388193FBED5405982FBBD3@test #proxy-user-group = server1:test/1378F6CC3A8E8A43CA388193FBED5405982FBBD3 proxy-user-group = server1:test/1378F6CC3A8E8A43CA388193FBED5405982FBBD3 #proxy-user-group.2 = server2:test/1378F6CC3A8E8A43CA388193FBED5405982FBBD3
proxy-part-template = conf/template.txt proxy-part-tables.1 = conf/part.txt proxy-part-tables.2 = conf/part2.txt proxy-charset = gbk_chinese_ci proxy-group-policy = server1:master-only
proxy-secure-client = 127.0.0.1
remote-address = 10.122.3.69:4041 vip-address = 10.122.3.200/eth0:0 |
3、 根据oneproxy.service文件在/etc/init.d目录下创建oneproxyd文件,修改后内容如下:
ONEPROXY_HOME=/usr/local/oneproxy ONEPROXY_SBIN="${ONEPROXY_HOME}/bin/oneproxy" ONEPROXY_CONF="${ONEPROXY_HOME}/conf/proxy.conf" ONEPROXY_PID="${ONEPROXY_HOME}/log/oneproxy.pid" …(其他部分省略) |
4、 启动OneProxy,通过10.122.3.73:3307端口连接数据库,执行查询命令确认数据库是否可以访问:
[root@bogon oneproxy]# service oneproxyd start
Starting OneProxy ... [确定]
[root@bogon oneproxy]# ps -ef|grep oneproxy
root 29683 1 0 14:56 ? 00:00:00 /usr/local/oneproxy/bin/oneproxy --defaults-file=/usr/local/oneproxy/conf/proxy.conf
root 29684 29683 0 14:56 ? 00:00:00 /usr/local/oneproxy/bin/oneproxy --defaults-file=/usr/local/oneproxy/conf/proxy.conf
root 29709 31281 0 14:56 pts/1 00:00:00 grep oneproxy
[root@bogon ~]# mysql -h 10.122.3.200 -P 3307 -utest -ptest
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2016-01-31 14:59:59 |
+---------------------+
1 row in set (0.05 sec)
5、 停止OneProxy:
[root@bogon oneproxy]# service oneproxyd stop
Stopping OneProxy ... [确定]
[root@bogon oneproxy]# ps -ef|grep oneproxy
root 29951 31281 0 15:03 pts/1 00:00:00 grep oneproxy
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7913676/viewspace-1984853/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7913676/viewspace-1984853/