【Mysql】One-proxy簡單搭建
1 下載
官網:
2 安裝
機器有限,oneproxy就安裝在192.168.1.6上
192.168.1.6--主---oneproxy
192.168.1.56---從
3 簡單讀寫分離
多使用者:
---待續,先做個筆記
官網:
2 安裝
機器有限,oneproxy就安裝在192.168.1.6上
192.168.1.6--主---oneproxy
192.168.1.56---從
3 簡單讀寫分離
-
[chenliang@hostnfsd oneproxy]$ more 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 \ ####mysql互動埠
-
--admin-address=192.168.1.6:4041 \ ####管理埠
-
--proxy-master-addresses=192.168.1.6:3307@group1 \ ####real mysql
-
--proxy-slave-addresses=192.168.1.56:3307@group1 \ ####real mysql
-
--proxy-user-list=testuser/950434F7872CB57A600E1B2B7237766FA7E95460@testbak \ #####使用者以及對應的預設資料庫,該使用者需提前在db中建好,密碼登入管理埠passwd '密碼' 生成,這一步可第二次新增
-
--proxy-group-policy=group1:Read-balance \ #####組策略,很多種,具體可看文件
-
--proxy-charset=utf8_chinese_ci \
-
--log-file=${ONEPROXY_HOME}/oneproxy.log \
- --pid-file=${ONEPROXY_HOME}/oneproxy.pid
(6與56只是名義上的主從,實際沒搭建呢,只是為了測試讀寫分別從哪個ip)
讀寫分離
-
插入資料:[chenliang@hostnfsd oneproxy]$ mysql -utestuser -ptestuser -h192.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 -h192.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 -h192.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 -h192.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 -h192.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 -h192.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 -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 |
[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 |
---待續,先做個筆記
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29096438/viewspace-2071595/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 簡單搭建MySQL主從複製MySql
- MySQL InnoDB Cluster環境搭建和簡單測試MySql
- Gin 框架的簡單搭建框架
- mysql 簡單安裝MySql
- Mysql 簡單入門MySql
- mysql簡單脫敏MySql
- MySQL簡單總結MySql
- mysql cluster 簡單配置MySql
- 使用MyBatis搭建一個訪問mysql資料庫的簡單示例MyBatisMySql資料庫
- mysql_to_mysql的gg簡單配置MySql
- nginx+php+mysql+wordpress搭建簡單站點 安裝及配置過程NginxPHPMySql
- mysql簡單效能測試MySql
- MySQL簡單最佳化MySql
- MySQL基本簡單操作01MySql
- mysql的簡單基本操作MySql
- 簡單的mysql查詢MySql
- MySQL MGR 叢集搭建(單主模式)MySql模式
- Redis叢集搭建與簡單使用Redis
- .Net Core 3.1簡單搭建微服務微服務
- 簡單使用PyTorch搭建GAN模型PyTorch模型
- Hadoop HA叢集簡單搭建Hadoop
- debian10 nfs簡單搭建NFS
- Ubuntu 搭建簡單 Git 伺服器UbuntuGit伺服器
- SpringMVC簡單搭建與入門SpringMVC
- MySQL NDB Cluster簡介及環境搭建MySql
- mysql的event的簡單使用MySql
- mysql goldengate同步 簡單配置MySqlGo
- 簡單實踐搭建 nginx 負載均衡Nginx負載
- Angular環境搭建及簡單體驗Angular
- 直播原始碼如何進行簡單搭建原始碼
- swarm mode叢集搭建及簡單概念Swarm
- Zookeeper環境搭建及簡單練習
- mysql查詢快取簡單使用MySql快取
- mysql日誌系統簡單使用MySql
- linux 安裝 mysql簡單教程LinuxMySql
- MySQL的簡單查詢語句MySql
- MySQL修復表的簡單分析MySql
- Ubuntu 安裝mysql和簡單操作UbuntuMySql