1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| #!/bin/bash
set -e dir="/usr/local/src" keepalived="keepalived-2.0.18" keepalived_v="keepalived-2.0.18.tar.gz" yilai="openssl openssl-devel wget vim lrzsz" keepalived_make(){ echo -e "\033[33m 此脚本容错率较低请不要重复执行 \033[0m" sleep 10 echo -e "\033[36m ===============开始拉取安装包:${keepalived_v} \033[0m" wget --no-check-certificate https://www.keepalived.org/software/${keepalived_v} echo -e "\033[36m 解压到: ${dir} \033[0m" tar -zxvf ./${keepalived_v} -C ${dir} yum install -y ${yilai} cd ${dir}/${keepalived}/ && ./configure --prefix=/usr/local/keepalived cd ${dir}/${keepalived}/ && make cd ${dir}/${keepalived}/ && make install [ $? = 0 ] && echo -e "\033[36m 编译安装${keepalived}成功 \033[0m" || echo -e "\033[33m 编译安装${keepalived}失败 \033[0m" } keepalived_system(){ echo -e "\033[36m ===============开始配置:${keepalived} \033[0m" [ -d "/etc/keepalived" ] || mkdir -p /etc/keepalived cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ cp /usr/local/keepalived/sbin/keepalived /etc/init.d/ systemctl daemon-reload systemctl start keepalived systemctl enable keepalived systemctl status keepalived echo -e "\033[36m 常用命令: systemctl restart keepalived systemctl status keepalived systemctl enable keepalived \033[0m" echo "keepalived版本是:" /usr/local/keepalived/sbin/keepalived -v } main(){ keepalived_make keepalived_system } main
|