在docker中haproxy的安裝以及mysql的負載均衡配置
HAProxy提供高可用性、負載均衡以及基於TCP和HTTP應用的代理,支援虛擬主機,它是免費、快速並且可靠的一種解決方案 |
1 什麼是haproxy
HAProxy提供高可用性、負載均衡以及基於TCP和HTTP應用的代理,支援虛擬主機,它是免費、快速並且可靠的一種解決方案。HAProxy特別適用於那些負載特大的web站點,這些站點通常又需要會話保持或七層處理。HAProxy執行在當前的硬體上,完全可以支援數以萬計的併發連線。並且它的執行模式使得它可以很簡單安全的整合進您當前的架構中, 同時可以保護你的web伺服器不被暴露到網路上。
2 haproxy的安裝
1.拉取映象
docker pull haproxy
2.配置目錄
mkdir /docker/haproxy-master/ touch /docker/haproxy-master/haproxy.cfg
3.配置haproxy.cfg檔案
defaults mode tcp log global option tcplog option dontlognull option http-server-close option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000 frontend mysql bind 0.0.0.0:13307 mode tcp log global default_backend mysql_server backend mysql_server balance roundrobin server mysql1 192.168.228.131:3307 check inter 5s rise 2 fall 3 server mysql2 192.168.228.131:3308 check inter 5s rise 2 fall 3 listen stats mode http bind 0.0.0.0:1080 stats enable stats hide-version stats uri /haproxyamdin?stats stats realm Haproxy\ Statistics stats auth admin:admin stats admin if TRUE
1080埠為視覺化介面
4.構建相關容器
docker run -p 1080:1080 -p 13307:13307 -d --name haproxy-master -v /docker/haproxy-master/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg --privileged=true haproxy
5.負載均衡測試(本地連線)
可以看到訪問不同的server_id。
「其他文章」
- sql server如何刪除前1000行資料
- spring boot 不連線資料庫啟動
- 刪除字串中的所有相鄰重複項
- 超全面的Linux基礎知識的梳理
- 手把手教你 Socket 通訊(TCP/IP)
- Vue Openlayer中使用select選擇要素
- 對order by的理解
- 在docker中haproxy的安裝以及mysql的負載均衡配置
- JavaScript字串中URL的檢測並轉換為連結
- 只要有熱情和方法就能學好Linux
- Highcharts 環境配置介紹
- Centos7安裝與配置OpenVPN伺服器
- ECharts 互動元件概述
- docker初體驗:docker部署wordpress部落格系統
- 如何使用evilscan 掃描網路
- docker初體驗:docker 自己定製映象
- ECharts 樣式設定介紹
- 一名合格的運維工程師的歷練之路
- Python中非常有用的三個資料科學庫
- ssl證書是由什麼組成?ssl證書是什麼?