有感:
創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)提供從項(xiàng)目策劃、軟件開發(fā),軟件安全維護(hù)、網(wǎng)站優(yōu)化(SEO)、網(wǎng)站分析、效果評(píng)估等整套的建站服務(wù),主營業(yè)務(wù)為成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè),app軟件定制開發(fā)以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。創(chuàng)新互聯(lián)公司深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
redis玩了許久時(shí)間,真心感覺啟動(dòng)方式還是自己定義的方便!
1)直接啟動(dòng)和關(guān)閉:(配置文件默認(rèn))
開啟:redis-server &(&后臺(tái)運(yùn)行)
#daemonize yes(也可配置文件修改此參數(shù))
關(guān)閉:redis-cli shutdown or killall -9 redis-server
2)指定配置文件啟動(dòng):
redis-server /etc/redis.conf(配置文件可自己定義)
如果更改了redis默認(rèn)端口:
redis-cli shutdown (-p端口)
redis-cli shutdown (-p 端口) (-a 認(rèn)證密碼)
3)自己定義啟動(dòng)文件并配置(推薦)
[root@redis1 ~]# cpredis-2.8.24/utils/redis_init_script /etc/init.d/redis
注冊(cè)為系統(tǒng)服務(wù):
[root@redis1 ~]# sed -i '2i #chkconfig:2345 80 90' /etc/init.d/redis
[root@redis1 ~]# chkconfig --add redis
修改配置文件(因?yàn)槁窂阶约憾x,sed也可以)
REDISPORT=7000 #注意slave端口自己定義即可
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
腳本如下(自己配置的,大家也可在此基礎(chǔ)上進(jìn)行修改)
#!/bin/sh #chkconfig: 2345 80 90 # Simple Redis init.d script conceivedto work on Linux systems # as it does use of the /procfilesystem. REDISPORT=7000 EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/etc/redis/${REDISPORT}.conf" case "$1" in start) if [ -f $PIDFILE ] then echo -e "\033[31m $PIDFILEexists, process is already running or crashed \033[0m" else echo -e "\033[32m Waitingfor Redis to start...\033[0m" $EXEC $CONF if [ $? -eq 0 ] then echo -e "\033[32m Redis isalready started successfully! \033[0m" else echo -e "\033[31m Redisstart fail \033[0m" fi fi ;; stop) if [ ! -f $PIDFILE ] then echo -e "\033[31m $PIDFILEdoes not exist, process is not running \033[0m" else PID=$(cat $PIDFILE) echo -e "\033[32m Waitingfor Redis to stop ... \033[0m" $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo -e "\033[32mWaiting for Redis to shutdown ... \033[0m" sleep 1 done echo -e "\033[32m Redis isalready stopped successfully! \033[0m" fi ;; status) ps aux|grep redis-server|grep-v grep &>/dev/null if [ $? -eq 0 ] then echo -e "\033[32m Redisis running... \033[0m" else echo -e "\033[31m Redisis already stopped \033[0m" fi ;; restart) $CLIEXEC -p $REDISPORT shutdown if [ $? -eq 0 ] then echo -e "\033[32m Redis isalready stopped successfully! \033[0m" else echo -e "\033[31m Redisstop fail \033[0m" fi $EXEC $CONF if [ $? -eq 0 ] then echo -e "\033[32m Redis isalready started successfully! \033[0m" else echo -e "\033[31m Redisstart fail \033[0m" fi ;; *) echo "the usage is service redis start|stop|status|restart" esac
查看redis狀態(tài),啟動(dòng),關(guān)閉,重啟
[root@redis1 ~]# /etc/init.d/redis status Redis is running... [root@redis1 ~]# /etc/init.d/redis stop Waiting for Redis to stop ... Waiting for Redis to shutdown ... Redis is already stopped successfully! [root@redis1 ~]# /etc/init.d/redis start Waiting for Redis to start... Redis is already started successfully! [root@redis1 ~]# /etc/init.d/redis restart Redis is already stopped successfully! Redis is already started successfully! [root@redis1 ~]# [root@redis1 ~]# ps aux|grep redis-server|grep -v grep root 2881 0.1 0.1 128296 1692 ? Ssl 12:45 0:01 /usr/local/redis/bin/redis-server *:7000 [root@redis1 ~]#
分享標(biāo)題:Redis的多種啟動(dòng)方式比較!
瀏覽路徑:http://aaarwkj.com/article20/gihoco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷、面包屑導(dǎo)航、動(dòng)態(tài)網(wǎng)站、商城網(wǎng)站、App設(shè)計(jì)、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)