安装redis3.2集群出现的一些问题及解决方法
2017-01-17 18:22
841 查看
安装系统是在centOS上面时行的。有不足之处还记指正。
系统版本centOS6.5.
redis集群配置如下:
节点1
=============================================
主192.168.135.128 :1000
/usr/local/redis-cluster-test/cluster1/master
从 192.168.135.128 :1001
/usr/local/redis-cluster-test/cluster1/slave
节点1主配置
pidfile /usr/local/redis-cluster-test/cluster1/master/redis_1000.pid
logfile /usr/local/redis-cluster-test/cluster1/master/redist-1000.log
port 1000
bind 192.168.135.128
appendonly yes
daemonize yes
dir /usr/local/redis-cluster-test/cluster1/master/
cluster-enabled yes
cluster-config-file nodes-1000.conf
节点1从配置
pidfile /usr/local/redis-cluster-test/cluster1/slave/redis_1001.pid
logfile /usr/local/redis-cluster-test/cluster1/salve/redist-1001.log
port 1001
bind 192.168.135.128
appendonly yes
daemonize yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-enabled yes
cluster-config-file nodes-1001.conf
节点2
=============================================
节点2主192.168.135.128 :2000
/usr/local/redis-cluster-test/cluster2/master
/usr/local/redis-cluster-test/cluster2/slave
pidfile /usr/local/redis-cluster-test/cluster2/slave/redis_2001.pid
logfile /usr/local/redis-cluster-test/cluster2/salve/redist-2001.log
port 2001
bind 192.168.135.128
appendonly yes
daemonize yes
cluster-enabled yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-config-file nodes-2000.conf
节点2从 192.168.135.128 :2001
/usr/local/redis-cluster-test/cluster2/slave
pidfile /usr/local/redis-cluster-test/cluster2/slave/redis_2001.pid
logfile /usr/local/redis-cluster-test/cluster2/salve/redist-2001.log
port 2001
bind 192.168.135.128
appendonly yes
daemonize yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-enabled yes
cluster-config-file nodes-2001.conf
节点3
=============================================
节点3主192.168.135.128 :3000
/usr/local/redis-cluster-test/cluster3/master
/usr/local/redis-cluster-test/cluster2/slave
pidfile /usr/local/redis-cluster-test/cluster3/slave/redis_3000.pid
logfile /usr/local/redis-cluster-test/cluster3/salve/redist-3000.log
port 3000
bind 192.168.135.128
appendonly yes
daemonize yes
cluster-enabled yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-config-file nodes-3000.conf
节点3从 192.168.135.128 :3001
redis.conf /usr/local/redis-cluster-test/cluster3/slave
pidfile /usr/local/redis-cluster-test/cluster3/slave/redis_3001.pid
logfile /usr/local/redis-cluster-test/cluster3/salve/redist-3001.log
port 3001
bind 192.168.135.128
appendonly yes
daemonize yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-enabled yes
cluster-config-file nodes-3001.conf
以上配置在从中设置少了一个cluster-node-timeout 15000这个配置可以自行设置。
下面就是主题了,搞下集群。
也有一些野路子配置集群的,在网上看到,试过了,也可以用,但是在删除和增加节点时不是那么灵活。官方文档上推荐使用ruby,而且redis3.2里面内置了redis-trib.rb文件,所以在centOS上面安装ruby就可以了。可是,我是纠结了一下午才搞定了ruby的运行环境,可能是我安装的centos太纯净了,有些依赖包没有找到的问题。
一些问题如下:
问题1:
执行命令:./redis-trib.rb
/usr/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- redis (LoadError)
from /usr/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from ./redis-trib.rb:25:in `<main>'
解决方法:下载安装rubygem 进入解压包中.configure make && make install
此时就可以运行gem intall redis 命令,来安装ruby执行redis的相关依赖。
问题2:
gem install redis 命令出现的问题
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass手动安装opensll,此问题解决。
问题3:
接着执行命令:gem install redis
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
手动安装zlib包解决(这个可能是系统太纯净,没有些包的问题)。安装过程不多说,手动下载安装包安装。
问题3:
接着执行命令:gem install redis
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
网上搜索到的解决方法: gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
还是问题以旧。
解决方法:
gem sources -a https://gems.ruby-china.org/ 把https地址改成 gem sources -a http://gems.ruby-china.org/
执行成功,查看gem source -l 镜像地址修改成功。
再次执行:gem install redis成功。
通过命令查看:
gem list 已经成功安装了redis的依赖。
执行redis 目录下的ruby-trib.rb
命令格式如下:
./redis-trib.rb create --replicas 1 192.168.135.128:1000 192.168.135.128:2000
192.168.135.128:3000 192.168.135.128:1001 192.168.135.128:2001 192.168.135.128:3001
注意:--replicas 1 代表每个master有一个slave,还有就是前面三个是主服务,后面三个从服务地址,集群配置成功。
如图所示:
以上是在个人配置集群的时候碰到的问题。
java 程序测试集群:
程序运行效果如下:
系统版本centOS6.5.
redis集群配置如下:
节点1
=============================================
主192.168.135.128 :1000
/usr/local/redis-cluster-test/cluster1/master
从 192.168.135.128 :1001
/usr/local/redis-cluster-test/cluster1/slave
节点1主配置
pidfile /usr/local/redis-cluster-test/cluster1/master/redis_1000.pid
logfile /usr/local/redis-cluster-test/cluster1/master/redist-1000.log
port 1000
bind 192.168.135.128
appendonly yes
daemonize yes
dir /usr/local/redis-cluster-test/cluster1/master/
cluster-enabled yes
cluster-config-file nodes-1000.conf
节点1从配置
pidfile /usr/local/redis-cluster-test/cluster1/slave/redis_1001.pid
logfile /usr/local/redis-cluster-test/cluster1/salve/redist-1001.log
port 1001
bind 192.168.135.128
appendonly yes
daemonize yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-enabled yes
cluster-config-file nodes-1001.conf
节点2
=============================================
节点2主192.168.135.128 :2000
/usr/local/redis-cluster-test/cluster2/master
/usr/local/redis-cluster-test/cluster2/slave
pidfile /usr/local/redis-cluster-test/cluster2/slave/redis_2001.pid
logfile /usr/local/redis-cluster-test/cluster2/salve/redist-2001.log
port 2001
bind 192.168.135.128
appendonly yes
daemonize yes
cluster-enabled yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-config-file nodes-2000.conf
节点2从 192.168.135.128 :2001
/usr/local/redis-cluster-test/cluster2/slave
pidfile /usr/local/redis-cluster-test/cluster2/slave/redis_2001.pid
logfile /usr/local/redis-cluster-test/cluster2/salve/redist-2001.log
port 2001
bind 192.168.135.128
appendonly yes
daemonize yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-enabled yes
cluster-config-file nodes-2001.conf
节点3
=============================================
节点3主192.168.135.128 :3000
/usr/local/redis-cluster-test/cluster3/master
/usr/local/redis-cluster-test/cluster2/slave
pidfile /usr/local/redis-cluster-test/cluster3/slave/redis_3000.pid
logfile /usr/local/redis-cluster-test/cluster3/salve/redist-3000.log
port 3000
bind 192.168.135.128
appendonly yes
daemonize yes
cluster-enabled yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-config-file nodes-3000.conf
节点3从 192.168.135.128 :3001
redis.conf /usr/local/redis-cluster-test/cluster3/slave
pidfile /usr/local/redis-cluster-test/cluster3/slave/redis_3001.pid
logfile /usr/local/redis-cluster-test/cluster3/salve/redist-3001.log
port 3001
bind 192.168.135.128
appendonly yes
daemonize yes
dir /usr/local/redis-cluster-test/cluster1/slave/
cluster-enabled yes
cluster-config-file nodes-3001.conf
以上配置在从中设置少了一个cluster-node-timeout 15000这个配置可以自行设置。
下面就是主题了,搞下集群。
也有一些野路子配置集群的,在网上看到,试过了,也可以用,但是在删除和增加节点时不是那么灵活。官方文档上推荐使用ruby,而且redis3.2里面内置了redis-trib.rb文件,所以在centOS上面安装ruby就可以了。可是,我是纠结了一下午才搞定了ruby的运行环境,可能是我安装的centos太纯净了,有些依赖包没有找到的问题。
一些问题如下:
问题1:
执行命令:./redis-trib.rb
/usr/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- redis (LoadError)
from /usr/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from ./redis-trib.rb:25:in `<main>'
解决方法:下载安装rubygem 进入解压包中.configure make && make install
此时就可以运行gem intall redis 命令,来安装ruby执行redis的相关依赖。
问题2:
gem install redis 命令出现的问题
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass手动安装opensll,此问题解决。
问题3:
接着执行命令:gem install redis
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
手动安装zlib包解决(这个可能是系统太纯净,没有些包的问题)。安装过程不多说,手动下载安装包安装。
问题3:
接着执行命令:gem install redis
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
网上搜索到的解决方法: gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
还是问题以旧。
解决方法:
gem sources -a https://gems.ruby-china.org/ 把https地址改成 gem sources -a http://gems.ruby-china.org/
执行成功,查看gem source -l 镜像地址修改成功。
再次执行:gem install redis成功。
通过命令查看:
gem list 已经成功安装了redis的依赖。
执行redis 目录下的ruby-trib.rb
命令格式如下:
./redis-trib.rb create --replicas 1 192.168.135.128:1000 192.168.135.128:2000
192.168.135.128:3000 192.168.135.128:1001 192.168.135.128:2001 192.168.135.128:3001
注意:--replicas 1 代表每个master有一个slave,还有就是前面三个是主服务,后面三个从服务地址,集群配置成功。
如图所示:
以上是在个人配置集群的时候碰到的问题。
java 程序测试集群:
JedisPoolConfig poolConfig=new JedisPoolConfig(); Set<HostAndPort> nodeList=new HashSet<HostAndPort>(); nodeList.add(new HostAndPort(host,1000)); nodeList.add(new HostAndPort(host,1001)); nodeList.add(new HostAndPort(host,2000)); nodeList.add(new HostAndPort(host,2001)); nodeList.add(new HostAndPort(host,3000)); nodeList.add(new HostAndPort(host,3001)); JedisCluster cluster=new JedisCluster(nodeList,poolConfig); String name=cluster.get("name"); System.out.println("args = [" + name + "]");
程序运行效果如下:
相关文章推荐
- 关于windows系统安装jdk时出现的一些问题的解决方法
- Hyperledger Fabric 1.0安装过程中出现的一些问题和解决方法
- Android Studio安装过程中出现一些问题的解决方法(都已解决)
- linux centOS7安装mysql出现的一些问题和解决方法
- MySQL安装过程中出现的问题解决方法
- SQL安装中常出现的问题与解决方法
- 关于SQL安装时出现的有程序安装挂起问题的解决方法
- 中文VS2008中安装ASP.NET MVC框架出现问题的解决方法
- windows 2003中安装net Framework 2.0 后Reporting Service 出现问题及其解决方法
- 已安装好的Ubuntu启动出现 busybox initramfs 问题可能的解决方法
- [转]中文VS2008中安装ASP.NET MVC框架出现问题的解决方法
- 整理ArcSDE 安装过程出现问题以及解决方法系列
- 我在安装TFS 2008的时候遇到的问题以及解决方法一windows 2003 iis中总是不出现ASP.NET 2.0
- 安装DriverStudio3.2 过程中出现DSDDKEnv8.dll failed to register错误的解决方法
- 访问本地站点出现的一些问题及解决方法
- 中文VS2008中安装ASP.NET MVC框架出现问题的解决方法之完整版
- 在安装有VS2008beta2版本的机子上使用vs2005进行部署出现问题的解决方法
- 安装万能解码器出现的问题和解决方法
- 整理ArcSDE 安装过程出现问题以及解决方法系列
- 安装DriverStudio3.2 过程中出现DSDDKEnv8.dll failed to register错误的解决方法