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

What is the common configuration of keepalived 1.3.5 and solutions to common problems

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Keepalived 1.3.5 what is the common configuration and solutions to common problems, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

1. Keepalived configuration and instructions 1.1 installation

[root@mysql01 keepalived] tar-zxvf keepalived-1.3.5.tar.gz

[root@mysql01 keepalived] cd keepalived-1.3.5/

[root@mysql01 keepalived]. / configure-- help | grep prefix

[root@mysql01 keepalived]. / configure-- prefix=/usr/local/keepalived

[root@mysql01 keepalived] make & & make install

[root@mysql01 keepalived] cd / usr/local/keepalived

[root@mysql02 keepalived] # cp / usr/local/keepalived/sbin/keepalived / usr/sbin/

[root@mysql01 keepalived] # cp etc/sysconfig/keepalived / etc/sysconfig/

If it is Linux 6, you also need to copy the following files:

[root@mysql01 keepalived] cp / tmp/keepalived-1.3.2/keepalived/etc/init.d/keepalived / etc/rc.d/init.d/

1.2 modify keepalived log output

Vi / usr/lib/systemd/system/keepalived.service

# confirm that the following two variables point to the correct executable keepalived

EnvironmentFile

ExecStart

Vi / etc/sysconfig/keepalived

Modify the keepalived log output device to device 0, modify the Syslog program 0 output device output file, and add dump profile data.

Vi / etc/keepalived/keepalived.conf

KEEPALIVED_OPTIONS= "- D-d-S 0"

# modify keepalived to use log 0 output device and output log to specified file separately.

Vi / etc/rsyslog.conf

Local0.* / usr/local/keepalived/log/keepalived.log

1.3 modify keepalived configuration file

# Editing keepalived configuration file, configuring vip and service monitoring, notification script and other modules.

Vi / etc/keepalived/keepalived.conf

Vrrp_script check_run {

Script "/ etc/keepalived/scripts/keepalived_check_mysql.sh"

Interval 30

Weight 0

}

Vrrp_instance VI_1 {

State BACKUP

Nopreempt

Interface team0 # network card, fill in according to the actual situation

The id of virtual_router_id 88 # master and slave machines must be the same, and different vrrp_instance must be different.

Priority 101

Advert_int 1

Authentication {

Auth_type PASS

Auth_pass 1111

}

Virtual_ipaddress {

192.168.204.88 # Virtual IP

}

Track_script {

Check_run

}

Notify_master / etc/keepalived/scripts/notify_master.sh

}

1.4 keepalived.conf description

L Notify scripts

That are run when a vrrp instance or vrrp group

Changes state, or a virtual server quorum changes between up and down.

# global script_user and script_group to MASTER transition

Notify_master / path/to_master.sh [username [groupname]]

L vrrp tracking scripts

That will cause vrrp instances to go down it

They exit a non-zero exist status, or if a weight is specified will add

Or subtract the weight to/from the priority of that vrrp instance.

L nopreempt

A higher priority VRRP instance will normally preempt a lower priority instance

When it comes online. "nopreempt" stops the higher priority machine taking

Over the master role, and allows the lower priority machine to remain as

Master.

NOTE: For this to work, the initial state must not be MASTER.

1.5 start keepalived

Enable the keepalived service and start the keepalived service:

Systemctl enable keepalived

Systemctl start keepalived

two。 Question 2.1 not a regular non-executable file

L phenomenon

[root@mysql01 ~] # systemctl status keepalived.serviceMay 7 17:12:51 mysql01 Keepalived [5467]: Configuration file'/ etc/keepalived/keepalived.conf' is not a regular non-executable file

L reason

/ etc/keepalived/keepalived.conf file permissions are not 664.

L solution

Modify the / etc/keepalived/keepalived.conf permission to 664. 2.2 Cannot find an IP address to use for interface

L phenomenon

[root@mysql01 ~] # systemctl status keepalived.serviceMay 07 17:41:14 mysql01 Keepalived_vrrp [9448]: (VI_1): Cannot find an IP address to use for interface enp0s9

L reason

Interface module in / etc/keepalived/keepalived.conf configuration file, there is no IP address on the network card

L solution

You can solve this by adding temporary IP, or adding dynamic_interfaces after keepalived version 2.0.5

[root@mysql01 ~] # ifconfig eth2 172.16.20.101 Universe 16 up

Eth2 configures IP, because if the interface does not have IP,keepalived, it will start in FAULT state. For keepalived version 2.0.5 or above, you only need to add dynamic_interfaces to global_defs.

2.3 NetworkManager causes keepalived to fail to start

L phenomenon

[root@mysql01] # tail-f / var/log/messages

May 7 11:07:15 mysql01 Keepalived [8755]: daemon is already running

May 7 11:07:15 mysql01 systemd: PID file / usr/local/var/run/keepalived.pid not readable (yet?) After start.

May 7 11:08:45 mysql01 systemd: keepalived.service start operation timed out. Terminating.

May 7 11:08:45 mysql01 systemd: Failed to start LVS and VRRP High Availability Monitor.

May 7 11:08:45 mysql01 systemd: Unit keepalived.service entered failed state.

May 7 11:08:45 mysql01 systemd: keepalived.service failed.

L reason

NetworkManager automatically manages the network. Keepalived cannot be bound to the specified interface using virtual IP, and the reason cannot be located when an error is reported in the log. Close NetworkManager in advance and set the ip address of the network card manually.

L solution

[root@mysql01 ~] # systemctl disable NetworkManager

[root@mysql01 ~] # systemctl stop NetworkManager

2.4 VRRP_Instance (VI_1) Now in FAULT state

L phenomenon

[mysql@mysql01 65mysql] $sudo systemctl status keepalived

May 07 19:06:08 mysql01 Keepalived_vrrp [16144]: VRRP_Instance (VI_1) Entering BACKUP STATE

May 07 19:06:08 mysql01 Keepalived_vrrp [16144]: VRRP sockpool: [ifindex (4), proto (112), unicast (0), fd (10L11)]

May 07 19:06:12 mysql01 Keepalived_vrrp [16144]: VRRP_Instance (VI_1) Now in FAULT state

L reason

The / etc/keepalived/keepalived.conf configuration file vrrp_script module script did not check and always returned a non-0 error value, resulting in the keepalived state being unable to complete initialization and unable to bind vip.

L solution

Fix the script error and restart keepalived.

2.5 failed because a timeout was exceeded

● phenomenon

[mysql@mysql02 keepalived] $sudo systemctl status keepalived

Keepalived.service-LVS and VRRP High Availability Monitor

Loaded: loaded (/ usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)

Active: failed (Result: timeout) since Thu 2020-05-07 20:44:08 CST; 14min ago

Process: 31073 ExecStart=/usr/local/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)

Tasks: 6

CGroup: / system.slice/keepalived.service

├─ 2687 / usr/local/keepalived/sbin/keepalived-D-d-S 0

├─ 2688 / bin/bash / etc/keepalived/scripts/keepalived_check_mysql.sh

├─ 2815 sleep 2

├─ 25921 / usr/local/keepalived/sbin/keepalived-D-d-S 0

├─ 25922 / usr/local/keepalived/sbin/keepalived-D-d-S 0

└─ 25923 / usr/local/keepalived/sbin/keepalived-D-d-S 0

May 07 20:42:38 mysql02 systemd [1]: Starting LVS and VRRP High Availability Monitor...

May 07 20:42:38 mysql02 systemd [1]: PID file / var/run/keepalived.pid not readable (yet?) After start.

May 07 20:44:08 mysql02 systemd [1]: keepalived.service start operation timed out. Terminating.

May 07 20:44:08 mysql02 systemd [1]: Failed to start LVS and VRRP High Availability Monitor.

May 07 20:44:08 mysql02 systemd [1]: Unit keepalived.service entered failed state.

May 07 20:44:08 mysql02 systemd [1]: keepalived.service failed.

[mysql@mysql02 keepalived] $sudo systemctl start keepalived

Job for keepalived.service failed because a timeout was exceeded. See "systemctl status keepalived.service" and "journalctl-xe" for details.

L reason

The original keepalived program is not running properly, can not continue, systemctl restart keepalived has been unable to restart keepalived correctly.

L solution

[mysql@mysql02 ~] $ps-ef | grep keepalived

Kill drops all keepalived processes and restarts keepalived

[mysql@mysql02 ~] $sudo systemctl restart keepalived.service

[mysql@mysql02 ~] $sudo systemctl status keepalived.service

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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