Ubuntu12.04 安装 redis-3.2.1集群

本文详细介绍了Redis 3.2.1集群的搭建步骤,包括Ruby 2.3.1的安装与配置,以及在搭建过程中可能遇到的问题及解决办法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装的整个过程参考:

http://www.cnblogs.com/gomysql/p/4395504.html

 

一. 环境信息

1. redis-3.2.1:

(http://redis.io/) http://download.redis.io/releases/redis-3.2.1.tar.gz

tar xvf redis-3.2.1.tar.gz

make && make install

 

2. ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz

tar xvf ruby-2.3.1.tar.gz

./configure

make && make install

 

3. gem --version

2.5.1

 

4. gem install redis

 

最后在安装集群时遇到的一些问题和解决方案:

1. /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError)

from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from ./redis-trib.rb:25:in `<main>'

报此问题大多是环境信息有误, 请参照上面成功的环境信息, 如果低于上面的版本可以考虑升级;

 

2. ./redis-trib.rb create --replicas 1 192.168.100.101:6381 192.168.100.101:6382 192.168.100.101:6383 192.168.100.101:6384 192.168.100.102:6381 192.168.100.102:6382 192.168.100.102:6383 192.168.100.102:6384

出现错误:

>>> Creating cluster

 

[ERR] Sorry, can't connect to node 192.168.100.101:6381

搜索到的解决方案一般为:

集群中不要设置密码 / redis.conf配置cluster-enabled yes / 服务器之间能PING/TELNET(除开防火墙原因)

/ redis.conf中配置bind 192.168.100.101 127.0.0.1, 再重启服务器 这一条为自创, Google百度本博客外搜不到的解决方案;

 

由于can't connect to node 192.168.100.101:6381, 就试着链接192.168.100.101:6381一下, 输入命令keys *测试, 发现有如下4点可能对解决问题有用, 红色部分是配置bind ip地址, 最简单常用(其他几条没有测试):

redis@redis-cache-1:~/redis-3.2.1/src$ ./redis-cli  -h 192.168.100.101 -p 6381

10.160.16.221:6381> keys *

DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 

1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 

2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 

3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 

 

4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

 

最后附件传上集群的配置mochabin.zip, 说明redis.conf中有配置dir /data/redis/cluster/6381/

/data是挂载的新硬盘, 专存储redis集群的日志, aof, dump数据, 为给后面线上redis维护带来方便.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值