keepalived是什么
keepalived直译就是保持存活,在网络里面就是保持在线了,也就是所谓的高可用或热备,用来防止单点故障(单点故障是指一旦某一点出现故障就会导致整个系统架构的不可用)的发生,keepalived实现的基础是vrrp,至于vrrp是什么请直接看这里,下面我们直接看应用吧。
keepalived使用
为了方便使用,写了一个基于ubuntu 16.04 server 的一键配置脚本,配置使用相关就在脚本里见吧
#!/bin/bash# nginx+keepalived 高可用一键脚本for ubuntu 16.04if [ $# -ne 4 ]; then echo "USAGE: $0 [MASTER|BACKUP] priority interface virtual_ipaddress" exit 0fiecho -e 'Installing nginx'apt-get install nginx -y > /dev/null 2<&1echo -e 'Installing keepalived'apt-get install keepalived -y > /dev/null 2<&1echo -e 'Configuring keepalived'if [ ! -e /etc/keepalived ];then mkdir /etc/keepalivedficat > /etc/keepalived/keepalived.conf </etc/keepalived/check_nginx.sh <