天行健,君子以自强不息

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  90 随笔 :: 0 文章 :: 4 评论 :: 32万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

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   fgys  阅读(507)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示