Redis编译及安装

redis是什么?

Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
redis是开源,BSD许可,高级的key-value存储系统,可以用来存储字符串,哈希结构,链表,集合,因此,常用来提供数据结构服务。

redis和memcached相比,的独特之处:

1、redis可以用来做存储(storge), 而memccached是用来做缓存(cache)
这个特点主要因为其有”持久化”的功能;
2、 存储的数据有”结构”,对于memcached来说,存储的数据,只有1种类型–”字符串”,
而redis则可以存储字符串,链表,哈希结构,集合,有序集合。

Redis下载及编译:

1、 官方站点:http://redis.io/,下载最新版或stable版(当前为 Redis 3.0.5 is the latest stable version:http://download.redis.io/releases/redis-3.0.5.tar.gz);
2、解压源码并进入目录:cd redis-3.0.5;
3、不用configure,源码是官方configure过的,但官方configure时,生成的文件有时间戳信息,Make只能发生在configure之后如果你的虚拟机的时间不对,比如说是2012年,解决: date -s ‘yyyy-mm-dd hh:mm:ss’重写时间,再 clock -w 写入cmos;
4、直接make,如果是32位机器,采用make 32bit;
5、可选步骤: make test 测试编译情况,可能出现如下情况:

[hyx@hadoop redis-3.0.5]$ make test
cd src && make test
make[1]: 进入目录“/opt/redis-3.0.5/src”
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] 错误 1
make[1]: 离开目录“/opt/redis-3.0.5/src”
make: *** [test] 错误 2

通过安装tcl解决(yum install tcl);
6、安装到指定目录,如/usr/local/redis

make PREFIX=/usr/local/redis install

注意:PREFIX必需为大写
7、make install之后,得到如下几个文件

文件名 功能
redis-benchmark 性能测试工具
redis-check-aof aof日志文件检测工具(比如断电造成日志损坏,可以检测并修复)
redis-check-dump rdb快照文件检测工具,效果同上
redis-cli 客户端
redis-server 服务端

8、将源码中redis.conf拷贝到/usr/local/redis目录;

启动并测试

1、进行后台启动:修改redis.conf中“daemonize no”为“daemonize yes”

./bin/redis-server redis.conf

2、查看启动日志:vi redis.log

11020:M 14 Dec 19:48:01.026 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
11020:M 14 Dec 19:48:01.026 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted. 11020:M 14 Dec 19:48:01.026 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.5 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 11020 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 11020:M 14 Dec 19:48:01.027 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 11020:M 14 Dec 19:48:01.027 # Server started, Redis version 3.0.5 11020:M 14 Dec 19:48:01.027 # 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. 11020:M 14 Dec 19:48:01.027 # 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. 11020:M 14 Dec 19:48:01.027 * DB loaded from disk: 0.000 seconds 11020:M 14 Dec 19:48:01.027 * The server is now ready to accept connections on port 6379

3、启动客户端连接并测试:

[hyx@hadoop redis]$ ./bin/redis-cli 
127.0.0.1:6379> set test redis
OK
127.0.0.1:6379> get test
"redis"
127.0.0.1:6379>

到此redis编译、安装及测试完全通过;

你可能感兴趣的:(redis,安装,编译)