Detailed explanation of configuring keepalived log to another path in centos7

Detailed explanation of configuring keepalived log to another path in centos7

Keepalived installation:

cd <keepalived_sourcecode_path>
./configure --prefix=/usr/local/keepalived
 
make && make install
 
mkdir /etc/keepalived
mkdir /etc/keepalived/scripts
cp /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/keepalived
cp /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 strip it out.

In centos 6 you can:

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

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

(2) Next, 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:

Used on centos 7. Because centos 7 uses systemctl and calls service through systemctl, you need to modify the /lib/systemd/system/keepalived.service file.

Put the following inside:

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

Modified to:

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

Then reload the service:

systemctl daemon-reload

The overall idea is,

1. Start via systemctl start keepalived;

2. When starting keepalived, it will read the service configuration file: /lib/systemd/system/keepalived.service;

3. In the service configuration file:

3.1 Startup file path ExecStart=/sbin/keepalived $KEEPALIVED_OPTIONS, that is, the startup method is to start with the parameters in the environment variable file;

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

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

5. Therefore, the log is written to /var/log/keepalived.log.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  How to filter out certain libraries during mysql full backup

>>:  Implementation example of video player based on Vue

Recommend

MySQL 8.0.17 installation and configuration method graphic tutorial

This article shares the installation and configur...

Solution to the horizontal scroll bar in iframe under IE6

The situation is as follows: (PS: The red box repr...

Use dockercompose to build springboot-mysql-nginx application

In the previous article, we used Docker to build ...

Example of creating circular scrolling progress bar animation using CSS3

theme Today I will teach you how to create a circ...

Detailed explanation of common operations of Docker images and containers

Image Accelerator Sometimes it is difficult to pu...

Use h1, h2, and h3 tags appropriately

In the process of making web pages, it is inevita...

idea combines docker to realize image packaging and one-click deployment

1. Install Docker on the server yum install docke...

Java example code to generate random characters

Sample code: import java.util.Random; import java...

VMware virtual machine installation CentOS 8 (1905) system tutorial diagram

The world-famous virtual machine software VMware-...

Docker deploys net5 program to achieve cross-platform functions

Deployment environment: docker container, liunx s...

Teach you MySQL query optimization analysis tutorial step by step

Preface MySQL is a relational database with stron...

Some summary of MySQL's fuzzy query like

1. Common usage: (1) Use with % % represents a wi...

Detailed tutorial for installing influxdb in docker (performance test)

1. Prerequisites 1. The project has been deployed...

Solution to Nginx 500 Internal Server Error

Today, when I was using Nginx, a 500 error occurr...