# 將keepalived解壓到/usr/local目錄下
tar -zxvf keepalived-2.0.11.tar.gz -C /usr/local
cd /usr/local/keepalived-2.0.11
臨湘網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、自適應(yīng)網(wǎng)站建設(shè)等網(wǎng)站項目制作,到程序開發(fā),運營維護。成都創(chuàng)新互聯(lián)公司成立于2013年到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)公司。
./configure --prefix=/usr/local/keepalived
#編譯并安裝
make && make install
出現(xiàn)以下信息表示編譯成功
Keepalived version : 2.0.11
Compiler : gcc
Preprocessor flags :
Compiler flags : -Wall -Wunused -Wstrict-prototypes -Wextra -Winit-self -g -D_GNU_SOURCE -fPIE -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -O2
Linker flags : -pie
Extra Lib : -lcrypto -lssl -lnl
Use IPVS Framework : Yes
IPVS use libnl : Yes
IPVS syncd attributes : No
IPVS 64 bit stats : No
HTTP_GET regex support : No
fwmark socket support : Yes
Use VRRP Framework : Yes
Use VRRP VMAC : Yes
Use VRRP authentication : Yes
With ip rules/routes : Yes
Use BFD Framework : No
SNMP vrrp support : No
SNMP checker support : No
SNMP RFCv2 support : No
SNMP RFCv3 support : No
DBUS support : No
SHA1 support : No
Use JSON output : No
libnl version : 1
Use IPv4 devconf : No
Use iptables : Yes
Use libiptc : No
Use libipset : No
Use nftables : No
init type : systemd
Strict config checks : No
Build genhash : Yes
Build documentation : No
編譯可能出現(xiàn)的問題
*** WARNING - this build will not support IPVS with IPv6. Please install libnl/libnl-3 dev libraries to support IPv6 with IPVS.
執(zhí)行yum命令yum -y install libnl libnl-devel解決上述警告問題
yum -y install libnl libnl-devel
configure: error: in /usr/local/keepalived-2.0.11':<br/>configure: error: no acceptable C compiler found in $PATH<br/>See
config.log' for more details
yum install gcc
configure: error:
!!! OpenSSL is not properly installed on your system. !!!
!!! Can not include OpenSSL headers files. !!!
[root@dajia keepalived-2.0.11]#
yum -y install openssl-devel
安裝完成以后,重新執(zhí)行configure ... 命令
將keepalived添加到系統(tǒng)服務(wù)中
路徑 說明
/usr/local/keepalived-2.0.10 解壓后源碼存放路徑
/usr/local/keepalived 安裝目錄
# 拷貝執(zhí)行文件
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
# 將初始化腳本拷貝到系統(tǒng)初始化目錄下
cp /usr/local/keepalived-2.0.10/keepalived/etc/init.d/keepalived /etc/init.d/
# 將keepalived配置文件拷貝到etc下
cp /usr/local/keepalived-2.0.10/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
# 創(chuàng)建keepalived文件夾
mkdir /etc/keepalived/
# 將keepalived配置文件拷貝到etc下
cp /usr/local/keepalived-2.0.10/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
# 添加可執(zhí)行權(quán)限
chmod +x /etc/init.d/keepalived
# 添加keepalived到開機啟動
chkconfig --add keepalived
chkconfig keepalived on
此時已加入系統(tǒng)服務(wù) 可使用services 啟動
#啟動
service keepalived start
#停止
service keepalived stop
#重啟
service keepalived restart
#查看啟動情況
ps -aux |grep keepalived
配置keepalived虛擬IP
修改剛添加到系統(tǒng)的配置文件:vi /etc/keepalived/keepalived.conf
注意 是系統(tǒng)的配置文件(/etc/keepalived/keepalived.conf)
注意 是系統(tǒng)的配置文件(/etc/keepalived/keepalived.conf)
注意 是系統(tǒng)的配置文件(/etc/keepalived/keepalived.conf)
不是安裝目錄/usr/local...下的
vrrp_instance VI_1 {
state MASTER //MASTER主節(jié)點,備用節(jié)點上設(shè)置為state BACKUP
interface ens33 //綁定虛擬機IP的網(wǎng)卡 兩個節(jié)點設(shè)置一樣 根據(jù) ipaddr換成對應(yīng)的網(wǎng)卡地址
virtual_router_id 51 //VRRP組名,主副節(jié)點設(shè)置必須一樣,指名各個節(jié)點屬于同一個VRRP組,同一個組的節(jié)點互相搶IP
priority 100 //優(yōu)先級(1~254之間),備用節(jié)點必須比主節(jié)點優(yōu)先級低
advert_int 1 //組播信息發(fā)送間隔,兩個節(jié)點設(shè)置必須一樣
authentication { //設(shè)置驗證信息, 兩個節(jié)點設(shè)置必須一樣,用于節(jié)點間信息轉(zhuǎn)發(fā)時的加密
auth_type PASS
auth_pass 1111
}
virtual_ipaddress { // 虛擬IP兩個節(jié)點設(shè)置必須一樣,兩節(jié)點同時搶一個io
192.168.33.60/24 // 如果兩個nginx的ip分別是192.168.33.61,,...62,則此處的虛擬ip跟它倆同一個網(wǎng)段即可 24代表3個255的子網(wǎng)掩碼
}
}
如果要 ping 192.168.33.60 還需要注釋掉配置文件中的# vrrp_strict
遇到的問題
主備都搶到了虛擬ip
采用tcpdump抓包定位問題,以下是在192.168.93.141 主節(jié)點的抓包結(jié)果
tcpdump -i ens33 vrrp -n
![](/upload/otherpic47/9034.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
以下是在10.11.4.187 備節(jié)點的抓包結(jié)果
tcpdump -i ens33 vrrp -n
![](/upload/otherpic47/9036.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
由上圖可以看到,192.168.93.140和192.168.93.141兩個IP在輪流發(fā)送組播信號。而正常的應(yīng)該是由MASTER服務(wù)器發(fā)送組播,如果BACKUP收不到MASTER的組播信號了,那么判定MASTER宕機了,BACKUP就會接手VIP
問題就是出現(xiàn)在了防火墻這里,防火墻阻止了vrrp組包發(fā)送
如果是Firewalld防火墻 則主、備都運行下面的命令
[root@dajia sysconfig]# firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 --protocol vrrp -j ACCEPT
success
[root@dajia sysconfig]# firewall-cmd --reload
success
網(wǎng)頁題目:keepalived安裝配置(Centos7)
文章URL:http://aaarwkj.com/article36/googsg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、企業(yè)網(wǎng)站制作、網(wǎng)站策劃、微信公眾號、網(wǎng)站排名、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)