CentOS7源码安装部署keepalived-2.0.15

 

 

 

安装依赖包

yum install gcc openssl-devel libnl3-devel pcre-devel

选择安装net-snmp-devel libnfnetlink-devel

下载源码包

wget https://www.keepalived.org/software/keepalived-2.0.15.tar.gz
tar xf keepalived-2.0.15.tar.gz
cd keepalived-2.0.15
./configure --prefix=/usr/local/keepalived-2.0.15 
make && make install
ln -s /usr/local/keepalived-2.0.15 /usr/local/keepalived

mkdir /etc/keepalived/


cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived-2.0.15/etc/sysconfig/keepalived /etc/sysconfig/
cp /root/keepalived-2.0.15/keepalived/keepalived.service /etc/systemd/system/
ln -s /usr/local/keepalived-2.0.15/sbin/keepalived /usr/sbin/
# 这个从keepalived源码目录复制,安装目录中没有
cp /root/keepalived-2.0.15/keepalived/etc/init.d/keepalived /etc/init.d/ 
chmod 755 /etc/init.d/keepalived
systemctl enable keepalived.service
mkdir /var/log/keepalived/
vim /etc/sysconfig/keepalived
KEEPALIVED_OPTIONS="-D -d -S 0"
vim /etc/rsyslog.d/keepalived.conf
local0.* /var/log/keepalived/keepalived.log

systemctl restart rsyslog

systemctl start keepalived.service

配置日志轮转

/var/log/keepalived/*.log {  #切分的两个文件名
    daily        #按天切分
    rotate 7     #保留7份
    create 0644 haproxy haproxy  #创建新文件的权限、用户、用户组
    compress     #压缩旧日志
    delaycompress  #延迟一天压缩
    missingok    #忽略文件不存在的错误
    dateext      #旧日志加上日志后缀
    sharedscripts  #切分后的重启脚本只运行一次
    postrotate   #切分后运行脚本重载rsyslog,让rsyslog向新的日志文件中输出日志
    /bin/kill -HUP $(/bin/cat /var/run/syslogd.pid 2>/dev/null) &>/dev/null
    endscript
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值