Modify the keepalived configuration file location and the output path of the redirected keepalived log

Source: Internet
Author: User
Tags syslog


The last blog post focuses on how to use keepalived to implement dual-machine hot standby for tomcat servers. This blog is an extension of the previous blog post, mainly about how to modify the path of the default profile of the keepalived and the output path of the redirected keepalived log. For information on how to install keepalived and keepalived installation path issues, refer to the previous blog post.



Keepalived The default profile path is/etc/keepalived/keepalived.conf



Keepalived The default log file is saved in/var/log/messages



Sometimes it is necessary to modify these file paths to a suitable location because of the actual needs, such as the path planning of the project.



First look at the/etc/sysconfig/keepalived file.





# Options for keepalived. keepalived--help ' Output and keepalived (8) and
# keepalived.conf (5) Man pages for a list of all options. Here are the most
# common ones:
#
--VRRP               -P only    run with VRRP subsystem.
#--check              -C is    run with Health-checker subsystem.
#--DONT-RELEASE-VRRP    -v dont remove VRRP VIPs & vroutes on daemon stop.
#--dont-release-ipvs    -i dont remove Ipvs topology on daemon stop.
#--dump-conf    -D dump the configuration data.
#--log-detail    -D Detailed log messages.
#--log-facility    -S 0-7 Set local syslog facility (Default=log_daemon)
#

keepalived_options= '-d '
Note that there is only one keepalived_options= "-D" in this file, which is the key to modifying the file path.





Here to add the keeaplived of the relevant knowledge





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

A careful reader may notice that "-D" is the option for the output log, and-f is the option to modify the default profile path.


The keepalived_options in/etc/sysconfig/keepalived is modified to:


KEEPALIVED_OPTIONS="-f [Configuration file path] -D"



The [config file path]] is the path to the keepalived configuration file you want to modify.



Also note that "-S" is required to modify the default path of the log file. The keepalived_options will be amended to read:



KEEPALIVED_OPTIONS="-f [Configuration file path] -D -S 0"



Here the "-s 0" means local0.* specific also need to look at the/etc/rsyslog.conf file:







# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages

# The authpriv file has restricted access.
authpriv.*                                              /var/log/secure

# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog


# Log cron stuff
cron.*                                                  /var/log/cron

# Everybody gets emergency messages
*.emerg                                                 *

# Save news errors of level crit and higher in a special file.
uucp,news.crit                                          /var/log/spooler

# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log
See the last sentence:







local7.*                                                /var/log/boot.log
Also we can add in this file





local0.*/var/log/keepalived . log



This allows us to modify the log path.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.