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存储的不足,在部分场合可以对关系数据库起到很好的补充作用。它提供了Python,Ruby,Erlang,PHP客户端,使用很方便。
Redis支持主从同步。数据可以从主服务器向任意数量的从服务器上同步,从服务器可以是关联其他从服务器的主服务器。这使得Redis可执行单层树复制。从盘可以有意无意的对数据进行写操作。由于完全实现了发布/订阅机制,使得从数据库在任何地方同步树时,可订阅一个频道并接收主服务器完整的消息发布记录。同步对读取操作的可扩展性和数据冗余很有帮助。
[root@master redis]# pwd
/usr/local/yting/redis
[root@master redis]# ls
redis-2.8.9.tar.gz
[root@master redis]# tar -zxvf redis-2.8.9.tar.gz
[root@master redis]# cd redis-2.8.9
[root@master redis-2.8.9]# ls
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-sentinel sentinel.conf src tests utils
[root@master redis-2.8.9]# make
[root@master redis-2.8.9]# make test
然后会出现这样的结果,这中间可能会出现TCL错误,只要安装TCL就行了,下面有安装方法
[root@master redis-2.8.9]# make install
[root@master redis-2.8.9]# cd src/
[root@master src]# ls
adlist.c anet.h config.h dict.o lzf_c.c migrate.o pqsort.h redis-benchmark redis-cli.c rio.c setproctitle.o syncio.o t_zset.o zipmap.o
adlist.h anet.o config.o endianconv.c lzf_c.o mkreleasehdr.sh pqsort.o redis-benchmark.c redis-cli.o rio.h sha1.c testhelp.h util.c zmalloc.c
adlist.o aof.c crc64.c endianconv.h lzf_d.c multi.c pubsub.c redis-benchmark.o redis.h rio.o sha1.h t_hash.c util.h zmalloc.h
ae.c aof.o crc64.h endianconv.o lzf_d.o multi.o pubsub.o redis.c redis.o scripting.c sha1.o t_hash.o util.o zmalloc.o
ae_epoll.c asciilogo.h crc64.o fmacros.h lzf.h networking.c rand.c redis-check-aof redis-sentinel scripting.o slowlog.c t_list.c valgrind.sup
ae_evport.c bio.c db.c help.h lzfP.h networking.o rand.h redis-check-aof.c redis-server sds.c slowlog.h t_list.o version.h
ae.h bio.h db.o hyperloglog.c Makefile notify.c rand.o redis-check-aof.o release.c sds.h slowlog.o t_set.c ziplist.c
ae_kqueue.c bio.o debug.c hyperloglog.o Makefile.dep notify.o rdb.c redis-check-dump release.h sds.o solarisfixes.h t_set.o ziplist.h
ae.o bitops.c debug.o intset.c memtest.c object.c rdb.h redis-check-dump.c release.o sentinel.c sort.c t_string.c ziplist.o
ae_select.c bitops.o dict.c intset.h memtest.o object.o rdb.o redis-check-dump.o replication.c sentinel.o sort.o t_string.o zipmap.c
anet.c config.c dict.h intset.o migrate.c pqsort.c redisassert.h redis-cli replication.o setproctitle.c syncio.c t_zset.c zipmap.h
[root@master src]# ./redis-server (使用默认配置)
看起来很厉害的样纸、、、
[root@master redis-2.8.9]# mkdir conf
[root@master redis-2.8.9]# cp redis.conf conf/
[root@master redis-2.8.9]# cd conf/
[root@master conf]# pwd
/usr/local/yting/redis/redis-2.8.9/conf
[root@master conf]# ll
total 32
-rw-r--r-- 1 root root 31205 May 26 16:30 redis.conf
[root@master conf]#
[root@master redis-2.8.9]# pwd
/usr/local/yting/redis/redis-2.8.9
[root@master redis-2.8.9]# ls
00-RELEASENOTES BUGS conf CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-sentinel sentinel.conf src tests utils
[root@master redis-2.8.9]# mkdir bin
[root@master redis-2.8.9]# cd bin/
[root@master bin]# ln ../src/redis-serverredis-server
[root@master bin]# ln ../src/redis-cli redis-cli
[root@master bin]# ll
total 9756
-rwxr-xr-x 2 root root 4259855 May 26 16:05 redis-cli
-rwxr-xr-x 3 root root 5723167 May 26 16:05redis-server
[root@master bin]# vi /etc/profile.d/yting.sh(自己新建了一个yting.sh文件,里面写path什么的,不清楚的话可以百度下)
[root@master bin]# source /etc/profile
[root@master bin]# redis-benchmark -h localhost -p6379 -c 100 -n 100000
====== PING_INLINE ======
100000requests completed in 1.19 seconds
100 parallelclients
3 bytespayload
keep alive: 1
99.58% <= 1 milliseconds
100.00% <= 2 milliseconds
84033.61 requests per second
====== PING_BULK ======
100000requests completed in 1.17 seconds
100 parallelclients
3 bytespayload
keep alive: 1
# Redis的客户端
100.00% <= 0 milliseconds
85543.20 requests per second
[18025] 26 May 16:54:25.684 * 100 changes in 300seconds. Saving...
[18025] 26 May 16:54:25.685 * Background saving startedby pid 18236
[18236] 26 May 16:54:25.693 * DB saved on disk
[18236] 26 May 16:54:25.693 * RDB: 4 MB of memoryused by copy-on-write
[18025] 26 May 16:54:25.785 * Background savingterminated with success
====== SET ======
100000requests completed in 1.35 seconds
100 parallelclients
3 bytespayload
keep alive: 1
99.65% <= 1 milliseconds
100.00% <= 1 milliseconds
74183.98 requests per second
====== GET ======
100000requests completed in 1.16 seconds
100 parallelclients
3 bytespayload
keep alive: 1
99.89% <= 1 milliseconds
100.00% <= 1 milliseconds
86132.64 requests per second
====== INCR ======
100000requests completed in 1.16 seconds
100 parallelclients
3 bytespayload
keep alive: 1
99.65% <= 1 milliseconds
100.00% <= 1 milliseconds
85910.65 requests per second
====== LPUSH ======
100000requests completed in 1.09 seconds
100 parallelclients
3 bytespayload
keep alive: 1
99.98% <= 1 milliseconds
100.00% <= 1 milliseconds
91407.68 requests per second
====== LPOP ======
100000requests completed in 1.17 seconds
100 parallelclients
3 bytespayload
keep alive: 1
94.31% <= 1 milliseconds
99.98% <= 2 milliseconds
100.00% <= 3 milliseconds
100.00% <= 3 milliseconds
85324.23 requests per second
====== SADD ======
100000requests completed in 1.32 seconds
100 parallelclients
3 bytespayload
keep alive: 1
35.02% <= 1 milliseconds
99.95% <= 2 milliseconds
100.00% <= 2 milliseconds
75585.79 requests per second
====== SPOP ======
100000requests completed in 1.29 seconds
100 parallelclients
3 bytespayload
keep alive: 1
99.78% <= 1 milliseconds
100.00% <= 1 milliseconds
77639.75 requests per second
====== LPUSH (needed to benchmark LRANGE) ======
100000requests completed in 1.38 seconds
100 parallelclients
3 bytespayload
keep alive: 1
87.86% <= 1 milliseconds
100.00% <= 2 milliseconds
100.00% <= 2 milliseconds
72358.90 requests per second
====== LRANGE_100 (first 100 elements) ======
100000requests completed in 2.08 seconds
100 parallelclients
3 bytespayload
keep alive: 1
78.60% <= 1 milliseconds
99.91% <= 2 milliseconds
100.00% <= 2 milliseconds
48169.56 requests per second
====== LRANGE_300 (first 300 elements) ======
100000requests completed in 5.14 seconds
100 parallelclients
3 bytespayload
keep alive: 1
0.01% <= 1 milliseconds
0.02% <= 2 milliseconds
93.94% <= 3 milliseconds
96.40% <= 4 milliseconds
99.72% <= 5 milliseconds
99.99% <= 6 milliseconds
100.00% <= 6 milliseconds
19466.62 requests per second
====== LRANGE_500 (first 450 elements) ======
100000requests completed in 6.99 seconds
100 parallelclients
3 bytespayload
keep alive: 1
0.01% <= 1 milliseconds
0.02% <= 2 milliseconds
5.52% <= 3 milliseconds
95.79% <= 4 milliseconds
99.92% <= 5 milliseconds
99.97% <= 6 milliseconds
99.99% <= 7 milliseconds
100.00% <= 7 milliseconds
14304.10 requests per second
====== LRANGE_600 (first 600 elements) ======
100000requests completed in 9.91 seconds
100 parallelclients
3 bytespayload
keep alive: 1
0.01% <= 1 milliseconds
0.03% <= 2 milliseconds
0.07% <= 3 milliseconds
3.67% <= 4 milliseconds
85.32% <= 5 milliseconds
92.15% <= 6 milliseconds
93.30% <= 7 milliseconds
96.49% <= 8 milliseconds
99.08% <= 9 milliseconds
99.96% <= 10 milliseconds
99.99% <= 11 milliseconds
100.00% <= 12 milliseconds
100.00% <= 12 milliseconds
10090.82 requests per second
====== MSET (10 keys) ======
100000requests completed in 1.67 seconds
100 parallelclients
3 bytespayload
keep alive: 1
19.18% <= 1 milliseconds
69.29% <= 2 milliseconds
99.70% <= 3 milliseconds
100.00% <= 3 milliseconds
59701.50 requests per second
[root@master bin]# [18025] 26 May 16:55:26.045 *10000 changes in 60 seconds. Saving...
[18025] 26 May 16:55:26.046 * Background savingstarted by pid 18240
[18240] 26 May 16:55:26.075 * DB saved on disk
[18240] 26 May 16:55:26.076 * RDB: 4 MB of memoryused by copy-on-write
[18025] 26 May 16:55:26.146 * Background savingterminated with success
[root@master bin]#
[root@master bin]# redis-cli info (截一部分图意思一下吧!)
[root@master bin]# redis-cli info | grepmem (看看内存信息)
tar -zxvf tcl8.6.1-src.tar.gz
[root@master redis-2.8.9]# cd unix/
[root@master unix]# ./ configure
[root@master unix]# pwd
/home/tcl8.6.1/unix
[root@master unix]# make
[root@master unix]# make install
You need tcl 8.5 or newer in order to run the Redistest
make[1]: *** [test] Error 1
make[1]: Leaving directory`/usr/local/yting/redis/redis-2.8.9/src'
make: *** [test] Error 2
原因:没有安装tcl
解决:安装tcl就好
详细安装请看目录中的# Tcl的安装 tcl8.6.1-src.tar.gz