環境
10.0.0.134 dr1 負載均衡器
10.0.0.133 dr2 負載均衡器
10.0.0.131 rs1 web1
10.0.0.128 rs2 web2
10.0.0.11 vip
配置
1.在master上安裝配置keepalived
# yum -y install keepalived ipvsadm
ipvsadm安裝並不啟動 keepalived會喚醒
2.在master上修改配置檔案# vim /etc/keepalived/keepalived.conf
! configuration file for keepalived
global_defs
vrrp_instance vi_1
virtual_ipaddress }
virtual_server 10.0.0.11 80
} real_server 10.0.0.128 80
}}
3.在backup上安裝keepalived:# yum -y install keepalived ipvsadm
將master的配置檔案拷貝過來
# scp 10.0.0.133:/etc/keepalived/keepalived.conf /etc/keepalived/
進行修改
router_id director2
state backup
priority 100
6.master和backup上啟動服務:# systemctl enable keepalived
# systemctl start keepalived
# reboot
7.web1和web2同配置(apache或nginx)
安裝web測試站點
修改yum源
vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=
gpgcheck=0
enabled=1
說明:os:表作業系統,osrelease:表系統版本
# yum clean all
# yum makecache
# yum -y install nginx
# systemctl start nginx
# systemctl enable nginx
修改nginx**配置檔案,方便測試
# vim /usr/share/nginx/html/index.html
本次web1中寫111,web2中寫222
配置虛擬位址#cp /etc/sysconfig/network-scripts/
#vim /etc/sysconfig/network-scripts/ifcfg-lo:0
device=lo:0
ipaddr=10.0.0.11
netmask=255.255.255.255
onboot=yes
其他行注釋掉
配置路由#vim /etc/rc.local
/sbin/route add host 10.0.0.11 dev lo:0
配置arp# vim /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
重啟# reboot
測試1)觀察lvs路由條目
master上查詢 # ipvsadm -l
2)觀察vip位址在哪台機器上
master上查詢 # ip a
3)客戶端瀏覽器訪問vip
10.0.0.11
4)關閉master上的keepalived服務,再次訪問vip
5)關閉web1站點服務,再次訪問vip
keepalived lvs安裝部署
1.keepalived的設計目標是構建高可用的lvs負載均衡群集,可以呼叫ipvsadm工具來建立虛擬伺服器 管理伺服器池,而不僅僅是雙機熱備。優點 keepalived對lvs負載排程器實現熱備切換,提高可用性,對伺服器池中的節點進行健康檢查,自動移除失效節點,恢復後再重新加入。2.基於lvs ...
MySQL cluster集群 NDB集群學習
公司主業務用的mysql集群是官方自帶的mysql cluster,mysql自帶的集群模式,這個集群的模式和mgr pxc 主從 有點不一樣。一 儲存引擎不是innodb,mysql cluster用的是ndb引擎 二 資料儲存方式不同,mysql的其他集群方式資料是存在磁碟上的,中間資料的快取用...
zookeeper集群部署 kafka集群部署
wget wget 解壓到目錄 tar zxvf apache zookeeper 3.5.8 bin.tar.gz c usr local 進入目錄 cd usr local 建立軟連線 ln s usr local apache zookeeper 3.5.8 zookeeper 複製配置檔案 ...