yum install -y gcc gcc-c++ openssl openssl-devel

目前keepalived最新版本下载:
[root@rhel ~]#wget -c http://www.keepalived.org/software/keepalived-1.2.12.tar.gz
[root@rhel ~]# tar zxvf keepalived-1.2.12.tar.gz
[root@rhel ~]# cd keepalived-1.2.12
安装编译环境:
[root@rhel ~]# yum install -y gcc gcc-c++ openssl openssl-devel
1

//指定安装路径
[root@rhel keepalived-1.2.12]# ./configure --prefix=/usr/local/keepalived --sysconf=/etc

[root@rhel keepalived-1.2.12]# make && make install //安装
将keepalived命令软连接到/usr/bin下
[root@rhel keepalived-1.2.12]# ln -s /usr/local/keepalived/sbin/keepalived /usr/bin/keepalived

添加启动脚本且方便用service keepalived start/stop/restart管理(如果没有init.d/keepalived则从源码目录拷贝)
[root@rhel keepalived-1.2.12]# cp /keepalived/keepalived-2.0.8/keepalived/etc/init.d/keepalived /etc/init.d/keepalived
[root@rhel keepalived-1.2.12]# chmod 755 /etc/init.d/keepalived //添加执行权限
[root@rhel keepalived-1.2.12]# chkconfig keepalived on //开机启动

修改/etc/init.d/keepalived中的程序路径
# Source configuration file (we set KEEPALIVED_OPTIONS there)
. /etc/sysconfig/keepalived

改为:
# Source configuration file (we set KEEPALIVED_OPTIONS there)
. /keepalived/keepalived-2.0.8/keepalived/etc/sysconfig/keepalived

默认情况下,keepalived 会读取 /etc/keepalived 下keepalived.conf 文件
如果没有建立这个文件,keepalived也不会报错,但是会发现,所创建的关于keepalived的相关参数根本就没有生效。
[root@rhel keepalived-1.2.12]# mkdir /etc/keepalived
[root@rhel keepalived-1.2.12]# ln -s /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf

keepalived.conf

! Configuration File for keepalived

global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_script Monitor_Nginx {
script "/monitor_nginx.sh"
interval 2
weight 2
}

vrrp_instance VI_1 {
state MASTER
interface ens192
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}

track_script {
Monitor_Nginx #(调用nginx进程检测脚本)
}

virtual_ipaddress {
172.16.9.30
}

}

monitor_nginx.sh

#!/bin/bash
if [ "$(ps -ef | grep "nginx: master process"| grep -v grep )" == "" ]
then
killall keepalived
fi
 
chmod 777 /monitor_nginx.sh
sed -i 's/\r$//' /monitor_nginx.sh

启动测试:
[root@rhel keepalived-1.2.12]# service keepalived restart
停止 keepalived: [确定]
启动 keepalived: [确定]

安装完成

service keepalived restart
service keepalived stop
service keepalived start

systemctl start keepalived
systemctl restart keepalived
systemctl stop keepalived

KeepAlived+Nginx 安装的更多相关文章

  1. LVS+Nginx(LVS + Keepalived + Nginx安装及配置)

    (也可以每个nginx都挂在上所有的应用服务器)  nginx大家都在用,估计也很熟悉了,在做负载均衡时很好用,安装简单.配置简单.相关材料也特别多. lvs是国内的章文嵩博士的大作,比nginx被广 ...

  2. LVS + Keepalived + Nginx安装及配置

    1.概述 上篇文章<架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层>(http://blog.csdn.net/yinwenjie/artic ...

  3. 架构设计:负载均衡层设计方案(7)——LVS + Keepalived + Nginx安装及配置

    1.概述 上篇文章<架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层>(http://blog.csdn.net/yinwenjie/artic ...

  4. keepalived+nginx安装配置

    软件版本号: pcre8.36 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz keepalived1.2 ...

  5. keepalived+nginx安装

    安装keepalived+nginx做为公司服务器前端高可用反向代理安装nginx 1.yum install -y pcre pcre-devel gcc-c++ zlib zlib-devel o ...

  6. keepalived与nginx安装

    目的: 当用户请求访问时,会通过nginx来访问web服务应用,因此我们必须要保证nginx的高可用,要保证nginx的高可用,我们需要通过keepalived来监控nginx,并对外提供1个虚拟的v ...

  7. Nginx+keepalived 脚本安装主从双机热备自动切换解决方案

    Nginx+keepalived 脚本安装主从双机热备自动切换解决方案 2013-07-02 19:24:13 标签:filesnginx keepalived 原创作品,允许转载,转载时请务必以超链 ...

  8. centos安装与配置keepalived+nginx高可用

    一.安装启动keepalived 1.下载keepalived 在centos系统中,用wget下载最新版本: mkdir tool cd tool wget https://www.keepaliv ...

  9. 架构设计:负载均衡层设计方案(2)——Nginx安装

    来源:http://blog.csdn.net/yinwenjie(未经允许严禁用于商业用途!) 目录(?)[-] Nginx重要算法介绍 1一致性Hash算法 2轮询与加权轮询 Nginx的安装 1 ...

随机推荐

  1. Music Recommendation System with User-based and Item-based Collaborative Filtering Technique(使用基于用户及基于物品的协同过滤技术的音乐推荐系统)【更新】

    摘要: 大数据催生了互联网,电子商务,也导致了信息过载.信息过载的问题可以由推荐系统来解决.推荐系统可以提供选择新产品(电影,音乐等)的建议.这篇论文介绍了一个音乐推荐系统,它会根据用户的历史行为和口 ...

  2. Django Forms 表单

    环境 python 3.7 服务端  views.py from django import forms # 引入 froms 模块 from django.forms import widgets ...

  3. Azkaban安装及分布式部署(multiple-executor)

    参考文章:https://blog.csdn.net/weixin_35852328/article/details/79327996 官网:https://azkaban.readthedocs.i ...

  4. linux 的那些hung 检测机制

    在dmesg中,看到如下信息: [:: seconds [:: seconds [:af: seconds [:af: seconds [:: seconds [:3b: seconds [:: se ...

  5. com.mysql.jdbc.Connection.isValid(I)Z

    spring boot项目 运行提示这个错误的时候 只需要配置

  6. Ado.net之对数据库的增删改查

    一.了解Command对象 1.Command对象:封装了所有对外部数据源的操作,包括增删改查和执行存储过程,并在执行完成后返回合适的结果,同Connection一样,对于不同的数据源,Ado.net ...

  7. Vue.js组件之间的调用

    index.html: <div id="app"></div> 运行完index.html之后自动寻找运行main.js文件 main.js: impor ...

  8. 记账本,C,Github,entity

    package entity; public class Category { private int id; private String name; private int recordNumbe ...

  9. Setting up Scatter for Web Applications

    [Setting up Scatter for Web Applications] If you are still using scatter-js please move over to scat ...

  10. Linux shell 信号继承

    shell中,向进程发送信号多多通过ctrl键加上一些功能键来实现,这里是常见的Ctrl组合键及其意义: 组合键 信号类型 意义 Ctrl+C INT信号,即interrupt信号 停止运行当前的作业 ...