Linux Redis自动启动,Redis开机启动,Linux Redis设置开机启动
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
©Copyright 蕃薯耀 2017年7月21日
http://fanshuyao.iteye.com/
Linux Redis安装,Linux如何安装Redis见:
http://fanshuyao.iteye.com/blog/2386231
一、新建、编写开机自启动脚本(redis-auto为新建的文件)
vi /etc/init.d/redis-auto
二、在文件redis-auto加入如下内容:(注意Redis具体的安装路径,你的可能不一样)
扫描二维码关注公众号,回复:
341735 查看本文章
2017-07-26修正参数名不一致的问题。
#!/bin/sh #chkconfig: 2345 80 90 # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. REDISPORT=6379 REDISPATH=/home/java/run/redis-3.2.9/bin EXEC=${REDISPATH}/redis-server CLIEXEC=${REDISPATH}/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="${REDISPATH}/redis.conf" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *) echo "Please use start or stop as first argument" ;; esac
三、保存退出
:wq
四、设置文件redis-auto的权限,让Linux可以执行
cd /etc/init.d/ chmod 755 redis-auto
五、启动Redis服务测试,此处启动用的是第二步设置的启动脚本
/etc/init.d/redis-auto start
如果看到Redis启动的小盒子就表示成功。
不过你可以进一步打开redis-cli客户端进行测试
六、设置开机自启动,即:
chkconfig redis-auto on
七、经过测试,Linux系统在重新启动时,Redis的数据会自动丢失,解决方案见:
Linux Redis 重启数据丢失解决方案,Linux重启后Redis数据丢失解决方案
http://fanshuyao.iteye.com/blog/2386429
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
©Copyright 蕃薯耀 2017年7月21日
http://fanshuyao.iteye.com/