Linux Redis自動啟動,Redis開機啟動,Linux Redis設置開機啟動
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
©Copyright 蕃薯耀 2017年7月21日
http://www.cnblogs.com/fanshuyao/
Linux Redis安裝,Linux如何安裝Redis見:
http://fanshuyao.iteye.com/blog/2386231
一、新建、編寫開機自啟動腳本(redis-auto為新建的文件)
- vi /etc/init.d/redis-auto
二、在文件redis-auto加入如下內容:(注意Redis具體的安裝路徑,你的可能不一樣)
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可以執行
- 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://www.cnblogs.com/fanshuyao/p/7222011.html
(如果你覺得文章對你有幫助,歡迎捐贈,^_^,謝謝!)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
©Copyright 蕃薯耀 2017年7月21日
http://www.cnblogs.com/fanshuyao/