【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簡單總結MySql
- mysql 簡單安裝MySql
- Docker簡單使用MySQLDockerMySql
- mysql簡單脫敏MySql
- Mysql 簡單入門MySql
- Gin 框架的簡單搭建框架
- MySQL基本簡單操作01MySql
- mysql簡單效能測試MySql
- MySQL簡單最佳化MySql
- debian10 nfs簡單搭建NFS
- 簡單使用PyTorch搭建GAN模型PyTorch模型
- Hadoop HA叢集簡單搭建Hadoop
- MySQL MGR 叢集搭建(單主模式)MySql模式
- 如何使用 Node.js 和 MySQL 快速搭建簡單的增刪查改 APINode.jsMySqlAPI
- linux 安裝 mysql簡單教程LinuxMySql
- Redis叢集搭建與簡單使用Redis
- .Net Core 3.1簡單搭建微服務微服務
- MySQL的簡單查詢語句MySql
- MySql和簡單的sql語句MySql
- 簡單的php連線mysql類PHPMySql
- 簡單認識MySQL儲存引擎MySql儲存引擎
- mysql日誌系統簡單使用MySql
- mysql查詢快取簡單使用MySql快取
- swarm mode叢集搭建及簡單概念Swarm
- 簡單實踐搭建 nginx 負載均衡Nginx負載
- 直播原始碼如何進行簡單搭建原始碼
- Angular環境搭建及簡單體驗Angular
- MySQL MGR單主模式詳細搭建過程MySql模式
- angular中使用Echarts(環境搭建+簡單使用)AngularEcharts
- aws 之 python 和 go 環境簡單搭建PythonGo
- 簡單兩步--搭建自己的專屬梯子
- SpringCloud之Sentinel高可用流量框架簡單搭建SpringGCCloud框架
- Windows 10環境簡單搭建ELK叢集Windows
- [Rust]使用Rocket框架搭建簡單Web服務Rust框架Web
- Windows環境下ELK簡單搭建記錄Windows
- .Net Core Web Api 框架搭建簡單步驟WebAPI框架
- mysql的安裝和簡單的操作MySql
- MySQL:簡單insert 一秒原因排查MySql