1、下載(原文連接:http://www.studyshare.cn/blog-front//software/details/1158/0 )nginx
網盤下載:https://pan.baidu.com/s/1lK0HPBHvjy79pM0Zl-i1tQ 提取碼:o1vdcentos
2、安裝服務器
一、使用ftp工具或者liunx系統窗口中使用快捷鍵alt+p拖拽上傳下載的gz安裝包網絡
二、解壓工具
命令:tar -zxvf keepalived-1.3.4.tar.gzrouter
三、安裝blog
(1)命令:cd keepalived-1.3.4 //進入keepalived-1.3.4目錄接口
(2)命令:./configure --prefix=/usr/local/keepalived --sysconf=/usr/local/keepalived進程
配置解釋:ip
--prefix=/usr/local/keepalived :指定安裝在/usr/local/keepalived 路徑下
--sysconf=/usr/local/keepalived : 指定keepalived的conf配置文件路徑
出現keepalived/dbus/Makefile 表示配置成功,以下圖所示:
(3)命令:make && make install //編譯+安裝
3、修改配置
命令:cd /usr/local/keepalived/keepalived
命令:vi keepalived.conf
關鍵配置:
global_defs { #全局配置
router_id nginx_backup #表示運行Keepalived服務器的一個標識,惟一的
}
vrrp_instance VI_1 { #vrrp 實例定義部分
state BACKUP # 指定keepalived的角色,MASTER爲主,BACKUP爲備
interface eth0 # 當前進行vrrp通信的網絡接口卡(當前centos的網卡)
virtual_router_id 66 # 虛擬路由編號,主從要一致
priority 100 # 優先級,數值越大,獲取處理請求的優先級越高
advert_int 1 # 檢查間隔,默認爲1s(vrrp組播週期秒數)
authentication {
auth_type PASS #設置驗證類型和密碼,MASTER和BACKUP必須使用相同的密碼才能正常通訊
auth_pass 1111
}
track_script {
chk_http_port #(調用檢測腳本)
}
virtual_ipaddress {
192.168.244.200 # 定義虛擬ip(VIP),可多設,每行一個
}
}
global_defs { #全局配置
router_id LVS_1
}
4、啓動中止
命令:cd /usr/local/keepalived #進入keepalived安裝目錄
命令:./sbin/keepalived #啓動
命令:ps -ef|grep keepalived , kill -9 keepalived進程號 #中止
原創文章,轉載請註明出處,更多技術文章:http://www.studyshare.cn/blog-front/blog/index