Redis(2)Linux下Redis的安裝

一、下載Redis最新可用版本

從Redis官網:http://redis.io/download獲取最新Stable版本,目前最新的版本爲redis-3.2.0.tar.gz。

二、上傳 redis-3.2.0.tar.gz 至相應目錄

三、執行命令

(1) 解壓縮

tar zxvf redis-3.2.0.tar.gz

(2) 進入目錄

cd redis-3.2.0

(3)  編譯

make

四、驗證安裝是否成功

(1)啓動Redis

在redis目錄下執行如下命令:

src/redis-server
3019:M 12 May 23:49:06.084 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
3019:M 12 May 23:49:06.085 * DB loaded from disk: 0.000 seconds
3019:M 12 May 23:49:06.086 * The server is now ready to accept connections on port 6379

說明Redis啓動成功

當然也可指定配置文件啓動

src/redis-server redis.conf

(2)連接客戶端

在redis目錄下執行如下命令:

src/redis-cli
簡單測試:

127.0.0.1:6379> set a helloworld
 OK
127.0.0.1:6379> get a
 "helloworld"
127.0.0.1:6379> 
說明Redis安裝成功了。

(3)關閉Redis

src/redis-cli shutdown

(4)非Redis安裝目錄啓動配置

         Linux下安裝完Redis後,啓動需要進入Redis安裝目錄,輸入src/Redis-server啓動,那麼如何配置非Redis目錄下啓動呢,下面我們來看看這種方式的配置。

執行如下命令:

[root@RedHat1 redis-3.2.0]# cp redis.conf /etc/
[root@RedHat1 src]# cp redis-benchmark /usr/bin/
[root@RedHat1 src]# cp redis-server    /usr/bin/
[root@RedHat1 src]# cp redis-cli       /usr/bin/
我們試試在根目錄下啓動
[root@RedHat1 ~]# pwd
/root
[root@RedHat1 ~]# redis-server
啓動成功。

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