天天看點

Redis搭建

一. 環境

  • centos7.4

二. YUM搭建Redis

1 yum -y install  epel-release
2 yum -y install redis
3 systemctl enable redis.service
4 systemctl start redis.service
5 systemctl status redis.service
6 netstat -lnutp | grep 6379      

三.  編譯安裝Redis

3.1.1編譯安裝

1 wget http://download.redis.io/releases/redis-4.0.0.tar.gz
 2 mkdir /usr/local/redis/
 3 mkdir /data/redis/ -p
 4 tar xf redis-4.0.0.tar.gz 
 5 mv redis-4.0.0/* /usr/local/redis/
 6 cd /usr/local/redis/
 7 make
 8 echo $?
 9 cp redis.conf /data/redis/
10 cp src/redis-server /data/redis/
11 cd /data/redis/
12 ln -s /usr/local/redis/src/redis-cli /usr/bin/redis-cli
13 ./redis-server ./redis.conf 
14 netstat -lnutp | grep 6379      

3.1.2配置啟動腳本

1 [Unit]
 2 #描述資訊
 3 Description=Redis Server 3.0.4
 4 #啟動時機,開機啟動最好在網絡服務啟動後即啟動
 5 After=network.target
 6 [Service]
 7 #此處為指令行啟動redis的指令及參數,可參考官方文檔
 8 ExecStart=/data/redis/redis-server /data/redis/redis.conf --daemonize no  
 9 #停止redis伺服器指令
10 ExecStop=/usr/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown 
11 User=redis #運作reddis使用者
12 Group=redis #所屬組
13 [Install]
14 WantedBy=multi-user.target #字元界面下啟動      

3.1.3 測試systemctl管理啟動

1 systemctl enable redis.service
2 systemctl stop redis.service
3 systemctl start redis.service
4 systemctl status redis.service
5 netstat -lnutp | grep 6379      

作者:闫世成

出處:http://cnblogs.com/yanshicheng

聯系:[email protected]

本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接配接。如有問題或建議,請聯系上述郵箱,非常感謝。

下一篇: Redis簡介

繼續閱讀