CenterOS中安裝Redis及開機啟動設定

來源:互聯網
上載者:User

標籤:

Redis安裝

從官方下載最新Redis進行安裝,官網地址:http://redis.io/download

$ wget http://download.redis.io/releases/redis-3.2.3.tar.gz$ tar xzf redis-3.2.3.tar.gz$ cd redis-3.2.3$ make$ make install

Redis啟動

RedisServer /path/to/redis.conf

Redis關閉(預設port為6379)

RedisCli -p port -a Password shutdown  

查看Reids進程

ps -ef|grep redis

設定Redis開機啟動1:配置init指令碼,把代碼存為Reids,放到/etc/init.d/
############################ chkconfig:   2345 90 10# description:  Redis is a persistent key-value databasePATH=/usr/local/binREDISPORT=6379EXEC=/usr/local/bin/redis-serverREDIS_CLI=/usr/local/bin/redis-cli#Redis密碼PASSWORD=yourPasswordPIDFILE=/var/run/redis.pidCONF="/usr/local/reids/conf/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        if [ "$?"="0" ]         then              echo "Redis is running..."        fi        ;;    stop)        if [ ! -f $PIDFILE ]        then                echo "$PIDFILE does not exist, process is not running"        else                PID=$(cat $PIDFILE)                echo "Stopping ..."                $REDIS_CLI -p $REDISPORT -a $PASSWORD SHUTDOWN                while [ -x ${PIDFILE} ]               do                    echo "Waiting for Redis to shutdown ..."                    sleep 1                done                echo "Redis stopped"        fi        ;;   restart|force-reload)        ${0} stop        ${0} start        ;;  *)    echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2        exit 1esac##############################
注意事項:

  1) 最上面的注釋的意思是,redis服務必須在運行級2,3,4,5下被啟動或關閉,啟動的優先順序是90,關閉的優先順序是10。     

  2) 如果執行命令出現$‘/r‘:command not found,這個問題是在Windows下換行和linux下換行不同,可以通過Nodepad++進行轉換。

2:設定指令碼許可權
chmod +x /etc/init.d/redis  
3:設定開機啟動
sudo chkconfig redis on  
4:使用方法
service redis start   #或者 /etc/init.d/redis startservice redis stop   #或者 /etc/init.d/redis stop

 

CenterOS中安裝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.