首页 > 系统相关 >Ubuntu安装keepalive

Ubuntu安装keepalive

时间:2023-11-22 18:45:02浏览次数:150  
标签:keepalived 192.168 id MASTER virtual Ubuntu 安装 节点 keepalive

前言

nginx使用docker部署;keepalived使用传统部署。 准备两台服务器:192.168.1.6 和192.168.1.7

部署keepalived

keepalived可以将多个无状态的单点通过虚拟IP(VIP)漂移的方式搭建成一个高可用服务

官网

下载

这里下载最新的版本V2.2.7:

  • 先决条件-安装基础依赖
  • #RHEL/CentOS
    yum install curl gcc openssl-devel libnl3-devel net-snmp-devel

    # Ubuntu
    apt-get install curl gcc libssl-dev libnl-3-dev libnl-genl-3-dev libsnmp-dev

    tar -xzvf keepalived-2.2.7.tar.gz

    cd keepalived-2.2.7
./configure --prefix=/usr/local/keepalived-2.2.7 --sysconf=/etc

prefix:keepalived安装位置
sysconf:keepalived配置文件位置,默认/etc

编译

make

安装

sudo make install

配置

创建/etc/keepalived/keepalived.conf配置文件:

主节点(MASTER)的配置:
global_defs {
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 1
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.100
    }
}

子节点(BACKUP)的配置:

global_defs {
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state BACKUP
    interface ens33
    virtual_router_id 2
    priority 90
    advert_int 1
    nopreemt
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.100
    }
}

解释:

state MASTER 表示该节点为主节点;

virtual_router_id 1 虚拟路由id,取值范围0-255,主节点(MASTER)和子节点(BACKUP)不要设置一致;

interface ens33 指定网卡名称,使用ip addr查看;

advert_int 1 主、子节点心跳频率,单位为秒

mcast_src_ip 192.168.1.6 指定节点的IP地址;

authentication 用户名密码,主节点(MASTER)和子节点(BACKUP)设置一致;

virtual_ipaddress { 192.168.1.100 }虚拟IP(VIP)地址,待会测试就是使用该IP地址访问;最好跟服务器同一个网段;主节点(MASTER)和子节点(BACKUP)设置一致;

添加到系统服务 创建 keepalived.service 文件
[Unit]
Description=Keepalived
After=network.target

[Service]
ExecStart=/usr/local/keepalived-2.2.7/sbin/keepalived -D
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
Type=forking

[Install]
WantedBy=multi-user.target
请确保将 ExecStart 的路径 /usr/local/keepalived-2.2.7/sbin/keepalived 替换为你 Keepalived 实际安装的路径 将创建的 keepalived.service 文件移动到 /etc/systemd/system/ 目录中:
sudo mv keepalived.service /etc/systemd/system/

重新加载 systemd 配置

sudo systemctl daemon-reload

启动 Keepalived 服务

sudo systemctl start keepalived

重启

systemctl restart keepalived  

停止

systemctl stop keepalived  

查看运行状态

systemctl status keepalived

开机自启

systemctl enable keepalived

 

主节点和子节点都启动keepalived通过VIP访问,默认访问到主节点

 

标签:keepalived,192.168,id,MASTER,virtual,Ubuntu,安装,节点,keepalive
From: https://www.cnblogs.com/Mr-shen/p/17850038.html

相关文章

  • STATA 安装FUZZY
    网上搜索到STATA模糊匹配fuzzy输入命令sscdescribef显示所有能通过ssc安装并且以f开头的所有命令在其中找出相关的具体命令发现有fuzzydid所以使用命令:sscinstallfuzzydid来安装若没有相关的,则只能从网上搜索相应的安装包手动安装PACKAGESyoucould-netdescribe-:f......
  • mujoco安装报错:mujoco_py/gl/eglplatform.h:99:10: fatal error: X11/Xlib.h: 没有那
     安装mujoco报错:mujoco_py/gl/eglplatform.h:99:10:fatalerror:X11/Xlib.h:没有那个文件或目录 修复方法:sudoaptinstalllibx11-dev   ......
  • mujoco安装报错:mujoco_py/cymj.pyx:67:5: Exception check on 'c_warning_callback' w
    参考:https://blog.csdn.net/weixin_49373427/article/details/131981583https://blog.csdn.net/CCCDeric/article/details/131788795  ======================   安装mujoco报错:     环境:python3.10  修复方法:pipinstallcython==3.0.0a10 ......
  • 家宽-6- ESXI下安装ikuai
    一: 下载ikuai的ISO镜像文件到电脑桌面下载链接:https://www.ikuai8.com/component/download(注意:32位的镜像至少分配1G内存给虚拟机,64位的至少4G内存)   二:登录esxi, 创建ikuai虚拟机,点击:虚拟机—创建/注册虚拟机   三:  选择创建新虚拟机,点击下一页  ......
  • CentOS7下安装SNMP服务
    1、安装SNMP服务yuminstallnet-snmpnet-snmp-utils2、启动SNMP服务systemctlstartsnmpd.service3、设置SNMP服务开机自启systemctlenablesnmpd.service4、更改团体名vi/etc/snmp/snmpd.conf#####First,mapthecommunityname"public"intoa"securityna......
  • k8s 高可用集群3:VIP:HAProxy、keepalived
    为何要使用负载均衡器VIP(HAProxy、keepalived)​k8sMaster初始化配置时,使用负载均衡器,可以将apiserver的请求转发到不同的机器上,避免一台服务器宕机,造成所有节点不可使用。如果不使用负载均衡器,先创建一个k8sMaster,然后再加入其他的k8sMaster,当第一台k8sMaster宕机时......
  • centos 7.9安装Prometheus
    一、Prometheus功能Prometheus在系统监控和警报方面非常强大,它适用于多种应用场景。以下是一些常见的Prometheus应用场景,以及具体的例子:性能监控:Prometheus可以用来监控服务器和应用程序的性能。比如,它可以收集和显示CPU使用率、内存使用、磁盘IO、网络流量等指标。......
  • k8s集群二进制安装部署
    1、前期规划主机规划IP地址主机名主机角色软件列表192.168.16.129k8s-master01masterkube-apiserver、kube-controller-manager、kube-scheduler、etcd、kubelet、haproxy、keepalived192.168.16.130k8s-master02masterkube-apiserver、kube-controller-man......
  • filerun docker方式安装(debian arm64, tinkerboard2s类似树莓派)
    启动mysqldockerrun-p3366:3306--namemysql57--privileged=true-eMYSQL_ROOT_PASSWORD=12345-v/mnt/docker/varlibmysql:/var/lib/mysql-dliupeng0518/mysql:5.7-arm64#redis命令dockerrun-itd--nameredis--privileged=true-p6380:6379redis--requir......
  • docker安装
     一、Dockerdesktop安装(1)首先要开启Hyper-V,开启操作参照https://blog.csdn.net/qq_44368508/article/details/126601570(2)DockerDesktop官方下载地址: https://docs.docker.com/desktop/install/windows-install/会很慢,直接找到其他下载地址,下载DockerDesktop4.24.1......