Feeling
Redis played for a long time, really feel the start of the way or the convenience of their own definition!
1) direct Start and close: (Default profile)
Open: Redis-server & (& background Run)
#daemonize Yes (you can also configure the file to modify this parameter)
Close: redis-cli shutdown or killall-9 redis-server
2) Specify the configuration file to start:
Redis-server/etc/redis.conf (configuration file can be defined by itself)
If you change the Redis default port:
redis-cli shutdown (-p port)
redis-cli shutdown (-p Port) (-a authentication password)
3 ) Define your startup files and configure them (recommended)
[Email protected] ~]# Cpredis-2.8.24/utils/redis_init_script/etc/init.d/redis
Register as a system service:
[Email protected] ~]# sed-i ' 2i #chkconfig: 2345 '/etc/init.d/redis
[Email protected] ~]# chkconfig--add Redis
Modify the configuration file (because the path itself is defined, SED can also)
redisport=7000 # Note the slave port is defined by itself
Exec=/usr/local/redis/bin/redis-server
Cliexec=/usr/local/redis/bin/redis-cli
Pidfile=/var/run/redis_${redisport}.pid
conf= "/etc/redis/${redisport}.conf"
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/8B/58/wKioL1hKWS_QDEizAAAqIGqzitk891.png "title=" 1.png " alt= "Wkiol1hkws_qdeizaaaqigqzitk891.png"/>
The script is as follows (your own configuration, you can also modify on this basis)
#!/bin/sh#chkconfig: 2345 80 90# simple redis init.d script Conceivedto work on linux systems# as it does use of the /procfilesystem. redisport=7000exec=/usr/local/redis/bin/redis-servercliexec=/usr/local/redis/bin/ redis-cli pidfile=/var/run/redis_${redisport}.pidconf= "/etc/redis/${redisport}.conf" case "$" in start) if [ -f $PIDFILE ] then echo -e "\033[31m $PIDFILEexists, process is already running or crashed \033[0m " else echo -e "\033[32m waitingfor redis to start...\033[0m " $EXEC $CONF if [ $? -eq 0 ] then echo -e "\033[32m redis isalready started successfully! \033[0m " else echo -e "\033[31m redisstart fail \033[0m" fi fi ;; stop) if [ ! -f $PIDFILE ] then echo -e "\033[31m $PIDFILEdoes not exist, process is not running \033[0m " else pid=$ (cat $PIDFILE) echo -e "\033[32m waitingfor redis to stop ... \033[0m" $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${pid} ] do echo -e "\033[32mwaiting for redis to shutdown ... \033[0m " sleep 1 done echo -e "\033[32m redis isalready stopped successfully! \033[0m " fi ;; status) ps aux|grep redis-server|grep-v grep &>/dev/null if [ $? -eq 0 ] Then echo -e "\033[32m redisis running... \033[0m" else echo -e "\033[31m redisis already stopped \033[0m " fi ;; &nbSp; restart) $CLIEXEC -p $REDISPORT shutdown if [ $? -eq 0 ] then echo -e "\033[32m redis isalready stopped successfully! \033[0m " else echo -e "\033[31m redisstop fail \033[0m" fi $EXEC $CONF if [ $? -eq 0 ] then echo -e "\033[32m redis isalready started successfully! \033[0m " else echo -e "\ 033[31m redisstart fail \033[0m " fi ;; *) echo "the usage is service Redis sTart|stop|status|restart " esac
view Redis status, start, close, restart
[[email protected] ~]# /etc/init.d/redis status redis is running... [[ email protected] ~]# /etc/init.d/redis stop waiting for redis to Stop ... waiting for redis to shutdown ... redis is already stopped successfully! [[email protected] ~]# /etc/init.d/redis start Waiting for Redis to start... Redis is already started successfully! [[email protected] ~]# /etc/init.d/redis restart redis is already stopped successfully! redis is already started successfully! [[email protected] ~]#[[email protected] ~]# ps aux| grep redis-server|grep -v greproot 2881 0.1 0.1 128296&nbSp; 1692 ? ssl 12:45 0:01 /usr/local/redis/bin/redis-server *:7000 [[email protected] ~]#
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/8B/5C/wKiom1hKWuKSwL7NAABgQ9dK-5U277.png-wh_500x0-wm_3 -wmp_4-s_1704847371.png "title=" 2.png "alt=" Wkiom1hkwukswl7naabgq9dk-5u277.png-wh_50 "/>
This article is from "Never give up!" Ningzhiyuan "blog, be sure to keep this source http://renzhiyuan.blog.51cto.com/10433137/1881202
A variety of Redis start-up methods comparison!