能夠參考這篇博文:http://www.cnblogs.com/_popc/p/3684835.htmlhtml
Ubuntu 15.10,9臺電腦,3 master,6 slavenode
安裝rubyredis
sudo apt-get install ruby
安裝Redis Ruby驅動sql
sudo gem install redis
通用配置文件:redis-common.confruby
#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.confapp
#包含通用配置 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
redis-server redis-6379.conf
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
redis-cli -c -p 6379
參考:http://blog.51yip.com/nosql/1726.htmldom