32 keepalived

配置环境

node1:192.168.1.72

node2:192.168.1.73

1、node1、node2配置主机名、同步时间、通过hosts文件解析各主机名

2、各节点安装keepalived

yum -y install keepalived

3、配置node1

[[email protected] ~]# cd /etc/keepalived/

[[email protected] keepalived]# cp keepalived.conf{,.bak}

[[email protected] keepalived]# vim keepalived.conf

! Configuration File for keepalived

global_defs {

notification_email {

[email protected]

}

notification_email_from [email protected]

smtp_server 127.0.0.1

smtp_connect_timeout 30

router_id node1

vrrp_mcast_group4 224.18.0.100

}

vrrp_script chk_mantaince {

script "[[ -f /etc/keepalived/down ]] && exit 1 || exit 0"

interval 1

weight -2

}

vrrp_instance VI_1 {

state MASTER

interface eno16777736

virtual_router_id 51

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 3b8fd970

}

virtual_ipaddress {

192.168.1.80/24

}

track_script    {

chk_maintanance

}

}

4、配置node2

[[email protected] keepalived]# scp keepalived.conf node2:/etc/keepalived/

[[email protected] ~]# cd /etc/keepalived/

[[email protected] keepalived]# vim keepalived.conf

1、修改

router_id node1

router_id node2

2、修改

state MASTER

state BACKUP

3、修改

priority 100

priority 99

5、启动

[[email protected] keepalived]# systemctl start keepalived.service

[[email protected] keepalived]# systemctl start keepalived.service

6、添加日志储存文件

[[email protected] keepalived]# vim /etc/sysconfig/keepalived

修改

KEEPALIVED_OPTIONS="-D"

KEEPALIVED_OPTIONS="-D -S 3"

[[email protected] keepalived]# vim /etc/rsyslog.conf

添加一行

local3.*                                                /var/log/keepalived.log

[[email protected] keepalived]# systemctl restart rsyslog.service

[[email protected] keepalived]# systemctl restart keepalived.service

时间: 2024-09-29 10:27:58

32 keepalived的相关文章

keepalived工作原理

keepalived是一款c语言写的实现在linux系统上实现负载均衡和高可用的软件.它遵从于GNU是一款优秀的开源软件. 一:两个关键词的解释 1:负载均衡 keepalived内置了对ipvs函数的调用支持.可以直接在keepalived中按照语法配置ipvs然后keepalived就可以实现对ipvs的配置. 2:高可用 keepalived是以VRRP(Virtual Router Redundancy Protocol)协议为实现基础的即虚拟路由冗余协议.虚拟路由冗余协议可以认为是实现

ansible-playbook自动化安装Keepalived实现Nginx服务双机热备自动化配置

脚本实现通过ansible-playbook自动化安装Keepalived和配置,主要解决问题如下: Keepalived自动化安装: keepalived_vrid配置,自动根据vip获取最后一段作为vrid,确保同一网段不会出现vrid冲突导致HA切换失败的问题: 自动配置Keepalived: HA检测脚本自定义,根据脚本内容,来做redis或nginx或其他软件的双机热备: 自动配置vip给Keepalived 设置Keepalived开机启动,加入系统服务: Keepalived安装脚

文件共享存储&&主备实时热备实现方案

一.方案图 该方案可以解决nfs服务器的单点故障问题,也可以解决数据的备份难题,可以作为公司从nfs文件系统-->分布式存储系统的过渡解决方案.由于我公司从初创到至今,用户的产生数据量与日俱增,在探讨了现有nfs文件系统不能解决现有问题以及现阶段部署分布式存储系统的大量财力.人力的基础上,提出这么一个可以过度的方案.使用LVM磁盘管理技术可以很方便的在每个主机上进行磁盘的扩容.辅助监控监本智能监测服务状态,节省了运维成本! 二.配置步骤 1.LVM管理(主机.备机) 创建分区:fdisk /de

keepalived+nginx

高集成:keepalived 负载均衡:nginx 1.服务器IP Client: 172.25.254.25 Keepalived+Nginx1: 172.25.254.115 Vip: 172.25.254.100 Keepalived+Nginx2: 172.25.254.215 Vip: 172.25.254.100 二.安装 1.安装keepalived yum install keepalived 2.编译安装Nginx [[email protected] ~]#useradd -

Keepalived+Nginx实现高可用(HA)

keepalived的HA分为抢占模式和非抢占模式,抢占模式即MASTER从故障中恢复后,会将VIP从BACKUP节点中抢占过来.非抢占模式即MASTER恢复后不抢占BACKUP升级为MASTER后的VIP.下面分别介绍CentOS7下抢占模式和非抢占模式的配置方式: 1.方案规划 VIP IP 主机名 Nginx端口 192.168.1.210 192.168.1.201 nginx-01 80 192.168.1.210 192.168.1.202 nginx-02 80 两台服务器的VIP

Keepalived基本设置及IPVS扩展

Keepalived基本设置及IPVS扩展 IP地址高可用 [[email protected] ~]# yum install keepalived -y (一般系统光盘就有) [[email protected] ~]# yum install keepalived -y [[email protected] ~]# rpm -q keepalived keepalived-1.2.13-4.el6.x86_64 [[email protected] ~]# cd /etc/keepaliv

keepalived简单案例

---------------------------------- 一.前言 二.环境 三.Keepalived体系架构 四.安装Keepalived 五.案例配置 ---------------------------------- 一.前言 keepalived是一个类似于layer3,4&5交换机制的软件,也就是我们平时说的第3层.第4层和第5层交换.Keepalived的作用是检测web服务器的状态,如果有一台web服务器死机,或工作出现故障,Keepalived将检测到,并将有故障的

nginx+keepalived的高可用负载均衡集群构建

实验架构图: 实验环境 Nginx和Keepalived原理介绍 参考博客:http://467754239.blog.51cto.com/4878013/1541421 1.nginx Nginx进程基于于Master+Slave(worker)多进程模型,自身具有非常稳定的子进程管理功能.在Master进程分配模式下,Master进程永远不进行业务处理,只是进行任务分发, 从而达到Master进程的存活高可靠性,Slave(worker)进程所有的业务信号都 由主进程发出,Slave(wor

MySQL keepalived 双主.md

MySQL keepalived 双主搭建 环境说明 系统 IP 主机名 mysql keepalived VIP CentOS 6.8 192.168.197.61 C6-node1 5.6.36 1.2.13 192.168.197.88 CentOS 6.8 192.168.197.62 C6-node2 5.6.36 1.2.13 192.168.197.88 安装MySQL双主 C6-node1 MySQL的安装及初始化这里不做详细介绍,下面贴出node1的my.cnf的配置文件: [