Start with Redis-server with configuration file
[Email protected] utils]# redis-server/etc/redis/6379.conf[[email protected] utils]# Ps-ef | grep redis root 9662 1 0 15:47? 00:00:00redis-server *:6379 root 9670 3834 0 15:47 pts/1 00:00:00 grepredis
Turn off Redis
Use REDIS-CLI to keep up with shutdown to close Redis[[email protected] utils]# redis-cli-p 6379 shutdown[[email protected] utils]# Ps-ef | grep redis root 9674 3834 0 15:48 pts/1 00:00:00 grepredis directly use SYSV script to switch off Redis[[email protected] Util s]#/etc/init.d/redis_6379 stopstopping ... Redis stopped
Let the service run in front of the way
[[email protected] utils]# grep daemonize/etc/redis/6379.conf # Note that Redis will write a pid file in/var/run/redis.pid when daemonized.daemonize yes #这里的daemonize值为yes, indicating the future operation if the value is changed to No, then the Redis service will run # when running daemonized in the foreground mode. redis writes a pid file in/var/run/redis.pid by# output for logging but daemonize, logs will be sent to/dev/null# demonstrates this process, window 1[[ email protected] utils]# sed -i '/^daemonize/s/yes/no/g '/etc/redis/6379.conf #替换yes为no [[email protected] utils]# grep daemonize/etc/redis/6379.conf # Note that redis will write a pid file in/var/run/redis.pid when daemonized.daemonize no #确认一下这个值是否发生了变化 # when running daemonized, redis writes a pid file in /var/run/redis.pidby# output for logging but daemonize, Logs will be sent to/dev/null# currently does not have any boot redis[[email protected] utils]# ps -ef | grep redisroot 9725 3834 0 15:56 pts/1 00:00:00 grepredis[[email protected] utils ]# redis-server /etc/redis/6379.conf #这个时候窗口应该是hang住的 # window 2[[email protected] ~]# ps -ef | grep redisroot 9730 3834 0 15:56 pts/1 00:00:00redis-server *:6379 root 9749 9735 0 15:56 pts/0 00:00:00 grepredis[[email protected] ~ ]# redis-cli -p 6379127.0.0.1:6379> set k1 1ok127.0.0.1:6379> get k1 "1" 127.0.0.1:6379> shutdown #当shutdown命令敲下去之后, Just now the foreground process also released the terminal cursor should not let Redis in the foreground boot, so the configuration file in the value of the change back. [[email protected] utils]# sed -i '/^daemonize/s/no/yes/g '/etc/redis/6379.conf [[email protected] utils]# grep daemonize/etc/redis/6379.conf # Note that Redis will write a pid file In/var/run/redis.pid when daemonized.daemonize yes# when running daemonized,&nbSp redis writes a pid file in/var/run/redis.pid by# output for Logging but daemonize, logs will be sent to/dev/null
how to see if Redis is running
The [[email protected] utils]# /etc/init.d/redis_6379 startstarting redis is judged by the PS command Server ... [[Email protected] utils]# /etc/init.d/redis_6378 startstarting redis server ... [[email protected] utils]# ps -ef | grep redis #能看到进程号root 9801 1 0 16:02 ? 00:00:00/usr/local/bin/ Redis-server *:6378 root 9814 1 0 16:03 ? 00:00:00 /usr/local/bin/redis-server*:6379 root 9818 3834 0 16:03 pts/1 00:00:00 grepredis through REDIS-CLI, can connect into redis[[ email protected] utils]# redis-cli -p 6378127.0.0.1:6378> exit[[email Protected] utils]# redis-cli -p 6379127.0.0.1:6379> exit
This article is from the "long name will be good to remember" blog, please be sure to keep this source http://xiaoyiyi.blog.51cto.com/1351449/1705710
(ii) Redis startup and shutdown