Even if I set the ipvsadm table, it will return when I restart the OS.

Asked 1 years ago, Updated 1 years ago, 381 views

The ipvsadm table can be configured and the configuration information can be cleared and restored when the service is restarted, but the table information is not restored when the OS is restarted.
Is there any way to maintain the configuration after the OS reboot?

1.Verify Version

#cat/etc/redhat-release
Rocky Linux release 8.7 (Green Obsidian)

# yum list installed | grep ipvsadm
ipvsadm.x86_641.31-1.el8@appstream

# yum list installed | grep kept
kept.x86_642.1.5-9.el8@appstream

2.Check Service Status

#systemctl status ipvsadm
● ipvsadm.service - Initialize the Linux Virtual Server
   Loaded: loaded (/usr/lib/systemd/system/ipvsadm.service; enabled; vendor preset: disabled)
   Active:active (exited) since Tue 2022-12-13 11:18:36 JST; 2h 38minago

3.Service Script

#less/usr/lib/systemd/system/ipvsadm.service
Unit
Description= Initialize the Linux Virtual Server
After=syslog.targetnetwork.target 

Service
Type = one shot
ExecStart=/bin/bash-c "exec/sbin/ipvsadm-restore</etc/sysconfig/ipvsadm"
ExecStop=/bin/bash-c "exec/sbin/ipvsadm-save-n>/etc/sysconfig/ipvsadm"
ExecStop=/sbin/ipvsadm-C
RemainAfterExit=yes

Install
WantedBy=multi-user.target

4.Add Table Settings

#ipvsadm-L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  ->RemoteAddress: Port Forward Weight ActiveConn InActConn
TCP 192.168.100.100:http sh
  ->192.168.100.101: http Route 100         
  ->192.168.100.102: http Route 100         
  ->192.168.100.103: http Route 100         
  ->192.168.100.104—http Route 100         
TCP 192.168.100.100:httpssh
  ->192.168.100.101:https Route 100         
  ->192.168.100.102—https Route 100         
  ->192.168.100.103—https Route 100         
  ->192.168.100.104—https Route 100

5.Service Down - > ipvsadm Table States

#systemctl stop ipvsadm
# ipvsadm-L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  ->RemoteAddress: Port Forward Weight ActiveConn InActConn

6.Service Start->ipvsadm Table States

#systemctl start ipvsadm
# ipvsadm-L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  ->RemoteAddress: Port Forward Weight ActiveConn InActConn
TCP 192.168.100.100:http sh
  ->192.168.100.101: http Route 100         
  ->192.168.100.102: http Route 100         
  ->192.168.100.103: http Route 100         
  ->192.168.100.104—http Route 100         
TCP 192.168.100.100:httpssh
  ->192.168.100.101:https Route 100         
  ->192.168.100.102—https Route 100         
  ->192.168.100.103—https Route 100         
  ->192.168.100.104—https Route 100 

7.OS Restart - > ipvsadm Table States

#ipvsadm-L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  ->RemoteAddress: Port Forward Weight ActiveConn InActConn

8.Service Startup Order

Service Startup Order
There seems to be a way to change the service startup order, but the cause cannot be determined.
I would appreciate it if you could let me know.

linux

2022-12-14 16:44

1 Answers

It seems that the kept stopped after ipvsadm started, so the process of removing all entries from the IPVS virtual server table was carried out.
The problem with this question is that kept has stopped, so I will close the question.


2022-12-14 16:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.