Redis configuration file
主要遇到的问题是:redis.pid没有找到
Here is my configuration file
# By default Redis does not run as a daemon. Use ‘yes‘ if you need it.# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.daemonize yes# When running daemonized, Redis writes a pid file in /var/run/redis.pid by# default. You can specify a custom pid file location here.
Execute permissions for Var/run
lrwxrwxrwx 1 root root 4 Feb 24 06:57 run -> /run
Then I touch redis.pid with sudo.
root@ubuntu:/home/fuhui/redis-2.8.19/utils# pwd/home/fuhui/redis-2.8.19/utilsroot@ubuntu:/home/fuhui/redis-2.8.19/utils# sh redis_init_script stopnotnot running
Do not know whether permission is a problem, modify O permission
fuhui@ubuntu:/var/run$ 1 root root 0Jun22 08:39 redis.pid
Is the service not restarted?
Fuhui@ubuntu:/var/run$ Ps-ef | Grep' Redis 'Fuhui2452 1 0 -: -?xx:xx:Genevaredis-2.8. +/src/redis-server *:6379Fuhui2908 2756 008: $pts/ - xx:xx:xxgrep--color=auto Redisfuhui@ubuntu:/var/run$ Kill-9 2452Fuhui@ubuntu:/var/run$ Ps-ef | Grep' Redis 'Fuhui2910 2756 008: $pts/ - xx:xx:xxgrep--color=auto Redis
Reboot to try:
There's a PID number in the Redis.pid.
Turn off Redis Services
root@ubuntu:/home/fuhui/redis-2.8.19/utils# sh redis_init_script stopnotnot running
modifying shell files
The following is the original file, we have to do is actually very simple, just change the path to the actual storage can be
#!/bin/sh## Simple Redis init.d script conceived to work on Linux systems# as it does use of the/proc filesystem.redisport=6379Exec=/usr/local/bin/redis-servercliexec=/usr/local/bin/redis-clipidfile=/var/run/redis_${redisport}. pidconf="/etc/redis/${redisport}. conf" Case "$" inchStartif[- F $PIDFILE] Then Echo "$PIDFILE exists, process is already running or crashed" Else Echo "Starting Redis server ..." $EXEC $CONF fi;; Stopif[ !- F $PIDFILE] Then Echo "$PIDFILE does not exist, process was not running" Elsepid=$ (cat$PIDFILE)Echo "Stopping ..." $CLIEXEC-P$REDISPORTShutdown while[-x/proc/${pid}] Do Echo "Waiting for Redis to shutdown ..."Sleep1 Done Echo "Redis stopped" fi;; *)Echo "Use Start or stop as first argument";;Esac
Modify the following:
root@ubuntu:/home/fuhui/redis-2.8.19/utils# cp redis_init_script ../redis_script
See if there is a PID under the proc
fuhui@ubuntu:/proc$ cd /proc/fuhui@ubuntu:/proc$ 2912dr-xr-xr-x 9 root root 0Jun22 08:472912
Turn off Redis service testing
fuhui@ubuntu:~/redis-2.8.19$ src/redis-cli127.0.0.1:6379> shutdownnot
#!/bin/sh## Simple Redis init.d script conceived to work on Linux systems# as it does use of the/proc filesystem.#REDISPORT =6379exec=/home/fuhui/redis-2.8. +/src/redis-servercliexec=/home/fuhui/redis-2.8. +/src/redis-clipidfile=/var/run/redis.pidconf="/home/fuhui/redis-2.8.19/redis.conf" Case "$" inchStartif[- F $PIDFILE] Then Echo "$PIDFILE exists, process is already running or crashed" Else Echo "Starting Redis server ..." $EXEC $CONF fi;; Stopif[ !- F $PIDFILE] Then Echo "$PIDFILE does not exist, process was not running" Elsepid=$ (cat$PIDFILE)Echo "Stopping ..." $CLIEXECShutdown while[-x/proc/${pid}] Do Echo "Waiting for Redis to shutdown ..."Sleep1 Done Echo "Redis stopped" fi;; *)Echo "Use Start or stop as first argument";;Esac
Execution results
root@ubuntu:/home/fuhui/redis-2.8.19# sh redis_script startStartingRedis server...
Root@ubuntu:/home/fuhui/redis-2.8. +# Ps-ef | grep ' Redis 'Root2972 1 009:08?xx:xx:xx/home/fuhui/redis-2.8. +/src/redis-server *:6379Root2993 2720 009:pts/6 xx:xx:xxgrep--color=auto Redis
[email protected]:/home/fuhui/redis-2.8.19# sh redis_script stop...Redis stopped
root@ubuntu:/home/fuhui/redis-2.8.19# ps -ef | grep ‘redis‘root 2998 2720 0 09:10 pts/6 00:00:00 grep --color=auto redis
Redis Foundation 4-redis Services