CentOS7编译安装keepalived实现自动漂移、高可用及开机启动

一、先安装依赖包
[root@haoding205-jq1 hd205]# yum install -y epel-release
[root@haoding205-jq1 hd205]# yum install -y gcc gcc-c++ openssl openssl-devel popt-devel kernel-devel libnfnetlink-devel

二、安装keepalived
[root@haoding205-jq1 hd205]# ll
总用量 7796
-rw-rw-r-- 1 haoding haoding 289380 9月 13 11:28 keepalived-1.2.24.tar.gz
[root@haoding205-jq1 hd205]# cp keepalived-1.2.24.tar.gz /usr/local/src/
[root@haoding205-jq1 hd205]# cd /usr/local/src/
[root@haoding205-jq1 src]# ll
总用量 284
-rw-r–r-- 1 root root 289380 9月 13 11:34 keepalived-1.2.24.tar.gz
[root@haoding205-jq1 src]# gzip -cdf keepalived-1.2.24.tar.gz | tar -xvf -
[root@haoding205-jq1 src]# ll
总用量 288
drwxrwxr-x 7 haoding haoding 4096 8月 29 2012 keepalived-1.2.24
-rw-r–r-- 1 root root 289380 9月 13 11:34 keepalived-1.2.24.tar.gz
[root@haoding205-jq1 src]# cd keepalived-1.2.24
[root@haoding205-jq1 keepalived-1.2.24]# ll
总用量 356
-rw-rw-r-- 1 haoding haoding 41 7月 19 2012 AUTHOR
drwxrwxr-x 2 haoding haoding 23 8月 29 2012 bin
-rw-rw-r-- 1 haoding haoding 107055 8月 29 2012 ChangeLog
-rwxrwxr-x 1 haoding haoding 165821 8月 14 2012 configure
-rw-rw-r-- 1 haoding haoding 9818 8月 14 2012 configure.in
-rw-rw-r-- 1 haoding haoding 830 7月 19 2012 CONTRIBUTORS
-rw-rw-r-- 1 haoding haoding 17982 7月 19 2012 COPYING
drwxrwxr-x 4 haoding haoding 107 8月 29 2012 doc
drwxrwxr-x 2 haoding haoding 4096 8月 29 2012 genhash
-rw-rw-r-- 1 haoding haoding 1601 7月 19 2012 INSTALL
-rwxrwxr-x 1 haoding haoding 5598 7月 19 2012 install-sh
drwxrwxr-x 9 haoding haoding 118 8月 29 2012 keepalived
-rw-rw-r-- 1 haoding haoding 5229 7月 19 2012 keepalived.spec.in
drwxrwxr-x 2 haoding haoding 4096 8月 29 2012 lib
-rw-rw-r-- 1 haoding haoding 1259 8月 14 2012 Makefile.in
-rw-rw-r-- 1 haoding haoding 1007 7月 19 2012 README
-rw-rw-r-- 1 haoding haoding 20 8月 29 2012 TODO
-rw-rw-r-- 1 haoding haoding 6 8月 29 2012 VERSION

[root@haoding205-jq1 keepalived-1.2.24]# pwd
/usr/local/src/keepalived-1.2.24
[root@haoding205-jq1 keepalived-1.2.24]# ./configure --prefix=/usr/local/keepalived

Use IPVS Framework : Yes
IPVS sync daemon support : Yes
Use VRRP Framework : Yes
# 必须看到如上的提示,说明配置正确,才能继续后面的安装

[root@haoding205-jq1 keepalived-1.2.24]# make

[root@haoding205-jq1 keepalived-1.2.24]# make install

[root@haoding205-jq1 keepalived-1.2.24]# find / -name keepalived.conf
/usr/local/src/keepalived-1.2.24/keepalived/etc/keepalived/keepalived.conf
/usr/local/keepalived/etc/keepalived/keepalived.conf
[root@haoding205-jq1 keepalived-1.2.24]# cat /usr/local/keepalived/etc/keepalived/keepalived.conf

! Configuration File for keepalivedglobal_defs {notification_email {acassen@firewall.locfailover@firewall.locsysadmin@firewall.loc}notification_email_from Alexandre.Cassen@firewall.locsmtp_server 192.168.200.1smtp_connect_timeout 30router_id LVS_DEVEL
}vrrp_instance VI_1 {state MASTERinterface eth0virtual_router_id 51priority 100advert_int 1authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {192.168.200.16192.168.200.17192.168.200.18}
}virtual_server 192.168.200.100 443 {delay_loop 6lb_algo rrlb_kind NATnat_mask 255.255.255.0persistence_timeout 50protocol TCPreal_server 192.168.201.100 443 {weight 1SSL_GET {url {path /digest ff20ad2481f97b1754ef3e12ecd3a9cc}url {path /mrtg/digest 9b3a0c85a887a256d6939da88aabd8cd}connect_timeout 3nb_get_retry 3delay_before_retry 3}}
}virtual_server 10.10.10.2 1358 {delay_loop 6lb_algo rrlb_kind NATpersistence_timeout 50protocol TCPsorry_server 192.168.200.200 1358real_server 192.168.200.2 1358 {weight 1HTTP_GET {url {path /testurl/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl2/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl3/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}connect_timeout 3nb_get_retry 3delay_before_retry 3}}real_server 192.168.200.3 1358 {weight 1HTTP_GET {url {path /testurl/test.jspdigest 640205b7b0fc66c1ea91c463fac6334c}url {path /testurl2/test.jspdigest 640205b7b0fc66c1ea91c463fac6334c}connect_timeout 3nb_get_retry 3delay_before_retry 3}}
}virtual_server 10.10.10.3 1358 {delay_loop 3lb_algo rrlb_kind NATnat_mask 255.255.255.0persistence_timeout 50protocol TCPreal_server 192.168.200.4 1358 {weight 1HTTP_GET {url {path /testurl/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl2/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl3/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}connect_timeout 3nb_get_retry 3delay_before_retry 3}}real_server 192.168.200.5 1358 {weight 1HTTP_GET {url {path /testurl/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl2/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl3/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}connect_timeout 3nb_get_retry 3delay_before_retry 3}}
}

[root@haoding205-jq1 keepalived-1.2.24]#

下面开始修改:
需要修改个keepalived.conf成自己想要的效果
[root@haoding205-jq2 keepalived]# vim /usr/local/keepalived/etc/keepalived/keepalived.conf

[root@haoding205-jq2 keepalived]# cat keepalived.conf

! Configuration File for keepalivedglobal_defs {notification_email {sysadmin@firewall.loc}notification_email_from Alexandre.Cassen@firewall.locsmtp_server 127.0.0.1smtp_connect_timeout 30router_id node2
}vrrp_instance VI_1 {state BACKUPinterface eno16456436984virtual_router_id 51priority 90advert_int 1authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {192.168.256.233}
}

cp -R /usr/local/keepalived/etc/keepalived /etc/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

将keepalived命令软连接到/usr/sbin下
ln -svf /usr/local/keepalived/sbin/keepalived /usr/sbin/

修改/usr/local/keepalived/etc/rc.d/init.d/keepalived中的程序路径
. /etc/sysconfig/keepalived
改为:
. /usr/local/keepalived/etc/sysconfig/keepalived

添加启动脚本且方便用service keepalived start/stop/restart管理

cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/keepalived

添加执行权限
chmod +x /etc/init.d/keepalived

开机启动
chkconfig keepalived on

[root@haoding205-jq2 keepalived]# find / -name keepalived.conf
/etc/keepalived/keepalived.conf
/usr/local/src/keepalived-1.2.24/keepalived/etc/keepalived/keepalived.conf
/usr/local/keepalived/etc/keepalived/keepalived.conf

启动服务
service keepalived start

OK了,只要haoding-jq1与haoding-jq2相互能ping通,且没有防火墙阻挡,相互是可以切换的。

上述keepalived安装包获取路径如下:
网盘下载地址:
https://pan.baidu.com/s/1COzCRL4wS6xJeTRCE_E9VA

我是昊鼎王五,我为自己带盐,有兴趣的朋友们可以扫码关注公众号,更多惊喜等待着你哦

CentOS7编译安装keepalived实现自动漂移、高可用及开机启动相关推荐

  1. Redis主从配置及通过Keepalived实现Redis自动切换高可用

    Redis主从配置及通过Keepalived实现Redis自动切换高可用 [日期:2014-07-23] 来源:Linux社区  作者:fuquanjun [字体:大 中 小] 一:环境介绍: Mas ...

  2. CentOS7 编译安装 gcc/c++ 9.1

    目录 文章目录 目录 CentOS7 编译安装 gcc/c++ 9.1 CentOS7 编译安装 gcc/c++ 9.1 $ yum -y install bzip2 $ yum -y install ...

  3. Centos7 编译安装git 报错 git-compat-util.h:14:2: error

    Centos7 编译安装git 报错 git-compat-util.h:14:2: error 环境: OS:CentOS7.9 Git版本: git-2.38.1 一.报错现象 [root@077 ...

  4. centOS7编译安装openssl并使用C接口

    centOS7编译安装openssl并使用C接口. 1.编译安装: 下载OpenSSL安装包 sudo wget http://www.openssl.org/source/openssl-1.1.0 ...

  5. ngnix+keepalived 实现N主高可用负载均衡web群集

    ngnix+keepalived 实现N主高可用负载均衡web群集 思路: 总结一下最近学习的nginx+keepalived 的负载均衡架构,发现linux的群集系统都是负载均衡层加服务器群组层,实 ...

  6. Keepalived实现LVS的高可用全解析

    Keepalived实现LVS的高可用 一.概念引入: keepalived作用:为lvs提供高可用集群 Keepalived的功能:1.将IP地址转移到另一个节点上:2.转移lvs规则:3.健康状况 ...

  7. Keepalived v1.3.5 高可用配置参数总结

    Keepalived v1.3.5 高可用配置参数总结 前言 官网介绍 gratuitous ARP包 VRRP包 VRRP实例 1 全局配置 1.1 全局定义(global_defs ) 1.2 静 ...

  8. 基于keepalived对redis做高可用配置---转载

    关于keepalived的详细介绍,请移步本人相关博客:http://wangfeng7399.blog.51cto.com/3518031/1405785 功能 ip地址 安装软件 主redis 1 ...

  9. keepalived+Nginx实现Web高可用

    环境准备:关闭防火墙.关闭SELinux.配置YUM源 一.部署keepalived服务 1.web4安装Keepalive [root@web4 ~]# yum -y install keepali ...

最新文章

  1. 解决element-ui表头错位的问题
  2. -heap 查看当前jvm堆栈信息_必知必会的JVM工具系列二,读懂会用jhat,jstack,jstatd,JConsole...
  3. ssm路径访问不到_ssm整合!!!
  4. 动态规划——Poj 1159 Palindrome
  5. shell的建立与执行实验报告_实验指导书--实验02 Linux Shell用户接口
  6. Executor家族的辨析
  7. 爬虫:Python爬虫学习笔记之Urllib库
  8. 面向对象的三大特性和五大原则
  9. 知识图谱中的结构信息建模
  10. 简述数学建模的过程_数学建模
  11. vscode英文界面转换为中文界面
  12. [Python3]利用tkinter为数独计算器编写GUI
  13. 【LaTex】6.4 listings高亮设置
  14. 蓝奏云分享链接打不开修改host
  15. 前端开发工程师必读书籍有哪些值得推荐?
  16. org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception
  17. 刷脸支付不需要掏手机扫码很是方便
  18. RedHat Linux 9.0的安装+下载+入门指南(图文并茂)
  19. 【路径规划】基于D*算法的移动机器人路径规划(Matlab代码实现)
  20. Dell XPS15 4K GTX1050 ubuntu16.04系统安装+分辨率设置

热门文章

  1. Android NDK开发配置NDK
  2. 信息学奥赛一本通(c++):2036:【例5.3】开关门
  3. Windows server 2003怎么安装iis?Windows server 2003安装IIS教程
  4. Staubli HCB08.7202/IC/JS3
  5. 记录一次oracle中count特别慢的解决方案
  6. Android逆向 某州 解密sign字段 so层 算法分析 Unidbg模拟执行
  7. 忽视警告_企业无法忽视移动革命的6个原因
  8. 第2章第6节:艺术字体的下载和安装和嵌入 [PowerPoint精美幻灯片实战教程]
  9. `Supimo` `Algorithm` 算法代码模板CodeTemplate
  10. 真正解决layer弹层遮罩挡住窗体的问题