怎么實(shí)現(xiàn)slave集群負(fù)載均衡-創(chuàng)新互聯(lián)

這篇文章主要講解了“怎么實(shí)現(xiàn)slave集群負(fù)載均衡”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么實(shí)現(xiàn)slave集群負(fù)載均衡”吧!

創(chuàng)新互聯(lián)公司是網(wǎng)站建設(shè)技術(shù)企業(yè),為成都企業(yè)提供專業(yè)的成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè),網(wǎng)站設(shè)計(jì),網(wǎng)站制作,網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制適合企業(yè)的網(wǎng)站。10多年品質(zhì),值得信賴!

一.介紹
由于互聯(lián)網(wǎng)系統(tǒng)讀的壓力要遠(yuǎn)大于寫的壓力,因此該軟件主要實(shí)現(xiàn)分散壓力,負(fù)載均衡的功能。
- 四層負(fù)載均衡(TCPIP協(xié)議的負(fù)載均衡)
haproxy lvs

- 七層負(fù)載均衡(http協(xié)議的負(fù)載均衡)
nginx

二.結(jié)構(gòu)圖
怎么實(shí)現(xiàn)slave集群負(fù)載均衡

三.安裝配置haproxy
1.將安裝包上傳
haproxy-1.7.9.tar.gz

2.編譯安裝
tar -xzvf haproxy-1.7.9.tar.gz
- 查看內(nèi)核版本
# uname -r
2.6.32-696.el6.x86_64

- 根據(jù)內(nèi)核版本進(jìn)行編譯
<1img src="https://img-blog.csdn.net/20170415144338483?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamlhbmt1bmtpbmc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這里寫圖片描述" title="" style="box-sizing:border-box;outline:0px;margin:24px 0px;max-width:100%;word-break:break-all;cursor:zoom-in;color:#4F4F4F;font-family:-apple-system, " font-size:16px;text-align:justify;white-space:normal;background-color:#ffffff;"="">
yum install gcc*
make TARGET=linux26 PREFIX=/usr/local/haproxy ARCH=X86_64
make install PREFIX=/usr/local/haproxy

# /usr/local/haproxy/sbin/haproxy -v
HA-Proxy version 1.7.9 2017/08/18
Copyright 2000-2017 Willy Tarreau 3.建立haproxy用戶
useradd haproxy
chown -R  haproxy.haproxy /usr/local/haproxy

4.配置
- 復(fù)制haproxy文件到/usr/sbin下 
因?yàn)橄旅娴膆aproxy.init啟動(dòng)腳本默認(rèn)會(huì)去/usr/sbin下找,當(dāng)然你也可以修改,不過比較麻煩。
cp /usr/local/haproxy/sbin/haproxy /usr/sbin/

- 復(fù)制haproxy腳本,到/etc/init.d下
cp /tmp/haproxy-1.7.9/examples/haproxy.init /etc/init.d/haproxy
chmod 755 /etc/init.d/haproxy

- 創(chuàng)建配置文件
mkdir /etc/haproxy
vi /etc/haproxy/haproxy.cfg

.conf  去掉下面兩列的注釋
$ModLoad imudp
$UDPServerRun 514
然后添加下面的行
local1.* /var/log/haproxy.log

重啟rsyslog
# service rsyslog restart
Shutting down system logger:                               [  OK  ]
Starting system logger:                                    [  OK  ]

5.啟動(dòng)haproxy
在管理server上添加vip
ifconfig eth0:0 192.168.1.208
service haproxy start

四.測試負(fù)載均衡
1.數(shù)據(jù)庫連接

點(diǎn)擊(此處)折疊或打開

  1. [root@mysql5 ~]# mysql -uroot -p -h 192.168.1.208 -P 3307 -e "select @@hostname"

  2. Enter password:

  3. +------------+

  4. | @@hostname |

  5. +------------+

  6. | mysql5.7   |

  7. +------------+

  8. [root@mysql5 ~]# mysql -uroot -p -h 192.168.1.208 -P 3307 -e "select @@hostname"

  9. Enter password:

  10. +------------+

  11. | @@hostname |

  12. +------------+

  13. | mysql5.7-2 |

  14. +------------+

  15. [root@mysql5 ~]# mysql -uroot -p -h 192.168.1.208 -P 3307 -e "select @@hostname"

  16. Enter password:

  17. +------------+

  18. | @@hostname |

  19. +------------+

  20. | mysql5.7-3 |

  21. +------------+

  22. [root@mysql5 ~]# mysql -uroot -p -h 192.168.1.208 -P 3307 -e "select @@hostname"

  23. Enter password:

  24. +------------+

  25. | @@hostname |

  26. +------------+

  27. | mysql5.7   |

  28. +------------+


2.登陸網(wǎng)頁
http://192.168.1.208:48800/admin-status
怎么實(shí)現(xiàn)slave集群負(fù)載均衡

感謝各位的閱讀,以上就是“怎么實(shí)現(xiàn)slave集群負(fù)載均衡”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)怎么實(shí)現(xiàn)slave集群負(fù)載均衡這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

文章標(biāo)題:怎么實(shí)現(xiàn)slave集群負(fù)載均衡-創(chuàng)新互聯(lián)
網(wǎng)頁地址:http://bm7419.com/article2/ijdic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、關(guān)鍵詞優(yōu)化、網(wǎng)站營銷、網(wǎng)站設(shè)計(jì)公司、企業(yè)建站、移動(dòng)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)