The path to my Redis installation is in the
/usr/local/redis
Mkdir/etc/redis #创建文件夹
cp/usr/local/redis/redis.conf/etc/redis/6379.conf #将redis. conf Copy to/etc/redis folder
Vim/etc/rc.d/init.d/redis #打开编辑器
Insert the following content
#!/bin/Sh#chkconfig:2345 the -# Simple Redis init.d script conceived to work on Linux systems# asIt does use of the/proc FileSystem. Redisport=6379EXEC=/usr/local/redis/src/redis-servercliexec=/usr/local/redis/src/redis-Clipidfile=/var/run/redis_${redisport}.pidconf="/etc/redis/${redisport}.conf" Case " $" inchstart)if[ -F $PIDFILE] then echo"$PIDFILE exists, process is already running or crashed" ElseEcho"starting Redis Server ..."$EXEC $CONF fi;; Stop)if[ ! -F $PIDFILE] then echo"$PIDFILE does not exist, process was not running" ElsePID=$ (cat $PIDFILE) echo"stopping ..."$CLIEXEC-p $REDISPORT shutdown while[-x/proc/${pid}] DoEcho"waiting for Redis to shutdown ..."Sleep1Done Echo"Redis stopped"fi;; *) echo"Please use start or stop as first argument" ;; Esac
chkconfig --add redis #添加服务
Service Redis Start #启动服务
Add the directory of the Redis command to the system parameter path
Modify Profile: Vi/etc/profile
Append in last line: Export path= "$PATH:/usr/local/redis/src"
Then apply this file immediately:. /etc/profile
This makes it possible to invoke the REDIS-CLI command directly, as follows:
$ redis-cli
Redis 127.0.0.1:6379> Auth Superman
Ok
Redis 127.0.0.1:6379> Ping
PONG
Redis 127.0.0.1:6379>
Redis joins the boot start service