參照官網:linux
Download, extract and compile Redis with:redis
$ wget http://download.redis.io/releases/redis-2.8.19.tar.gz $ tar xzf redis-2.8.19.tar.gz $ cd redis-2.8.19 $ make
The binaries that are now compiled are available in the src
directory. Run Redis with:bash
$ src/redis-server
You can interact with Redis using the built-in client:編輯器
$ src/redis-cli redis> set foo bar OK redis> get foo "bar"
====================================================================ui
參考另外一安裝過程:spa
我用的系統是:redhat.net
[root@infa ~]# wget http://download.redis.io/releases/redis-2.8.12.tar.gzcode
tar xzf redis-2.8.12.tar.gzorm
[root@infa ~]# tar xzf redis-2.8.12.tar.gzserver
[root@infa ~]# cd redis-2.8.12
[root@infa redis-2.8.12]# ls
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-sentinel sentinel.conf src tests utils
[root@infa redis-2.8.12]# make
可是這樣子編譯會報錯,貌似是由於系統的緣由;
報錯以下:
解決方法,就是加上編譯參數設置,以下:
[root@infa redis-2.8.12]# make CFLAGS="-march=i686"
編譯成功;
啓動並運行redis:
[root@infa redis-2.8.12]# src/redis-server
打開另一個終端運行,redis客戶端
[root@infa redis-2.8.12]# src/redis-cli
127.0.0.1:6379> set name chenzhou
OK
127.0.0.1:6379> get name
"chenzhou"
127.0.0.1:6379>
附2:把Redis做爲Linux服務開機啓動 這裏只提供一種最簡單的方式,最好的是經過編寫開機啓動腳原本作。 若是要開機啓動redis,咱們須要把redis設置爲daemon後臺啓動(若是不設置爲後臺啓動,則linux啓動後圖形界面會卡在一個空白的頁面),而redis只有1個啓動參數,就是redis的配置文件路徑。redis的默認配置文件redis.conf位於redis的安裝目錄下。咱們能夠把該文件copy到/etc目錄下 Shell代碼 1[root@localhost redis-2.6.14]# cp redis.conf /etc/ redis的默認配置文件中daemonize參數的值爲no,表明爲非後臺啓動,因此咱們須要把該參數的值修改成yes。至於其它的參數在這裏就不詳細說了,具體能夠參見:http://blog.csdn.net/htofly/article/details/7686436修改完daemonize參數以後,redis就可以經過daemon方式啓動了,那麼下一步就是把redis加入到linux開機啓動服務配置中了,具體步驟以下: 使用VI編輯器打開Linux開機啓動服務配置文件/etc/rc.local,並在其中加入下面的一行代碼: Shell代碼 2/usr/local/redis-2.6.14/src/redis-server /etc/redis.conf 編輯完後保存,而後重啓系統就OK了。 中止Redis服務: Shell代碼 3src/redis-cli shutdown
指定配置文件啓動redis: redis-server ./redis.conf