环境:Centos 6.2
redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统。和Memcached类似,但很大程度补偿了memcached的不足,它支持存储的value类型相对更多,包括string、list、set、zset和hash。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作。在此基础上,redis支持各种不同方式的排序。Redis数据都是缓存在计算机内存中,并且会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件。
redis官网地址:http://www.redis.io/
1、下载文件
http://download.redis.io/releases/redis-2.8.3.tar.gz
redis-2.8.3.tar.gz文件下载成功后上传至/usr/local
2、安装
[[email protected] local]# mkdir /usr/local/redis
[[email protected] local]#tar xzf redis-2.8.3.tar.gz
[[email protected] local]#cd redis-2.8.3
[[email protected] redis-2.8.3]#make
3、编译完成后,在Src目录下,有三个可执行文件redis-server、redis-benchmark、redis-cli。然后拷贝到一个目录下。
[[email protected] redis-2.8.3]# cd src
[[email protected] src]# cp redis-server /usr/local/redis
[[email protected] src]# cp redis-benchmark /usr/local/redis
[[email protected] src]# cp redis-cli /usr/local/redis
4、启动服务器的服务
[[email protected] src]# cd /usr/local/redis
[[email protected] redis]# ll
total 13688
-rwxr-xr-x. 1 root root 4156999 Jan 1 23:26 redis-benchmark
-rwxr-xr-x. 1 root root 4229443 Jan 1 23:27 redis-cli
-rwxr-xr-x. 1 root root 5627506 Jan 1 23:26 redis-server
[[email protected] redis]# ./redis-server
[4445] 01 Jan 23:28:56.519 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
[4445] 01 Jan 23:28:56.520 * Max number of open files set to 10032
_._
_.-``__ ‘‘-._
_.-`` `. `_. ‘‘-._ Redis 2.8.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ‘‘-._
( ‘ , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|‘` _.-‘| Port: 6379
| `-._ `._ / _.-‘ | PID: 4445
`-._ `-._ `-./ _.-‘ _.-‘
|`-._`-._ `-.__.-‘ _.-‘_.-‘|
| `-._`-._ _.-‘_.-‘ | http://redis.io
`-._ `-._`-.__.-‘_.-‘ _.-‘
|`-._`-._ `-.__.-‘ _.-‘_.-‘|
| `-._`-._ _.-‘_.-‘ |
`-._ `-._`-.__.-‘_.-‘ _.-‘
`-._ `-.__.-‘ _.-‘
`-._ _.-‘
`-.__.-‘
[4445] 01 Jan 23:28:56.543 # Server started, Redis version 2.8.3
[4445] 01 Jan 23:28:56.544 # 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.
[4445] 01 Jan 23:28:56.544 * The server is now ready to accept connections on port 6379
5、然后用客户端测试一下是否启动成功。(打开另外一个终端运行,redis客户端)
[[email protected] redis]# cd /usr/local/redis
[[email protected] redis]# ./redis-cli
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379>