CentOS 6.4 64位安裝Redis

來源:互聯網
上載者:User

CentOS 6.4 64位安裝Redis

一、介紹

REmote DIctionary Server(Redis)是一個key-value儲存系統。和Memcached類似,它支援儲存的value類型相對更多,包括string(字串)、list(鏈表)、set(集合)、zset(sorted set --有序集合)和hash(雜湊類型)。這些資料類型都支援push/pop、add/remove及取交集並集和差集及更豐富的操作,而且這些操作都是原子性的。在此基礎上,redis支援各種不同方式的排序。與memcached一樣,為了保證效率,資料都是緩衝在記憶體中。區別的是redis會周期性的把更新的資料寫入磁碟或者把修改操作寫入追加的記錄檔案,並且在此基礎上實現了master-slave(主從)同步。

Redis 是一個高效能的key-value資料庫。 redis的出現,很大程度補償了memcached這類key/value儲存的不足,在部分場合可以對關聯式資料庫起到很好的補充作用。它提供了Java,C/C++,C#,PHP,JavaScript,Perl,Object-C,Python,Ruby,Erlang等用戶端,使用很方便。

Redis支援主從同步,資料可以從主伺服器向任意數量的從伺服器上同步,從伺服器可以是關聯其他從伺服器的主伺服器。這使得Redis可執行單層樹複製。從庫可以有意無意的對資料進行寫操作。由於完全實現了發布/訂閱機制,使得從資料庫在任何地方同步樹時,可訂閱一個頻道並接收主伺服器完整的訊息發布記錄。同步對讀取操作的可擴充性和資料冗餘很有協助。

二、安裝

Redis安裝超級簡單

1、解壓  tar zxvf redis-2.8.18.tar.gz到任意目錄

2、編譯  make

make命令執行完成後,會在目前的目錄下產生多個可執行檔,分別是redis-server、redis-cli、redis-benchmark、redis-stat,它們的作用如下:

  • redis-server:Redis伺服器的daemon啟動程式
  • redis-cli:Redis命令列操作工具,Redis用戶端
  • redis-benchmark:Redis效能測試工具,測試Redis在你的系統及你的配置下的讀寫效能
  • redis-stat:Redis狀態偵查工具,可以檢測Redis目前狀態參數及延遲狀況

三、測試

系統:CentOS 6.4 64位

redis:Redis 2.8.18

[root@localhost redis]# tar zxvf redis-2.8.18.tar.gz -C /usr/local/redis/        #源碼包解壓到指定目錄

[root@localhost redis-2.8.18]# cd /usr/local/redis/redis-2.8.18/                  #進入該目錄

[root@localhost redis-2.8.18]# make

編譯後的可執行檔在src目錄中,可以使用下面的命令運行Redis:

[root@localhost redis-2.8.18]# ./src/redis-server

[26720] 21 Dec 23:38:07.043 # Warning: no config file specified, using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf

[26720] 21 Dec 23:38:07.045 * Increased maximum number of open files to 10032 (it was originally set to 1024).

              _._                                                 
          _.-``__ ''-._                                           
      _.-``    `.  `_.  ''-._          Redis 2.8.18 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                 
 (    '      ,      .-`  | `,    )    Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|    Port: 6379
 |    `-._  `._    /    _.-'    |    PID: 26720
  `-._    `-._  `-./  _.-'    _.-'                                 
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |          http://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                 
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                 
      `-._    `-.__.-'    _.-'                                     
          `-._        _.-'                                         
              `-.__.-'                     

[26720] 21 Dec 23:38:07.069 # Server started, Redis version 2.8.18
[26720] 21 Dec 23:38:07.070 # 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.
[26720] 21 Dec 23:38:07.072 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
[26720] 21 Dec 23:38:07.078 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
[26720] 21 Dec 23:38:07.078 * The server is now ready to accept connections on port 6379


注意:這時候redis是獨佔方式啟動的,預設連接埠6379,要串連redis需要從新開啟一個視窗

            如果想改變Redis啟動方式,可以修改Redis設定檔redis.conf(解壓後的目錄裡就有,這裡是:/usr/local/redis/redis-2.8.18)

            關於redis.conf中的參數,後面我會專門寫一遍部落格來解釋,期待吧^_^

你可以使用內建的用戶端串連Redis

[root@localhost redis-2.8.18]# ./src/redis-cli
127.0.0.1:6379> set mykey wangxiuli
OK
127.0.0.1:6379> get mykey
"wangxiuli"
127.0.0.1:6379>

是不是很簡單,我們已經安裝成功了。

Ubuntu 14.04下Redis安裝及簡單測試

Redis叢集明細文檔

Ubuntu 12.10下安裝Redis(圖文詳解)+ Jedis串連Redis

Redis系列-安裝部署維護篇

CentOS 6.3安裝Redis

Redis安裝部署學習筆記

Redis設定檔redis.conf 詳解

Redis 的詳細介紹:請點這裡
Redis 的:請點這裡

本文永久更新連結地址:

相關文章

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.