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 的下载地址:请点这里

本文永久更新链接地址:

相关内容