千家信息网

Mysql中如何搭建oneproxy

发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,小编给大家分享一下Mysql中如何搭建oneproxy,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!1 下载官网:http
千家信息网最后更新 2026年11月01日Mysql中如何搭建oneproxy

小编给大家分享一下Mysql中如何搭建oneproxy,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

1 下载
官网:http://www.onexsoft.cn/software/step_into_oneproxy.pdf

2 安装
机器有限,oneproxy就安装在192.168.1.6上
192.168.1.6--主---oneproxy
192.168.1.56---从

3 简单读写分离

  1. 插入数据:[chenliang@hostnfsd oneproxy]$ mysql -utestuser -ptestuser -h292.168.1.6 --port=3308 -e "insert into test2(id) values(4)" testbak;
    Warning: Using a password on the command line interface can be insecure.
    [chenliang@hostnfsd oneproxy]$ mysql -utestuser -ptestuser -h292.168.1.6 --port=3308 -e "select * from test2" testbak;
    Warning: Using a password on the command line interface can be insecure.
    +------+------+
    | id | name |
    +------+------+
    | 1 | NULL |
    | 2 | NULL |
    | 3 | 4 |
    +------+------+

  2. 成功插入主库


读负载均衡测试:

  1. [chenliang@hostnfsd oneproxy]$ mysql -utestuser -ptestuser -h292.168.1.6 --port=3308 -e "select * from test2" group1;
    Warning: Using a password on the command line interface can be insecure.
    +------+------+
    | id | name |
    +------+------+
    | 1 | NULL |
    | 2 | NULL |
    | 3 | 4 |
    +------+------+
    [chenliang@hostnfsd oneproxy]$ mysql -utestuser -ptestuser -h292.168.1.6 --port=3308 -e "select * from test2" group1;
    Warning: Using a password on the command line interface can be insecure.
    +------+
    | id |
    +------+
    | 1 |
    | 2 |
    +------+
    [chenliang@hostnfsd oneproxy]$ mysql -utestuser -ptestuser -h292.168.1.6 --port=3308 -e "select * from test2" group1;
    Warning: Using a password on the command line interface can be insecure.
    +------+------+
    | id | name |
    +------+------+
    | 1 | NULL |
    | 2 | NULL |
    | 3 | 4 |
    +------+------+
    [chenliang@hostnfsd oneproxy]$ mysql -utestuser -ptestuser -h292.168.1.6 --port=3308 -e "select * from test2" group1;
    Warning: Using a password on the command line interface can be insecure.
    +------+
    | id |
    +------+
    | 1 |
    | 2 |
    +------+


  2. 读负载均衡,均衡分发至每个库


多用户:

  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 -h292.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 -h292.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 -h292.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 -h292.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 -h292.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 -h292.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 -h292.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 -h292.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 |

以上是"Mysql中如何搭建oneproxy"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

均衡 篇文章 内容 数据 用户 测试 不同 成功 不怎么 大部分 数据库 更多 有限 机器 知识 罢了 行业 资讯 资讯频道 频道 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 互联网高科技 天津市摩尔互联网科技 广东猪兼强互联网科技有限公司 互联网科技活动banner 金融科技创新监管互联网金融 北京互联网络科技有限公司 兼蜜互联网科技 栖莱科技互联网股份有限公司 互联网校园科技培训 杭州壁岐互联网科技有限公司 苏州铭阳互联网科技有限公司 互联网科技和信息 华夏恒生互联网科技013171 长沙茂晟互联网科技有限公司 互联网科技大赛获奖感言 黑科技 体验场景 互联网大会 互联网第三次科技革命特征 互联网科技资金流入 美国互联网科技公司 互联网科技对化妆品行业 中关村互联网 科技集团 广州百单互联网科技有限公司 国智互联网科技 互联网科技未来 万达互联网科技 青海科技产业互联网发展 山东有哪些互联网科技公司 卡尔迅互联网科技有限公司 互联网科技博主张洲 恒生科技互联网指数十大成分股
0