久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Mysql中如何搭建oneproxy

148次閱讀
沒有評論

共計 3871 個字符,預計需要花費 10 分鐘才能閱讀完成。

丸趣 TV 小編給大家分享一下 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 簡單讀寫分離

插入數據:[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    |
+——+——+

成功插入主庫

讀負載均衡測試:

[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 |
+——+

讀負載均衡,均衡分發至每個庫

多用戶:

[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”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-19發表,共計3871字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 黑水县| 九龙城区| 清镇市| 府谷县| 鄂托克旗| 紫云| 灵山县| 田东县| 盐池县| 鸡泽县| 隆昌县| 静乐县| 印江| 桓台县| 杂多县| 伊通| 石渠县| 沧州市| 大余县| 天津市| 佛坪县| 申扎县| 朝阳县| 黎平县| 特克斯县| 巧家县| 梅河口市| 康乐县| 鄄城县| 临邑县| 萝北县| 颍上县| 五常市| 上虞市| 五家渠市| 新巴尔虎左旗| 砚山县| 喀喇沁旗| 延安市| 大足县| 专栏|