歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習Linux

centos安裝redis3為系統服務

centos安裝redis3為系統服務


centos安裝redis3為系統服務


#無wget,請通過命令yuminstallwget安裝wgethttp://download.redis.io/releases/redis-3.0.1.tar.gztarxzfredis-3.0.1.tar.gzcdredis-3.0.1make#如果無make命令,請下載yuminstallgccmakemaketestmakeinstall

安裝好了redis後,須注意拷貝bin文件到usr/local/bin(這步很重要,無這步會報錯)

?cpredis-server/usr/local/bin/cpredis-cli/usr/local/bin

之後修改redis.conf,打開後台運行選項:

?daemonizeyes

編寫啟動shell:vim/etc/init.d/redis(copy網上的)

?#chkconfig:23451090#description:StartandStopredisPATH=/usr/local/bin:/sbin:/usr/bin:/binREDISPORT=6379#實際環境而定EXEC=/usr/local/redis/src/redis-server#實際環境而定REDIS_CLI=/usr/local/redis/src/redis-cli#實際環境而定PIDFILE=/var/run/redis.pidCONF="/usr/local/redis/redis.conf"#實際環境而定case"$1"instart)if[-f$PIDFILE]thenecho"$PIDFILEexists,processisalreadyrunningorcrashed."elseecho"StartingRedisserver..."$EXEC$CONFfiif["$?"="0"]thenecho"Redisisrunning..."fi;;stop)if[!-f$PIDFILE]thenecho"$PIDFILEexists,processisnotrunning."elsePID=$(cat$PIDFILE)echo"Stopping..."$REDIS_CLI-p$REDISPORTSHUTDOWNwhile[-x$PIDFILE]doecho"WaitingforRedistoshutdown..."sleep1doneecho"Redisstopped"fi;;restart|force-reload)${0}stop${0}start;;*)echo"Usage:/etc/init.d/redis{start|stop|restart|force-reload}">&2exit1esac

賦予權限chmod+x /etc/init.d/redis

設置開機啟動:

?#嘗試啟動或停止redisserviceredisstartserviceredisstop#開啟服務自啟動chkconfigredison

http://xxxxxx/Linuxjc/1134260.html TechArticle

Copyright © Linux教程網 All Rights Reserved