keepalived指定日志文件方法

首先查看keepalived命令的参数,-S指定syslog的facility。

   
   
   
   
  1. /usr/local/keepalived/sbin/keepalived --vrrp               -P    Only run with VRRP subsystem. 
  2. /usr/local/keepalived/sbin/keepalived --check              -C    Only run with Health-checker subsystem. 
  3. /usr/local/keepalived/sbin/keepalived --dont-release-vrrp  -V    Dont remove VRRP VIPs & VROUTEs on daemon stop. 
  4. /usr/local/keepalived/sbin/keepalived --dont-release-ipvs  -I    Dont remove IPVS topology on daemon stop. 
  5. /usr/local/keepalived/sbin/keepalived --dont-fork          -n    Dont fork the daemon process. 
  6. /usr/local/keepalived/sbin/keepalived --use-file           -f    Use the specified configuration file. 
  7.                               Default is /etc/keepalived/keepalived.conf. 
  8. /usr/local/keepalived/sbin/keepalived --dump-conf          -d    Dump the configuration data. 
  9. /usr/local/keepalived/sbin/keepalived --log-console        -l    Log message to local console. 
  10. /usr/local/keepalived/sbin/keepalived --log-detail         -D    Detailed log messages. 
  11. /usr/local/keepalived/sbin/keepalived --log-facility       -S    0-7 Set syslog facility to LOG_LOCAL[0-7]. (default=LOG_DAEMON
  12. /usr/local/keepalived/sbin/keepalived --help               -h    Display this short inlined help screen. 
  13. /usr/local/keepalived/sbin/keepalived --version            -v    Display the version number 
  14. /usr/local/keepalived/sbin/keepalived --pid                -p    pidfile 
  15. /usr/local/keepalived/sbin/keepalived --checkers_pid       -c    checkers pidfile 
  16. /usr/local/keepalived/sbin/keepalived --vrrp_pid           -r    vrrp pidfile 

然后通过如下命令启动keepalived,

   
   
   
   
  1. [root@LVS02 ~]# /usr/local/keepalived/sbin/keepalived -d -D -S 0 

或者修改/etc/sysconfig/keepalived,然后用service来启动。

   
   
   
   
  1. [root@LVS02 ~]# cat /etc/sysconfig/keepalived  
  2. # Options for keepalived. See `keepalived --help' output and keepalived(8) and 
  3. # keepalived.conf(5) man pages for a list of all options. Here are the most 
  4. # common ones : 
  5. # --vrrp               -P    Only run with VRRP subsystem. 
  6. # --check              -C    Only run with Health-checker subsystem. 
  7. # --dont-release-vrrp  -V    Dont remove VRRP VIPs & VROUTEs on daemon stop. 
  8. # --dont-release-ipvs  -I    Dont remove IPVS topology on daemon stop. 
  9. # --dump-conf          -d    Dump the configuration data. 
  10. # --log-detail         -D    Detailed log messages. 
  11. # --log-facility       -S    0-7 Set local syslog facility (default=LOG_DAEMON
  12.  
  13. KEEPALIVED_OPTIONS="-D -d -S 0" 
  14.  
  15. [root@LVS02 ~]# service keepalived start

最后设置syslog,修改/etc/syslog.conf.

   
   
   
   
  1. root@LVS02 ~]# cat /etc/syslog.conf 
  2. # Log all kernel messages to the console. 
  3. # Logging much else clutters up the screen. 
  4. #kern.*                         /dev/console 
  5.  
  6. # Log anything (except mail) of level info or higher. 
  7. # Don't log private authentication messages! 
  8. *.info;mail.none;authpriv.none;cron.none        /var/log/messages 
  9.  
  10. # The authpriv file has restricted access. 
  11. authpriv.*                      /var/log/secure 
  12.  
  13. # Log all the mail messages in one place. 
  14. mail.*                          -/var/log/maillog 
  15.  
  16.  
  17. # Log cron stuff 
  18. cron.*                          /var/log/cron 
  19.  
  20. # Everybody gets emergency messages 
  21. *.emerg                         * 
  22.  
  23. # Save news errors of level crit and higher in a special file. 
  24. uucp,news.crit                      /var/log/spooler 
  25.  
  26. # Save boot messages also to boot.log 
  27. local7.*                        /var/log/boot.log 
  28.  
  29. # keepalived -S 0 
  30. local0.*                                                /var/log/keepalived.log
  31.  
   
   
   
   
  • 注意:local0是l是字符L的小写.
  •  
  • 转载:http://18567.blog.51cto.com/8567/655043

重启syslog,设置完成。

你可能感兴趣的:(keepalived,职场,休闲)