Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1778897
  • 博文数量: 198
  • 博客积分: 4088
  • 博客等级: 上校
  • 技术积分: 2391
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-15 16:29
个人简介

游戏开发,系统架构; 博客迁移到:http://www.jianshu.com/u/3ac0504b3b8c

文章分类

全部博文(198)

文章存档

2017年(1)

2016年(12)

2015年(1)

2014年(3)

2013年(13)

2012年(18)

2011年(150)

分类: 服务器与存储

2017-02-28 17:10:01

开始部署之前,务必先看第6条

1.从官网下载和编译redis安装包
 $ wget  
 $ tar xzf redis-3.2.5.tar.gz
 $ cd redis-3.2.5
 $ make



2.配置redis
 port 7000  
 cluster-enabled yes
 cluster-config-file nodes.conf
 cluster-node-timeout 5000
 appendonly yes


如果你不想做持久化的话,appendonly yes -> appendonly no
假设我们部署3个redis nodes, 那么需要创建6个redis实例,其中3个node为另外3个nodes的slave;
 mkdir cluster-test
 cd cluster-test
 mkdir 7000 7001 7002 7003 7004 7005
保证这6个目录下的redis.conf的port 分别为7000~7005 
3.启动所有redis实例
分别进入六个目录,启动相应的redis-server
cd 7000
../redis-server ./redis.conf
4.安装redis-trib.rb运行环境
 redis-trib.rb是ruby代码,所以先要安装ruby
 yum install ruby  
 gem install redis -- 安装redis依赖
因为墙的问题,gem install redis 可能会失败,改用国内的源
 gem sources --remove  删掉原来的源
 gem sources -a    改用国内的源 
 gem sources -l 查看现有的源 
 gem install redis  安装redis依赖
5.创建集群
 ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 


6.注意的地方
(1) 使用redis-trib.rb构建集群,完成前不要配置密码
(2) 集群构建完再通过config set + config rewrite命令逐个实例设置密码
(3) 对集群设置密码,requirepass和masterauth都需要设置
(4) 各个节点密码都必须一致,否则Redirected就会失败
 config set masterauth   yourpasswd 
 config set requirepass   yourpasswd
 auth yourpasswd
 config rewrite

(5) 如果提示一下错误,那么是redis依赖版本错误,移除当前redis依赖,安装指定版本即可
/usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:111:in `rescue in _write_to_socket': Connection timed out (Redis::TimeoutError)  
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:104:in `_write_to_socket' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:131:in `block in write' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:130:in `loop' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:130:in `write' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:374:in `write' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:271:in `block in write' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:250:in `io' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:269:in `write' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:228:in `block (3 levels) in process' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:222:in `each' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:222:in `block (2 levels) in process' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:367:in `ensure_connected' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:221:in `block in process' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:306:in `logging' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:220:in `process' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:120:in `call' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:2705:in `block in method_missing' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:58:in `block in synchronize' 
        from /usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:58:in `synchronize' 
        from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:2704:in `method_missing' 
        from ./redis-trib.rb:212:in `flush_node_config' 
        from ./redis-trib.rb:776:in `block in flush_nodes_config' 
        from ./redis-trib.rb:775:in `each' 
        from ./redis-trib.rb:775:in `flush_nodes_config' 
        from ./redis-trib.rb:1296:in `create_cluster_cmd' 
        from ./redis-trib.rb:1701:in ` 
那是gem 删除 redis-3.3.2 插件版本,改用3.0.0
    gem list
    gem uninstall redis --version 3.3.2 
    gem install redis --version 3.0.0
    gem list
阅读(7102) | 评论(0) | 转发(0) |
1

上一篇:开源监控软件ganglia安装手册

下一篇:没有了

给主人留下些什么吧!~~