Linux下keepalived下载安装与配置
一、下载(原文链接:http://www.studyshare.cn/blog-front//software/details/1158/0 )
网盘下载:https://pan.baidu.com/s/1lk0hpbhvjy79pm0zl-i1tq 提取码:o1vd
二、安装
1、使用ftp工具或者liunx系统窗口中使用快捷键alt+p拖拽上传下载的gz安装包
2、解压
命令:tar -zxvf keepalived-1.3.4.tar.gz
3、安装
(1)命令:cd keepalived-1.3.4 //进入keepalived-1.3.4目录
(2)命令:./configure --prefix=/usr/local/keepalived --sysconf=/usr/local/keepalived
配置解释:
--prefix=/usr/local/keepalived :指定安装在/usr/local/keepalived 路径下
--sysconf=/usr/local/keepalived : 指定keepalived的conf配置文件路径
出现keepalived/dbus/makefile 表示配置成功,如下图所示:
(3)命令:make && make install //编译+安装
三、修改配置
命令: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
}
四、启动停止
命令:cd /usr/local/keepalived #进入keepalived安装目录
命令:./sbin/keepalived #启动
命令:ps -ef|grep keepalived , kill -9 keepalived进程号 #停止
原创文章,转载请注明出处,更多技术文章:http://www.studyshare.cn/blog-front/blog/index