Keeplived安装部署(单机双机)

news2024/11/9 10:09:18

Keeplived官网:https://www.keepalived.org/download.html

一 单机安装配置:

1.上传keepalived安装包并且安装

[root@master1 local]# tar -zxvf keepalived-2.2.8.tar.gz
[root@master1 local]# mv keepalived-2.2.8 keepalived
[root@master1 local]# chown root:root -R keepalived
[root@master1 local]# cd keepalived
[root@master1 keepalived]# ./configure --prefix=/usr/local/keepalived
[root@master1 keepalived]# make && make install
[root@master1 keepalived]# ls
aclocal.m4  autogen.sh  bin_install  build_setup  config.log     configure     CONTRIBUTORS  doc         Dockerfile.in  INSTALL     keepalived.spec     lib  Makefile     Makefile.in  README.md  share  TODO
AUTHOR      bin         build-aux    ChangeLog    config.status  configure.ac  COPYING       Dockerfile  etc            keepalived  keepalived.spec.in  m4   Makefile.am  README       sbin       snap   tools

2.修改配置

[root@master1 keepalived]# cd etc/keepalived/
[root@master1 keepalived]# ls
keepalived.conf.sample  samples
[root@master1 keepalived]# cp keepalived.conf.sample keepalived.conf
[root@master1 keepalived]# ls
keepalived.conf  keepalived.conf.sample  samples

3.添加系统启动项

vim /lib/systemd/system/keepalived.service
[Unit]
Description=LVS and VRRP High Availability Monitor
After=network-online.target syslog.target
Wants=network-online.target
Documentation=man:keepalived(8)
Documentation=man:keepalived.conf(5)
Documentation=man:genhash(1)
Documentation=https://keepalived.org

[Service]
Type=forking
PIDFile=/run/keepalived.pid
KillMode=process
EnvironmentFile=-/usr/local/keepalived/etc/sysconfig/keepalived
ExecStart=/usr/local/keepalived/sbin/keepalived  $KEEPALIVED_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
重新加载配置:
systemctl daemon-reload

设置开机启动:
cp /usr/local/keepalived/sbin/keepalived /etc/init.d/keepalived
systemctl enable keepalived

启动命令:
systemctl start keepalived
systemctl status keepalived
systemctl restart keepalived

启动和相关报错:

[root@master1 etc]# systemctl start keepalived
[root@master1 keepalived]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 四 2023-10-19 18:05:36 CST; 3s ago
     Docs: man:keepalived(8)
           man:keepalived.conf(5)
           man:genhash(1)
           https://keepalived.org
  Process: 110509 ExecStart=/usr/local/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 110510 (code=exited, status=2)
    Tasks: 0
   Memory: 0B
   CGroup: /system.slice/keepalived.service

10月 19 18:05:36 master1 Keepalived[110510]: NOTICE: setting config option max_auto_priority should result in better keepalived performance
10月 19 18:05:36 master1 Keepalived[110510]: Starting Healthcheck child process, pid=110511
10月 19 18:05:36 master1 Keepalived[110510]: Starting VRRP child process, pid=110512
10月 19 18:05:36 master1 Keepalived_healthcheckers[110511]: Initializing ipvs
10月 19 18:05:36 master1 systemd[1]: keepalived.service: main process exited, code=exited, status=2/INVALIDARGUMENT
10月 19 18:05:36 master1 systemd[1]: Unit keepalived.service entered failed state.
10月 19 18:05:36 master1 systemd[1]: keepalived.service failed.
10月 19 18:05:36 master1 Keepalived_healthcheckers[110511]: Gained quorum 1+0=1 <= 1 for VS [192.168.200.100]:tcp:443
10月 19 18:05:36 master1 Keepalived_healthcheckers[110511]: Gained quorum 1+0=1 <= 2 for VS [10.10.10.2]:tcp:1358
10月 19 18:05:36 master1 Keepalived_healthcheckers[110511]: Gained quorum 1+0=1 <= 2 for VS [10.10.10.3]:tcp:1358

需要修改虚拟ip等配置:

[root@master1 keepalived]# tail -f /var/log/messages

Oct 19 18:07:04 master1 grafana: logger=plugins.update.checker t=2023-10-19T18:07:04.752278809+08:00 level=info msg="Update check succeeded" duration=6.432745249s
Oct 19 18:07:06 master1 systemd: Starting LVS and VRRP High Availability Monitor...
Oct 19 18:07:06 master1 Keepalived[110735]: Starting Keepalived v2.2.8 (04/04,2023), git commit v2.2.7-154-g292b299e+
Oct 19 18:07:06 master1 Keepalived[110735]: Running on Linux 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 (built for Linux 3.10.0)
Oct 19 18:07:06 master1 Keepalived[110735]: Command line: '/usr/local/keepalived/sbin/keepalived' '-D'
Oct 19 18:07:06 master1 Keepalived[110735]: Opening file '/usr/local/keepalived/etc/keepalived/keepalived.conf'.
Oct 19 18:07:06 master1 Keepalived[110735]: Configuration file /usr/local/keepalived/etc/keepalived/keepalived.conf
Oct 19 18:07:06 master1 systemd: Started LVS and VRRP High Availability Monitor.
Oct 19 18:07:06 master1 Keepalived[110735]: (Line 15) WARNING - number '0' outside range [0.000001, 4294.967295]
Oct 19 18:07:06 master1 Keepalived[110735]: (Line 15) vrrp_garp_interval '0' is invalid
Oct 19 18:07:06 master1 Keepalived[110735]: (Line 16) WARNING - number '0' outside range [0.000001, 4294.967295]
Oct 19 18:07:06 master1 Keepalived[110735]: (Line 16) vrrp_gna_interval '0' is invalid
Oct 19 18:07:06 master1 Keepalived[110736]: NOTICE: setting config option max_auto_priority should result in better keepalived performance
Oct 19 18:07:06 master1 Keepalived[110736]: Starting Healthcheck child process, pid=110737
Oct 19 18:07:06 master1 Keepalived[110736]: Starting VRRP child process, pid=110738
Oct 19 18:07:06 master1 Keepalived_vrrp[110738]: Registering Kernel netlink reflector
Oct 19 18:07:06 master1 systemd: keepalived.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Oct 19 18:07:06 master1 Keepalived_vrrp[110738]: Registering Kernel netlink command channel
Oct 19 18:07:06 master1 systemd: Unit keepalived.service entered failed state.
Oct 19 18:07:06 master1 Keepalived_vrrp[110738]: (/usr/local/keepalived/etc/keepalived/keepalived.conf: Line 21) WARNING - interface eth0 for vrrp_instance VI_1 doesn't exist
Oct 19 18:07:06 master1 systemd: keepalived.service failed.
Oct 19 18:07:06 master1 Keepalived_vrrp[110738]: Non-existent interface specified in configuration
Oct 19 18:07:06 master1 Keepalived_vrrp[110738]: Stopped - used 0.000000 user time, 0.001848 system time
Oct 19 18:07:06 master1 Keepalived[110736]: pid 110738 exited with permanent error CONFIG. Terminating
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Gained quorum 1+0=1 <= 1 for VS [192.168.200.100]:tcp:443
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Gained quorum 1+0=1 <= 2 for VS [10.10.10.2]:tcp:1358
Oct 19 18:07:06 master1 Keepalived[110736]: CPU usage (self/children) user: 0.000000/0.000000 system: 0.001606/0.002565
Oct 19 18:07:06 master1 Keepalived[110736]: Stopped Keepalived v2.2.8 (04/04,2023), git commit v2.2.7-154-g292b299e+
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Gained quorum 1+0=1 <= 2 for VS [10.10.10.3]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Activating healthchecker for service [192.168.201.100]:tcp:443 for VS [192.168.200.100]:tcp:443
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Activating healthchecker for service [192.168.200.2]:tcp:1358 for VS [10.10.10.2]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Activating healthchecker for service [192.168.200.3]:tcp:1358 for VS [10.10.10.2]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Activating healthchecker for service [192.168.200.4]:tcp:1358 for VS [10.10.10.3]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Activating healthchecker for service [192.168.200.5]:tcp:1358 for VS [10.10.10.3]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Shutting down service [192.168.201.100]:tcp:443 from VS [192.168.200.100]:tcp:443
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Shutting down service [192.168.200.2]:tcp:1358 from VS [10.10.10.2]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Shutting down service [192.168.200.3]:tcp:1358 from VS [10.10.10.2]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Shutting down service [192.168.200.4]:tcp:1358 from VS [10.10.10.3]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Shutting down service [192.168.200.5]:tcp:1358 from VS [10.10.10.3]:tcp:1358
Oct 19 18:07:06 master1 Keepalived_healthcheckers[110737]: Stopped - used 0.001620 user time, 0.001620 system time
[root@master1 keepalived]# vim keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

vrrp_instance VI_1 {
    state MASTER
    interface ens32 #这个是根据ip address来的,就是本机的网卡名称
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.10.10.33 #这个地址是根据原来机器的ip来的,比如原ip:10.10.10.10,虚拟ip写成10.10.10.33或其他的
    }
}

 

测试:

1.需要安装nginx并且配置(nginx自己安装)

[root@master1 conf]# cd /usr/local/nginx/html
[root@master1 html]# vim test.html
this is a test url!

vim nginx.conf

 测试结果:

 二 双机安装配置:

待续...

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1114245.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

docker安装es分词插件ik详情步骤

1.下载ik查询 根据es版本去下载对应的版本&#xff0c;游览器中输入下面下载链接 https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.7.1/elasticsearch-analysis-ik-8.7.1.zip 2.2.若有对应版本跳过&#xff0c;若没有对应版本&#xff08;比如我需…

将语义分割的标注mask转为目标检测的bbox

1. 语义分割标签 1.1 labelme工具 语义分割的标签是利用labelme工具进行标注的,标注的样式如下: 1.2 语义分割的标签样式 2. 转换语义分割的标注到目标检测的bbox 实现步骤 (1) 利用标注的json文件生成mask图片(2) 在mask图片中找到目标的bbox矩形框的左上角点和右下角点(…

TCP通信-使用线程池优化

下面的通信架构存在问题&#xff1a; 客户端与服务端的线程模型是&#xff1a; N-N的关系&#xff0c;客户端并发越多&#xff0c;系统瘫痪的越快。 引入线程池处理多个客户端消息 代码实现 public class ClientDemo1 {public static void main(String[] args) {try {Syste…

C++是不是最容易产生猪队友的编程语言之一?

C是不是最容易产生猪队友的编程语言之一&#xff1f; 猪队友不是什么编程语言产生的&#xff0c;而是其做派本身就是猪队友&#xff0c;比如说自己一知半解的东西用得飞 起&#xff0c;而且不愿意深层次去学;再比如说不愿意写单元测试&#xff0c;甚至普通的测试都懒得做。最近…

在chrom浏览器安装Vue.js devtools插件,遇到恶意扩展程序字样,附百度网盘下载链接

遇到的问题 拖拽下载好的 Vue.js devtools 插件到谷歌扩展程序&#xff0c; 百度网盘下载地址 链接&#xff1a;https://pan.baidu.com/s/1FeK6pwc2UzRUUlMFN3rW5w?pwdw361 提取码&#xff1a;w361 提示&#xff1a; 解决办法 将Vue.js devtools 插件的后缀从.crx改为.zi…

C# 文件 校验:MD5、SHA1、SHA256、SHA384、SHA512、CRC32、CRC64

文件 校验 算法:MD5、SHA1、SHA256、SHA384、SHA512、CRC32、CRC64 编程语言:C# 文件属性内容 校验算法:MD5、SHA1、SHA256、SHA384、SHA512、CRC32、CRC64。 核心代码: using System; using System.Collections.Generic; using System; using System.Text; using Syst…

提升APP的用户体验的方法

提高APP的用户体验&#xff08;User Experience&#xff0c;简称UX&#xff09;对于吸引用户、提高用户满意度和应用的成功至关重要。以下是一些方法&#xff0c;可以帮助改善APP的用户体验&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软件外包…

K8s 概念及组件

K8s 的全称为Kubernetes&#xff0c;是一种开源的容器编排平台&#xff0c;用于自动化部署以及扩展和管理容器化的应用程序&#xff0c;它提供了一种容器编排和管理的方式&#xff0c;可以帮助开发人员更轻松的管理容器化的应用程序&#xff0c;并且提供了一种跨多个主机的自动…

内存爆炸、CPU100%问题定位

目录 一、内存爆炸相关1、关于-Xms(最小堆内存)和-Xmx(最大堆内存)2、JVM初始化时申请实际物理内存3、OutOfMemory问题排查(1) 堆内存溢出排查(2) 堆外内存溢出排查 二、CPU 100及死锁问题定位1、CPU 100问题排查(1) 找到程序对应进程号(2) 查找进程对应的线程编号(3)查看线程堆…

根据Excel表格数据去修改数据库数据

一、背景 项目上线&#xff0c;实施任务发来一份Excel表格数据 需要将供应商和生产厂商进行绑定&#xff0c;因为数据过多&#xff0c;实施人员一个个绑定时间成本过高&#xff0c;想让开发给出一个脚本。 二、操作 比如这些数据 生产厂商为A 供应商为B 以update 语句为例 …

基于Vertx实现可配置及可扩展的IOT服务

搭建框架的目标 相信写过IOT服务的伙伴应该知道&#xff0c;面对各种千奇百怪的通信协议&#xff0c;特别是16进制报文的协议&#xff0c;有些协议看的确实有点让人头疼。但这些协议中也有很多共性&#xff0c;不必针对每过协议都把一些业务无关的代码再撸一遍。 搭建这个项目主…

【Javascript】‘var‘ is used instead of ‘let‘ or ‘const‘

解决&#xff1a; 设置完之后,var 就不会再出现黄色波浪线警告

普通二维码跳转微信小程序实战

简介 服务端springboot项目,前端基于uniapp的微信小程序,要求扫描二维码之后进入到小程序指定页面,下面记录一下实现过程以及过程中遇到的问题. 实现过程 下面是成功跳转的配置截图: 首先说下二维码规则,这个地方需要填写扫描二维码之后打开的地址,这个地址在我的项目里…

Keil实现Flash升级跳转(STM32/GD32/HC32)

编写BOOT程序&#xff0c;和APP程序。 BOOT程序检查OTA参数&#xff0c;执行OTA升级&#xff0c;然后跳转到APP代码。 记录一下跳转APP需要修改得东西&#xff1a; 1、BOOT程序 修改跳转地址 先检查APP地址是否有效 然后关闭外设 反初始化 设置MSP指针&#xff0c;进行跳转 …

多商户自营连锁小程序商城的作用是什么

近几年&#xff0c;线上线下经营压力很大&#xff0c;不少商家都希望通过数字化转型实现破局或增长&#xff0c;单店管理力度相对容易些&#xff0c;但如果是连锁门店&#xff0c;近几年则相对风险大些&#xff0c;但从2020年至今依然有不少品牌选择扩店&#xff0c;增加连锁规…

vue 组件封装 综合案例

vue 组件封装 综合案例 **创建 工程&#xff1a; H:\java_work\java_springboot\vue_study ctrl按住不放 右键 悬着 powershell H:\java_work\java_springboot\js_study\Vue2_3入门到实战-配套资料\01-随堂代码素材\day05\准备代码\11-综合案例-商品列表 vue --version vue c…

深入探索Sharding JDBC:分库分表的利器

随着互联网应用的不断发展和用户量的不断增加&#xff0c;传统的数据库在应对高并发和大数据量的场景下面临着巨大的挑战。为了解决这一问题&#xff0c;分库分表成为了一个非常流行的方案。分库分表主流的技术包括MyCat和Sharding JDBC。我们来通过一张图来了解这两者有什么区…

38 WEB漏洞-反序列化之PHPJAVA全解(下)

目录 Java中的API实现序列化和反序列化演示案例WebGoat_Javaweb靶场反序列化测试2020-网鼎杯-朱雀组-Web-think java真题复现 文章参考&#xff1a; https://www.cnblogs.com/zhengna/p/15737517.html https://blog.csdn.net/MCTSOG/article/details/123819548 ysoserial生成攻…

CC攻击和其防御策略

CC攻击简介 CC攻击&#xff0c;又称为Challenge Collapsar攻击&#xff0c;是一种常见的DDoS&#xff08;分布式拒绝服务&#xff09;攻击方式&#xff0c;旨在使Web服务在第七层协议层面遭受攻击。攻击者并不需要大量的肉鸡来实施CC攻击&#xff0c;相反&#xff0c;他们使用…

Flyway Desktop updated

Flyway Desktop updated 为比较工件序列化和反序列化添加了额外的调试日志记录。 Flyway Desktop现在将记住以前用于创建项目和匹配克隆的位置。 新的脱机许可工作流现在已在Microsoft Windows上启用。 现在&#xff0c;在配置目标数据库列表时&#xff0c;环境ID是可见的。 现…