zoukankan      html  css  js  c++  java
  • 源码安装最新版keepalived,剥离日志出来并配置日志轮询

    安装

    yum install -y gcc openssl-devel popt-devel ipvsadm libnl3-devel net-snmp-devel libnl libnl-devel libnfnetlink-devel
    tar -zxvf keepalived-2.2.4.tar.gz
    cd keepalived-2.2.4
    ./configure --prefix=/usr/local/keepalived-2.2.4
    
    mkdir /etc/keepalived/
    cp /usr/local/keepalived-2.2.4/etc/keepalived/keepalived.conf /etc/keepalived/
    cp /usr/local/keepalived-2.2.4/etc/sysconfig/keepalived /etc/sysconfig/
    cp /usr/local/src/keepalived-2.2.4/keepalived/keepalived.service /etc/systemd/system/
    cp /usr/local/keepalived-2.2.4/sbin/keepalived /usr/sbin/
    cp /usr/local/src/keepalived-2.2.4/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.conf 
    local0.* /var/log/keepalived/keepalived.log
    
    systemctl restart rsyslog
    
    vim /etc/systemd/system/keepalived.service
    EnvironmentFile=/etc/sysconfig/keepalived
    
    systemctl daemon-reload
    
    systemctl start keepalived.service
    

    配置日志轮转

    vim /etc/logrotate.d/keepalived
    /var/log/keepalived/*.log {  
        su root root
        daily     
        rotate 7    
        create 0600 root root
        compress    
        delaycompress 
        missingok  
        dateext    
        sharedscripts
        postrotate   
          /bin/kill -HUP $(/bin/cat /var/run/syslogd.pid 2>/dev/null) &>/dev/null
        endscript
    }
    
    测试强制轮询
    /usr/sbin/logrotate -vf  /etc/logrotate.d/keepalived
    
    crontab  -e  #添加以下代码
    0 0 * * * /usr/sbin/logrotate -vf /etc/logrotate.d/keepalived   #每天凌晨定时执行脚本
    
  • 相关阅读:
    python3画聚类树图
    RedHat 7.0 系统 安装
    在VMware vSphere Client安装新的服务器(虚拟机)
    RedHat 7.0 VMware Tools 安装
    RedHat 7.0 Firefox浏览器 安装与更新
    Redhat 7.0 Opera浏览器 安装
    windows 8.1 IE11 和 windows 10 Edge & IE11 FlashPlayer 的安装与卸载
    在Windows和Mac上输入unicode字符
    已知IP 查看hostname
    RedHat 7.0 Chrome浏览器 安装
  • 原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/15239423.html
Copyright © 2011-2022 走看看