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. Linux 开机、重启和用户登录注销、用户管理

    关机&重启命令 shutdown shutdown -h now:表示立即关机 shutdown -h 1:表示1分钟后关机 shutdown -r now:立即重启 halt 就是直接使用, ...

  2. echart 单选legend 并排序

    java代码 List<Map<String, Object>> AllList = null; JSONArray jsonArray = JSONArray.fromObj ...

  3. MySQL的or/in/union与索引优化

    转载自:MySQL的or/in/union与索引优化 https://blog.csdn.net/zhangweiwei2020/article/details/80005590 假设订单业务表结构为 ...

  4. NYOJ737石子合并(二)-(区间dp)

    题目描述:     有N堆石子排成一排,每堆石子有一定的数量.现要将N堆石子并成为一堆.合并的过程只能每次将相邻的两堆石子堆成一堆,每次合并花费的代价为这两堆石子的和,经过N-1次合并后成为一堆.求出 ...

  5. es6入门set和map

    ES6提供了新的数据结构Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set函数可以接受一个数组(或类似数组的对象)作为参数,用来初始化. var set = new Set([1, ...

  6. JDBC缺点分析

    * JDBC代码繁琐,每一次JDBC都需要编写“同样”的六步. * sql不能配置,在JDBC编程中sql语句是写在java源程序当中的,sql语句经常会发生改变(业务发生了改变),sql改变之后,需 ...

  7. Tomcat常用设置及安全管理规范

    前言 随着公司内部使用Tomcat作为web应用服务器的规模越来越大,为保证Tomcat的配置安全,防止信息泄露,恶性攻击以及配置的安全规范,特制定此Tomcat安全配置规范.注意:  本文章从htt ...

  8. MariaDB ColumnStore初探(1):安装、使用及测试

    相信大家在对接BI数据报表部门有很深刻的体验,高大上的复杂SQL关联JOIN十几张表在InnoDB里跑起来,会让你酸爽到死.它的出现正是解决这个问题,DBA能不能轻松愉快地玩耍,就要靠它了,“神州行我 ...

  9. PTA 1067 Sort with Swap(0, i) (25 分)(思维)

    传送门:点我 Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasin ...

  10. 转)Ubuntu16.04下安装DDD(Data Display Debugger)

    以下转自:http://www.linuxdiyf.com/linux/26393.html   前两天在Linux论坛偶然间看到了DDD这个软件,根据介绍是一个gdb界面化的调试软件,这正是我找了好 ...