CentOS安裝與配置redis

官網地址:https://redis.io/download

下載地址:http://download.redis.io/releases

GitHub地址:(linux) https://github.com/antirez/redis       (windows)https://github.com/microsoftarchive/redis

1、安裝步驟:

 #下載安裝包
 wget http://download.redis.io/releases/redis-5.0.8.tar.gz
 #解壓
 tar xzf redis-5.0.8.tar.gz
 cd redis-5.0.8
 #編譯和安裝(默認安裝在src目錄下,安裝包下的Makefile中記錄了)
 make install

2、常用操作命令 

2.1 啓動redis服務:redis-server

      帶端口號啓動(可以用於啓動多個redis實例):redis-server --port [端口號]

      後臺啓動:redis-server --daemonize yes

2.2 使用配置文件啓動redis:

   a、配置文件默認就在解壓後的文件夾下面,查看配置文件:cat redis.conf

   b、配置文件裏面#註釋和空行太多,過濾後查看:cat redis.conf | grep -v "#" | grep -v "^$"

   c、原始的配置文件不建議改動,創建一個新的配置文件:cat redis.conf | grep -v "#" | grep -v "^$" > redis-6379.conf

   d、修改配置文件,主要修改以下四項:vi redis-6379.conf

port 6379   #指定端口號
daemonize yes  #後臺運行,不佔用窗口
logfile "6379.log"  #指定日誌文件名稱
dir /usr/local/redis/redis-5.0.8/data #日誌存放位置

            e、 啓動reids: redis-server redis-6379.conf 

2.2 使用redis-cli客戶端:redis-cli -h 47.11.16.61 -p 6379 -a cxddf^&2032115

                                        redis-cli -h [IP] -p [端口] -a [密碼]

2.2 關閉redis:redis-cli -h [IP] -p [端口]  shutdown

      查看進程關閉:ps -ef | grep redis              kill -9 [processId]

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章