(二)redis的啟動和關閉

來源:互聯網
上載者:User

標籤:redis   redis啟動與關閉   

使用redis-server 帶上設定檔方式啟動

[[email protected] utils]# redis-server /etc/redis/6379.conf[[email protected] utils]# ps -ef | grep redis              root       9662      1 0 15:47 ?        00:00:00redis-server *:6379             root       9670   3834 0 15:47 pts/1    00:00:00 grepredis


關閉redis

使用redis-cli跟上shutdown來關閉redis[[email protected] utils]# redis-cli -p 6379 shutdown[[email protected] utils]# ps -ef | grep redis              root       9674   3834 0 15:48 pts/1    00:00:00 grepredis直接使用sysV指令碼關掉redis[[email protected] utils]# /etc/init.d/redis_6379 stopStopping ...Redis stopped


讓服務以前台方式運行

[[email protected] utils]# grep daemonize/etc/redis/6379.conf              # Note that Redis will write a pid file in/var/run/redis.pid when daemonized.daemonize yes   #這裡的daemonize值為yes,表示以後台方式運行如果把這個值改成no,那麼redis服務將以前台方式運行# When running daemonized, Redis writes a pid file in/var/run/redis.pid by# output for logging but daemonize, logs will be sent to/dev/null#示範這個過程,視窗1[[email protected] utils]# sed -i ‘/^daemonize/s/yes/no/g‘/etc/redis/6379.conf  #替換yes為no[[email protected] utils]# grep daemonize/etc/redis/6379.conf                 # Note that Redis will write a pid file in/var/run/redis.pid when daemonized.daemonize no    #確認一下這個值是否發生了變化# When running daemonized, Redis writes a pid file in /var/run/redis.pidby# output for logging but daemonize, logs will be sent to/dev/null#當前沒有任何啟動的redis[[email protected] utils]# ps -ef | grep redisroot       9725   3834 0 15:56 pts/1    00:00:00 grepredis[[email protected] utils]# redis-server /etc/redis/6379.conf  #這個時候視窗應該是hang住的#視窗2[[email protected] ~]# ps -ef | grep redisroot       9730   3834 0 15:56 pts/1    00:00:00redis-server *:6379             root       9749   9735 0 15:56 pts/0    00:00:00 grepredis[[email protected] ~]# redis-cli -p 6379127.0.0.1:6379> set k1 1OK127.0.0.1:6379> get k1"1"127.0.0.1:6379> shutdown    #當shutdown命令敲下去之後,剛才的前台進程也釋放了終端游標其實不應該讓redis在前台啟動,所以設定檔中的這個值還是改回來吧。[[email protected] utils]# sed -i ‘/^daemonize/s/no/yes/g‘/etc/redis/6379.conf          [[email protected] utils]# grep daemonize/etc/redis/6379.conf                 # Note that Redis will write a pid file in/var/run/redis.pid when daemonized.daemonize yes# When running daemonized, Redis writes a pid file in/var/run/redis.pid by# output for logging but daemonize, logs will be sent to/dev/null


如何查看redis是否在運行中

通過ps命令判斷[[email protected] utils]# /etc/init.d/redis_6379 startStarting Redis server...[[email protected] utils]# /etc/init.d/redis_6378 startStarting Redis server...[[email protected] utils]# ps -ef | grep redis        #能看到進程號root       9801      1 0 16:02 ?        00:00:00/usr/local/bin/redis-server *:6378             root       9814      1 0 16:03 ?        00:00:00 /usr/local/bin/redis-server*:6379             root       9818   3834 0 16:03 pts/1    00:00:00 grepredis通過redis-cli判斷,可以串連進redis[[email protected] utils]# redis-cli -p 6378127.0.0.1:6378> exit[[email protected] utils]# redis-cli -p 6379127.0.0.1:6379> exit


本文出自 “名字長一點會好記” 部落格,請務必保留此出處http://xiaoyiyi.blog.51cto.com/1351449/1705710

(二)redis的啟動和關閉

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.