标签:
一、安装redis(略)和支持组件
yum install rubby rubbygems -y
gem install redis #安装redis 的api 接口
二、配置redis
redis-common.conf:
1 #GENERAL 2 daemonize yes 3 tcp-backlog 511 4 timeout 0 5 tcp-keepalive 0 6 loglevel notice 7 databases 16 8 dir /opt/redis/redis/data 9 slave-serve-stale-data yes 10 #slave只读 11 slave-read-only yes 12 #not use default 13 repl-disable-tcp-nodelay yes 14 slave-priority 100 15 #打开aof持久化 16 appendonly yes 17 #每秒一次aof写 18 appendfsync everysec 19 #关闭在aof rewrite的时候对新的写操作进行fsync 20 no-appendfsync-on-rewrite yes 21 auto-aof-rewrite-min-size 64mb 22 lua-time-limit 5000 23 #requirepass uuzz 24 #打开redis集群 25 cluster-enabled yes 26 #节点互连超时的阀值 27 cluster-node-timeout 5000 28 cluster-migration-barrier 1 29 slowlog-log-slower-than 10000 30 slowlog-max-len 128 31 notify-keyspace-events "" 32 hash-max-ziplist-entries 512 33 hash-max-ziplist-value 64 34 list-max-ziplist-entries 512 35 list-max-ziplist-value 64 36 set-max-intset-entries 512 37 zset-max-ziplist-entries 128 38 zset-max-ziplist-value 64 39 activerehashing yes 40 client-output-buffer-limit normal 0 0 0 41 client-output-buffer-limit slave 256mb 64mb 60 42 client-output-buffer-limit pubsub 32mb 8mb 60 43 hz 10 44 aof-rewrite-incremental-fsync yes
redis-6661.conf:
1 #包含通用配置 2 include /opt/redis/redis-common.conf 3 #监听tcp端口 4 port 6661 5 #最大可用内存 6 maxmemory 100m 7 #内存耗尽时采用的淘汰策略: 8 # volatile-lru -> remove the key with an expire set using an LRU algorithm 9 # allkeys-lru -> remove any key accordingly to the LRU algorithm 10 # volatile-random -> remove a random key with an expire set 11 # allkeys-random -> remove a random key, any key 12 # volatile-ttl -> remove the key with the nearest expire time (minor TTL) 13 # noeviction -> don‘t expire at all, just return an error on write operations 14 maxmemory-policy allkeys-lru 15 #aof存储文件 16 appendfilename "appendonly-6661.aof" 17 #rdb文件,只用于动态添加slave过程 18 dbfilename dump-6661.rdb 19 #cluster配置文件(启动自动生成) 20 cluster-config-file nodes-6661.conf 21 #部署在同一机器的redis实例,把auto-aof-rewrite搓开,防止瞬间fork所有redis进程做rewrite,占用大量内存 22 auto-aof-rewrite-percentage 80-100 23 logfile "/opt/redis/log/redis-6661.log"
三、启动redis(略)并创建集群
redis-trib.rb create --replicas 1 10.1.1.28:6661 10.1.1.28:7771 10.1.1.29:8881 10.1.1.29:9991 10.1.1.28:6662 10.1.1.28:7772 10.1.1.29:8882 10.1.1.29:9992
执行以上命令后redis-trib会打印出一份预想中的配置给你看, 如果你觉得没问题的话, 就可以输入 yes , redis-trib 就会将这份配置应用到集群当中。
标签:
原文地址:http://www.cnblogs.com/wjoyxt/p/4897824.html