keepalived之 ipvsadm-1.26-4(lvs)+ keepalived-1.2.24 安裝

張衝andy發表於2017-06-16


一、安裝 LVS

前提:已經提前配置好本地 Yum 源 配置過程可參考> http://blog.csdn.net/zhang123456456/article/details/56690945
1、 檢查一下系統核心
安裝之前,首先檢查一下系統核心是否支援LVS的IPVS模組;自Linux 2.6開始,系統核心完全內建了LVS的各個模組。
[root@mysql03 ~]# modprobe -l|grep ipvs
kernel/net/netfilter/ipvs/ip_vs.ko
kernel/net/netfilter/ipvs/ip_vs_rr.ko
kernel/net/netfilter/ipvs/ip_vs_wrr.ko
kernel/net/netfilter/ipvs/ip_vs_lc.ko
....
kernel/net/netfilter/ipvs/ip_vs_pe_sip.ko
看到如上輸出資訊,則表明系統核心預設支援IPVS模組。

2、安裝依賴包
由於是原始碼包安裝,所以編譯時需要打上如下依賴包。
# yum -y install kernel-headers glibc-headers glibc-devel libgomp gcc libstdc++-devel gcc-c++

3、 yum安裝 ipvsadm-1.26-4 
[root@mysql03 ~]# yum -y install kernel-devel ipvsadm
===================================================================================
Package Arch Version Repository Size
===================================================================================
Installing:
ipvsadm x86_64 1.26-4.el6 c6-media 42 k

Transaction Summary
===================================================================================
Install 1 Package(s)

Total download size: 42 k
Installed size: 78 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ipvsadm-1.26-4.el6.x86_64 1/1 
Verifying : ipvsadm-1.26-4.el6.x86_64 1/1

Installed:
ipvsadm.x86_64 0:1.26-4.el6

Complete!
4、 做個 ln
[root@mysql03 ~]# ln -sv /usr/src/kernels/2.6.32-573.el6.x86_64/ /usr/src/linux <--請自行修改 kernels 版本號

5、 檢視 ipvsadm 版本資訊
[root@mysql03 ~]# ipvsadm -version
ipvsadm v1.26 2008/5/15 (compiled with popt and IPVS v1.2.1) #> 能看到幫助資訊,則說明IPVS安裝成功。

二、 安裝 keepalived-1.2.24

1、官網下載地址:
[root@mysql03 ~]# wget
2、解壓安裝包:
[root@mysql03 ~]# ll keepalived-1.2.24.tar.gz 
-rw-r--r--. 1 root root 601873 Jun 16 23:49 keepalived-1.2.24.tar.gz
[root@mysql03 ~]# tar -zxvf keepalived-1.2.24.tar.gz
3、進入安裝目錄:
[root@mysql03 ~]# cd keepalived-1.2.24

4、安裝keepalived:
[root@mysql03 keepalived-1.2.24]# ./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.32-573.el6.x86_64/

說明:--with-kernel-dri :指定使用核心原始碼中的標頭檔案,即include目錄,該引數很重要,只有使用LVS時才用此引數。
主要輸出:
Keepalived configuration
------------------------
Keepalived version : 1.2.24
Compiler : gcc
Preprocessor flags : 
Compiler flags : -Wall -Wunused -Wstrict-prototypes
Linker flags : 
Extra Lib : -ldl -lssl -lcrypto 
Use IPVS Framework : Yes
IPVS use libnl : No
IPVS syncd attributes : No
IPVS 64 bit stats : No
fwmark socket support : Yes
Use VRRP Framework : Yes
Use VRRP VMAC : Yes
Use VRRP authentication : Yes
With ip rules/routes : Yes
SNMP keepalived support : No
SNMP checker support : No
SNMP RFCv2 support : No
SNMP RFCv3 support : No
SHA1 support : No
Use Debug flags : No
Stacktrace support : No
Memory alloc check : No
libnl version : None
Use IPv4 devconf : No
Use libiptc : No
Use libipset : No
Build genhash : Yes
Build documentation : No
[root@mysql03 keepalived-1.2.24]# make && make install

5、複製指令碼和檔案:

5.1 複製執行檔案
[root@mysql03 keepalived-1.2.24]# cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
5.2 將init.d檔案複製到etc下,加入開機啟動項
[root@node6 keepalived-1.2.16]# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
5.3 將keepalived檔案複製到etc下,加入網路卡配置
[root@node6 keepalived-1.2.16]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
5.4 建立keepalived資料夾
[root@node6 keepalived-1.2.16]# mkdir /etc/keepalived
5.5 將keepalived配置檔案複製到etc下
[root@node6 keepalived-1.2.16]# cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
5.6 複製啟動指令碼
[root@node6 keepalived-1.2.16]# cp /usr/local/keepalived/sbin/keepalived /etc/keepalived/

6、加入開機啟動項
[root@mysql03 keepalived-1.2.24]# chkconfig --add keepalived #新增時必須保證/etc/init.d/keepalived存在
7、 啟動
[root@mysql03 keepalived-1.2.24]# chmod 755 /etc/init.d/keepalived
[root@mysql03 keepalived-1.2.24]# service keepalived start
Starting keepalived: [ OK ]
8、 關閉
[root@mysql03 keepalived-1.2.24]# service keepalived stop
Stopping keepalived: [ OK ] > OK,成功!



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2140850/,如需轉載,請註明出處,否則將追究法律責任。

相關文章