redis安裝和使用

來源:互聯網
上載者:User

 一、redis安裝

        1)下載redis最新穩定版:http://redis.googlecode.com/files/redis-2.4.14.tar.gz

        2)解壓安裝:make & make test

        3)可能需要安裝tcl8.5:

             3.1)下載tcl8.5源碼包:wget http://downloads.sourceforge.net/tcl/tcl8.5.10-src.tar.gz

             3.2)解壓 安裝 :cd unix/ & ./configure --prefix=/usr --enable-threads --mandir=/usr/share/man

             3.3)make & sed -i -e "s@^\(TCL_SRC_DIR='\).*@\1/usr/include'@" -e "/TCL_B/s@='\(-L\)\?.*unix@='\1/usr/lib@"  tclConfig.sh

             3.4)make test & make install && make install-private-headers && ln -v -sf tclsh8.5 /usr/bin/tclsh && chmod -v 755 /usr/lib/libtcl8.5.so

       4)安裝:make install

       5)修改設定檔:vi /etc/redis.conf    

daemonize yes   #是否後台進程(yes/no)pidfile /usr/local/redis/var/redis.pid  #pid檔案路徑port 6379   #redis server監聽連接埠bind 127.0.0.1  #設定redis綁定的 interface,如果不設定,則搬到所有timeout 300      #用戶端連線逾時時間loglevel debug   #日誌等級(debug/verbose/notice/warning)logfile /usr/local/redis/var/redis.log  #記錄檔路徑(stdout/file路徑)databases 16     #資料庫的數量,預設資料庫為 DB 0save 90 100000       #資料庫儲存到磁碟的方式:save <seconds> <changes> rdbcompression yes   #是否對資料庫資料進行壓縮dbfilename dump.rdb  #資料庫資料檔案名稱dir /usr/local/redis/var/   #資料庫資料目錄appendonly no           #是否開啟每個操作記錄一條日誌功能appendfsync always      #(no 等到系統同步 always 每條記錄同步一次 everysec 每秒同步一次)glueoutputbuf yes       #shareobjects noshareobjectspoolsize 1024

       6)啟動redis server :/usr/local/bin/redis-server /etc/redis.conf

二、安裝redis-py   (redis-py不支援python 2.4)

        在修改了部分redis-py的源碼後,終於安裝成功,測試結果如下:

[root@test redis-2.4.13]# pythonPython 2.4.3 (#1, Feb 22 2012, 16:05:45) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import redis>>> r = redis.StrictRedis(host='127.0.0.1', port=6379)>>> r.set('foo', 'hello') True>>> r.rpush('mylist', 'one')1L>>> print r.get('foo') hello>>> print r.rpop('mylist')one>>> 

     

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.