Redis是一个开源、支持网络、基于内存、键值对存储数据库,使用ANSI C编写。是比较热门的 NOSQL 非关系性数据库之一,它是一个 key-value 存储系统,与 Memcached 类似但是很大程度的填补了 Memcached 的不足,支持存储的value类型相对更多,包括string、list、set、zset和hash,这些数据类型都支持push/pop、add/remove以及取交集并集差集等更多的操作。
Redis的外围由一个键、值映射的字典构成。与其他非关系型数据库主要不同在于:Redis中值的类型不仅限于字符串,还支持如下抽象数据类型:
1)字符串列表
2)无序不重复的字符串集合
3)有序不重复的字符串集合
4)键、值都为字符串的哈希表
Redis 官方地址:http://www.redis.io/,目前最新版本是 redis-3.0.5.tar.gz
下面为大家讲述一下在 Linux 系统 安装 Redis 的具体步骤:
1、通过 Linux 中 wget 命令,远程下载源码,并解压后进行编译源码如下:
[root@iZ256w2hluuZ local]# wget http://download.redis.io/releases/redis-3.0.5.tar.gz [root@iZ256w2hluuZ local]# tar xzf redis-3.0.5.tar.gz [root@iZ256w2hluuZ local]# cd redis-3.0.5 [root@iZ256w2hluuZ redis-3.0.5]# make
2、执行 Linux 中 ll 命令,查看目录下结构:
[root@iZ256w2hluuZ redis-3.0.5]# ll total 148 -rw-rw-r-- 1 root root 32593 Oct 15 21:44 00-RELEASENOTES -rw-rw-r-- 1 root root 53 Oct 15 21:44 BUGS -rw-rw-r-- 1 root root 1439 Oct 15 21:44 CONTRIBUTING -rw-rw-r-- 1 root root 1487 Oct 15 21:44 COPYING drwxrwxr-x 6 root root 4096 Oct 15 21:44 deps -rw-rw-r-- 1 root root 11 Oct 15 21:44 INSTALL -rw-rw-r-- 1 root root 151 Oct 15 21:44 Makefile -rw-rw-r-- 1 root root 4223 Oct 15 21:44 MANIFESTO -rw-rw-r-- 1 root root 5201 Oct 15 21:44 README -rw-rw-r-- 1 root root 41560 Oct 15 21:44 redis.conf -rwxrwxr-x 1 root root 271 Oct 15 21:44 runtest -rwxrwxr-x 1 root root 280 Oct 15 21:44 runtest-cluster -rwxrwxr-x 1 root root 281 Oct 15 21:44 runtest-sentinel -rw-rw-r-- 1 root root 7109 Oct 15 21:44 sentinel.conf drwxrwxr-x 2 root root 4096 Oct 15 21:44 src drwxrwxr-x 10 root root 4096 Oct 15 21:44 tests drwxrwxr-x 5 root root 4096 Oct 15 21:44 utils
3、编译完成后在 src 目录下有四个可执行文件,Copy 到一个新目录假设为 redis 名(新增目录)中,具体命令如下:
[root@iZ256w2hluuZ src]# mkdir /usr/redis [root@iZ256w2hluuZ src]# cp redis-server /usr/redis [root@iZ256w2hluuZ src]# cp redis-benchmark /usr/redis [root@iZ256w2hluuZ src]# cp redis-cli /usr/redis [root@iZ256w2hluuZ src]# cp redis.conf /usr/redis [root@iZ256w2hluuZ src]# cd /usr/redis
4、赋予执行文件权限,命令如下:
[root@iZ256w2hluuZ redis]# chmod 777 *
5、启动 redis 服务,执行命令如下:
[root@iZ256w2hluuZ redis]# /redis-server ./redis.conf
6、使用客户端测试,是否启动成功,执行如下:
[root@iZ256w2hluuZ redis]# redis-cliredis> set yood yoodb OK redis> get yood "yoodb"