天行健,君子以自强不息

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1 Redis Standalone安装

可以参考这篇博文:http://www.cnblogs.com/_popc/p/3684835.html

2 Redis Cluster安装

2.1 环境介绍:

    Ubuntu 15.10,9台电脑,3 master,6 slave

2.2 环境准备:

    安装ruby

sudo apt-get install ruby

    安装Redis Ruby驱动

sudo gem install redis

2.3 修改配置文件

通用配置文件:redis-common.conf

#GENERAL  
daemonize yes  
tcp-backlog 511  
timeout 0  
tcp-keepalive 0  
loglevel notice  
databases 16  
logfile "/home/hadoop/software/cloud/redis-3.0.4/data/redis/redis.log"
dir /home/hadoop/software/cloud/redis-3.0.4/working_directory 
slave-serve-stale-data yes  
#slave只读  
slave-read-only yes  
#not use default  
repl-disable-tcp-nodelay yes  
slave-priority 100  
#打开aof持久化  
appendonly yes  
#每秒一次aof写  
appendfsync everysec  
#关闭在aof rewrite的时候对新的写操作进行fsync  
no-appendfsync-on-rewrite yes  
auto-aof-rewrite-min-size 64mb  
lua-time-limit 5000  
#打开redis集群  
cluster-enabled yes  
#节点互连超时的阀值  
cluster-node-timeout 15000  
cluster-migration-barrier 1  
slowlog-log-slower-than 10000  
slowlog-max-len 128  
notify-keyspace-events ""  
hash-max-ziplist-entries 512  
hash-max-ziplist-value 64  
list-max-ziplist-entries 512  
list-max-ziplist-value 64  
set-max-intset-entries 512  
zset-max-ziplist-entries 128  
zset-max-ziplist-value 64  
activerehashing yes  
client-output-buffer-limit normal 0 0 0  
client-output-buffer-limit slave 256mb 64mb 60  
client-output-buffer-limit pubsub 32mb 8mb 60  
hz 10  
aof-rewrite-incremental-fsync yes  

个性化配置文件:redis-6379.conf

#包含通用配置  
include /home/hadoop/software/cloud/redis-3.0.4/redis-common.conf  
#监听tcp端口  
port 6379  
#最大可用内存  
maxmemory 10240m  
#内存耗尽时采用的淘汰策略:  
# volatile-lru -> remove the key with an expire set using an LRU algorithm  
# allkeys-lru -> remove any key accordingly to the LRU algorithm  
# volatile-random -> remove a random key with an expire set  
# allkeys-random -> remove a random key, any key  
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)  
# noeviction -> don't expire at all, just return an error on write operations  
maxmemory-policy allkeys-lru  
#aof存储文件  
appendfilename "appendonly-6379.aof"  
#rdb文件,只用于动态添加slave过程  
dbfilename dump-6379.rdb  
#cluster配置文件(启动自动生成)  
cluster-config-file nodes-6379.conf  
#部署在同一机器的redis实例,把auto-aof-rewrite搓开,防止瞬间fork所有redis进程做rewrite,占用大量内存 
auto-aof-rewrite-percentage 80-100  

2.4 每台机器启动redis-server

redis-server redis-6379.conf

2.5 创建集群

src/redis-trib.rb create --replicas 2 192.168.1.100:6379 192.168.1.101:6379 192.168.1.106:6379 192.168.1.107:6379 192.168.1.108:6379 

192.168.1.109:6379 192.168.1.103:6379 192.168.1.104:6379 192.168.1.105:6379

2.6 进入Redis命令行测试

redis-cli -c -p 6379

3 Redis Cluster 命令

参考:http://blog.51yip.com/nosql/1726.html

4 参考文献

4.1 http://hot66hot.iteye.com/blog/2050676/

4.2 http://blog.chinaunix.net/uid-7374279-id-4470290.html

posted on 2015-12-21 15:00  fgys  阅读(506)  评论(0编辑  收藏  举报