Redis can't find pid? How to configure the pid file location address after Redis starts

Redis startup can't find pid file location? Where is the pid file for Redis?

Redis can't find pid? How to configure the pid file location address after Redis starts

LinuxHow to check the location address of the Redis process pid file?

Linux find redis process command▼

ps -ef | grep redis

Return to display the following query results▼

redis 28221 1 1 Feb08 ? 00:13:19 /usr/bin/redis-server 127.0.0.1:6379
  • Looking at the redis process, I can't find the location of the pid file. What should I do?

redis.pid file not found?

The Redis startup script is supposed to create a pid file on startup, but we've confirmed all the settings we can find, and no pid file is created.

What if the Redis daemon didn't create the PID file?

How is redis.pid generated?

for linux server CentOS 7:

The name of the Redis server isredis.service, SSH Enter the following command to start editing▼

systemctl edit redis.service

add this ▼

[Service]

ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"
PIDFile=/var/run/redis/redis.pid

Restart the service:

systemctl daemon-reload
systemctl restart redis
monit reload

Then, the file address of this location will be used to generate the pid file of Redis:/etc/systemd/system/redis.service.d/override.conf

pid file address▼

cat /var/run/redis/redis.pid 
=> 27585

What's in the redis.pid file?

  • The redis.pid file stores the ID of the process.
  • 使用catCommand to view, you can see that there is only one line, recording the ID of the process.

What is the role of the redis.pid file?

  • The role of the redis.pid file is to prevent multiple copies of the process from being started.
  • The Monit program monitors the redis process and needs to use the location address of the redis.pid file.

      What is the principle of pid file?

      • After the process is running, a file lock is added to the .pid file.
      • Only the process that obtains the lock has write permission (F_WRLCK), and writes its own pid to the file.
      • Other processes trying to acquire the lock will automatically exit.

      Monit monitoringAdd Redis pid file location address

      Configuration files for monitoring programs in Monitmonit.confIn, add the location address of the pid file of Redis ▼

      check process redis with pidfile "/var/run/redis/redis.pid"
      start program "/usr/bin/systemctl start"
      stop program "/usr/bin/systemctl stop"
      if failed host 127.0.0.1 port 6379 then restart 
      if 5 restarts within 5 cycles then timeout
      group redis

      How to set up the monit.conf file?

      Monit monitoring is a free and open sourcesoftware, click the link below to browse the CWP7 installation Monit monitoring software tutorial ▼

      Hope Chen Weiliang Blog ( https://www.chenweiliang.com/ ) shared "Redis can't find pid? How to configure the location address of the pid file after Redis is started", it will help you.

      Welcome to share the link of this article:https://www.chenweiliang.com/cwl-26494.html

      Welcome to the Telegram channel of Chen Weiliang's blog to get the latest updates!

      🔔 Be the first to get the valuable "ChatGPT Content Marketing AI Tool Usage Guide" in the channel top directory! 🌟
      📚 This guide contains huge value, 🌟This is a rare opportunity, don’t miss it! ⏰⌛💨
      Share and like if you like!
      Your sharing and likes are our continuous motivation!

       

      Comment

      Your email address will not be published. Required fields * Callout

      scroll to top