1.安装
tar -zxvf redis-2..8.18.tar.gz
cd redis-2.8.18
make && make install
2.调整内存如果内存情况比较紧张的话,需要设定内核参数:
echo 1 > /proc/sys/vm/overcommit_memory这里说一下这个配置的含义:
/proc/sys/vm/overcommit_memory
该文件指定了内核针对内存分配的策略,其值可以是0、1、2。
0,表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
1,表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
2,表示内核允许分配超过所有物理内存和交换空间总和的内存
3.设置可选部分:拷贝文件
cp redis.conf /etc/ #这个文件时redis启动的配置文件
cp redis-benchmark redis-cli redis-server /usr/bin/ #这个倒是很有用,这样就不用再执行时加上./了,而且可以在任何地方执行
4.编辑redis.conf
daemonize yes #转为守护进程,否则启动时会每隔5秒输出一行监控信息save 60 1000 #减小改变次数,其实这个可以根据情况进行指定maxmemory 1024000000 #分配256M内存5.启动服务
redis-server redis.conf #启动服务6.压力测试redis-benchmark -n 100000 -c 60 ====== PING_INLINE ====== 100000 requests completed in 1.31 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 76219.51 requests per second ====== PING_BULK ====== 100000 requests completed in 1.33 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 75471.70 requests per second ====== SET ====== 100000 requests completed in 1.32 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 75700.23 requests per second ====== GET ====== 100000 requests completed in 1.33 seconds 60 parallel clients 3 bytes payload keep alive: 1 99.96% <= 1 milliseconds 100.00% <= 1 milliseconds 75471.70 requests per second ====== INCR ====== 100000 requests completed in 1.28 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 77942.32 requests per second ====== LPUSH ====== 100000 requests completed in 1.24 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 80385.85 requests per second ====== LPOP ====== 100000 requests completed in 1.25 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 79872.20 requests per second ====== SADD ====== 100000 requests completed in 1.26 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 79491.26 requests per second ====== SPOP ====== 100000 requests completed in 1.26 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 79428.12 requests per second ====== LPUSH (needed to benchmark LRANGE) ====== 100000 requests completed in 1.25 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 80064.05 requests per second ====== LRANGE_100 (first 100 elements) ====== 100000 requests completed in 1.25 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 80321.28 requests per second ====== LRANGE_300 (first 300 elements) ====== 100000 requests completed in 1.24 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 80515.30 requests per second ====== LRANGE_500 (first 450 elements) ====== 100000 requests completed in 1.24 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 80645.16 requests per second ====== LRANGE_600 (first 600 elements) ====== 100000 requests completed in 1.25 seconds 60 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 80321.28 requests per second ====== MSET (10 keys) ====== 100000 requests completed in 1.37 seconds 60 parallel clients 3 bytes payload keep alive: 1 83.31% <= 1 milliseconds 100.00% <= 1 milliseconds 73260.07 requests per second