Keepalived::instance1 s in a crash loop : pidfile_write : Cannot open /run/keepalived.pid pidfile

Hello,

I just installed

openwrt-19.07.3-x86-64-combined-ext4.img

After installing keepalived:

opkg update
opkg install keepalived

Cannot start up. Getting a following error:

......
Tue Aug 18 08:14:36 2020 daemon.info Keepalived[22842]: pidfile_write : Cannot open /run/keepalived.pid pidfile
Tue Aug 18 08:14:36 2020 daemon.info Keepalived[22842]: Stopped Keepalived v2.0.18 (07/26,2019)
Tue Aug 18 08:14:41 2020 daemon.info Keepalived[22853]: Starting Keepalived v2.0.18 (07/26,2019)
Tue Aug 18 08:14:41 2020 daemon.info Keepalived[22853]: WARNING - keepalived was build for newer Linux 4.14.193, running on Linux 4.14.180 #0 SMP Sat May 16 18:32:20 2020
Tue Aug 18 08:14:41 2020 daemon.info Keepalived[22853]: Command line: '/usr/sbin/keepalived' '-n' '-f' '/tmp/keepalived.conf'
Tue Aug 18 08:14:41 2020 daemon.info Keepalived[22853]: Opening file '/tmp/keepalived.conf'.
Tue Aug 18 08:14:41 2020 daemon.info Keepalived[22853]: pidfile_write : Cannot open /run/keepalived.pid pidfile
Tue Aug 18 08:14:41 2020 daemon.info Keepalived[22853]: Stopped Keepalived v2.0.18 (07/26,2019)
Tue Aug 18 08:14:41 2020 daemon.info procd: Instance keepalived::instance1 s in a crash loop 6 crashes, 0 seconds since last crash

You could try to start the daemon from command line with debug switch (if available) and watch for an more usefull error message.
It might be enough to link /tmp/var/run to /run or to configure the path within command line or configfile.

yes thank you pwned :slight_smile:

So the right way of the installation:

ln -s /tmp/run /run
opkg update
opkg install keepalived

edit /etc/config/keepalived
need to comment this 2 line

config global_defs
        option alt_config_file          "/etc/keepalived/keepalived.conf"

from here this guide can be followed
https://openwrt.org/docs/guide-user/network/high-availability

i used a following minimalist config just for test:

global_defs {
   router_id OWRT-V-01         # give unique id for each router
   vrrp_skip_check_adv_addr
}

vrrp_instance VI_1 {
    state MASTER           # The other router is  BACKUP
    interface br-mng         # the interface where the vrrp is running
    virtual_router_id 56
    priority 200                  # The other router is 100 (the lower is the backup)
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass weuigf89
    }


    virtual_ipaddress {
        192.168.56.254            # ip should be changed 
    }
}

for testing
stop both router

service keepalived stop

first start the backup then the master
service keepalived restart; logread -f

The slave first became master then slave when the higher priority router is started :

root@OWRT-V-02:/etc/keepalived#  service keepalived restart; logread -f
Tue Aug 18 19:32:42 2020 local1.info Keepalived_vrrp[5475]: Stopped
Tue Aug 18 19:32:42 2020 daemon.info Keepalived[5472]: Stopped Keepalived v2.0.18 (07/26,2019)
Tue Aug 18 19:32:42 2020 daemon.info Keepalived[7411]: Starting Keepalived v2.0.18 (07/26,2019)
Tue Aug 18 19:32:42 2020 daemon.info Keepalived[7411]: WARNING - keepalived was build for newer Linux 4.14.193, running on Linux 4.14.180 #0 SMP Sat May 16 18:32:20 2020
Tue Aug 18 19:32:42 2020 daemon.info Keepalived[7411]: Command line: '/usr/sbin/keepalived' '-n' '-f' '/tmp/keepalived.conf'
Tue Aug 18 19:32:42 2020 daemon.info Keepalived[7411]: Opening file '/tmp/keepalived.conf'.
Tue Aug 18 19:32:42 2020 daemon.info Keepalived[7411]: Starting VRRP child process, pid=7412
Tue Aug 18 19:32:42 2020 local1.info Keepalived_vrrp[7412]: Registering Kernel netlink reflector
Tue Aug 18 19:32:42 2020 local1.info Keepalived_vrrp[7412]: Registering Kernel netlink command channel
Tue Aug 18 19:32:42 2020 local1.info Keepalived_vrrp[7412]: Opening file '/tmp/keepalived.conf'.
Tue Aug 18 19:32:42 2020 local1.info Keepalived_vrrp[7412]: Unable to load magic database
Tue Aug 18 19:32:42 2020 local1.info Keepalived_vrrp[7412]: Registering gratuitous ARP shared channel
Tue Aug 18 19:32:42 2020 local1.info Keepalived_vrrp[7412]: (VI_1) Entering BACKUP STATE (init)
Tue Aug 18 19:32:45 2020 local1.info Keepalived_vrrp[7412]: (VI_1) Entering MASTER STATE
Tue Aug 18 19:33:41 2020 local1.info Keepalived_vrrp[7412]: (VI_1) Master received advert from 192.168.56.2 with higher priority 200, ours 100
Tue Aug 18 19:33:41 2020 local1.info Keepalived_vrrp[7412]: (VI_1) Entering BACKUP STATE

netstat also can be used for checking if VRRP is listening

root@OWRT-V-01:/etc/keepalived# netstat -na| grep -i 112            
raw        0      0 0.0.0.0:112             0.0.0.0:*               112
raw        0      0 0.0.0.0:112             0.0.0.0:*               112
1 Like