Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure keepalived log to another path in centos7

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to configure the keepalived log for other paths in centos7, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

Keepalived installation:

Cd. / configure-- prefix=/usr/local/keepalived make & & make install mkdir / etc/keepalivedmkdir / etc/keepalived/scriptscp / usr/local/keepalived/etc/keepalived/keepalived.conf / etc/keepalived/cp / root/keepalived-2.0.6/keepalived/etc/init.d/keepalived / etc/init.d/cp / usr/local/keepalived/sbin/keepalived / sbin/keepalivedcp / usr/local/keepalived/etc/sysconfig/keepalived / etc/sysconfig/chmod + x / etc/init.d/keepalived

Since keepalived logs are written to / var/log/message by default, we need to split this out.

Under centos 6, you can:

(1) modify the / etc/sysconfig/keepalived file first, comment out the following, and add the following:

# KEEPALIVED_OPTIONS= "- D" KEEPALIVED_OPTIONS= "- D-d-S 0"

(2) secondly, modify the / etc/rsyslog.conf file and add the following:

Local0.* / var/log/keepalived.log

Under centos 7, you also need to modify the / lib/systemd/system/keepalived.service file:

Centos 7 is used. Because centos 7 uses systemctl and calls service through systemctl, the / lib/systemd/system/keepalived.service file needs to be modified.

Put the inside:

EnvironmentFile=-/usr/local/keepalived/etc/sysconfig/keepalivedExecStart=/usr/local/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS

Modified to:

EnvironmentFile=/etc/sysconfig/keepalivedExecStart=/sbin/keepalived $KEEPALIVED_OPTIONS

Then reload service:

Systemctl daemon-reload

The whole idea is

1. Launch via systemctl start keepalived

two。 When you start keepalived, you will read the service configuration file: / lib/systemd/system/keepalived.service

3. In the configuration file of service:

3.1Boot file path ExecStart=/sbin/keepalived $KEEPALIVED_OPTIONS, that is, the startup mode is started with parameters in the environment variable file

Read the environment variable parameter EnvironmentFile=/etc/sysconfig/keepalived.

4. The $KEEPALIVED_OPTIONS parameter is configured in / etc/sysconfig/keepalived; we configure KEEPALIVED_OPTIONS= "- D-d-S 0"; and-S is the facility,0 of syslog to put in local0, and configure local0.* / var/log/keepalived.log in / etc/rsyslog.conf

5. So, write a journal and go to / var/log/keepalived.log.

Thank you for reading this article carefully. I hope the article "how to configure keepalived logs for other paths in centos7" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report