[url]
修改redis.conf,開啟後台執行選項:
# by default redis does not run as a daemon. use 'yes' if you need it.
# note that redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
編寫指令碼,vim /etc/init.d/redis:
# chkconfig: 2345 10 90
# description: start and stop redis
path=/usr/local/bin:/sbin:/usr/bin:/bin
redisport=6379 #實際環境而定
exec=/usr/local/redis/src/redis-server #實際環境而定
redis_cli=/usr/local/redis/src/redis-cli #實際環境而定
pidfile=/var/run/redis.pid
conf="/usr/local/redis/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
fiif [ "$?"="0" ]
then
echo "redis is running..."
fi;;
stop)
if [ ! -f $pidfile ]
then
echo "$pidfile exists, process is not running."
else
pid=$(cat $pidfile)
echo "stopping..."
$redis_cli -p $redisport shutdown
while [ -x $pidfile ]
doecho "waiting for redis to shutdown..."
sleep 1
done
echo "redis stopped"
fi;;
restart|force-reload)
$ stop
$ start
;;*)
echo "usage: /etc/init.d/redis " >&2
exit 1
esac
執行許可權:
chmod +x /etc/init.d/redis
開機自啟動:
# 嘗試啟動或停止redis
service redis start
service redis stop
# 開啟服務自啟動
chkconfig redis on
收工.
redis開機自啟動
一.啟動redis 1.redis server 這種方式啟動,當按ctrl c退出時會關閉啟動 2.redis server 加上 號使redis以後台程式方式執行 二.檢測redis程序後台是否存在的三種方法 1.ps ef grep redis 檢視redis程序 2.netstat lntp...
Redis配置開機自啟動
1.redis開啟守護程序 2.新增開啟啟動配置檔案,修改相應值為實際值,完整檔案見最後 3.修改新增redis啟動指令碼許可權為可執行 chmod x redis4.etc init.d stop 出現stopping error noauth authentication required.錯誤...
redis設定開機自啟動
1 拷貝 redis 安裝目前下的 usr local redis 4.0.8 utils redis init script 到 etc init.d redis檔案中 cp usr local redis 4.0.8 utils redis init script etc init.d redi...