博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
redis-cluster创建步骤
阅读量:7102 次
发布时间:2019-06-28

本文共 4184 字,大约阅读时间需要 13 分钟。

  hot3.png

官方提供了脚本创建集群的工具,我们参照官方的指导进行创建集群以我本测试环境为例:

/usr/local/soft/redis-cluster/redis-3.2.1/utils/create-cluster

进入脚本目录后执行集群创建失败,如下:

[root@bogon create-cluster]# ./create-cluster create../../src/redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)        from ../../src/redis-trib.rb:24

通过查找官方文档说明,

The redis-trib utility is in the src directory of the Redis source code distribution. You need to install redis gem to be able to run redis-trib.(....需要通过安装redis gem来运行redis-trib)

gem install redis

系统没有安装gem,先安装gem。

1)yum install ruby

2)安装rubygems

ruby setup.rb --help

安装提示ruby版本需大于1.8.7,则需要手动安装ruby。从【ruby源】下载安装包后解压进行安装。

[root@bogon create-cluster]# gem install redisERROR:  Loading command: install (LoadError)        cannot load such file -- zlibERROR:  While executing gem ... (NoMethodError)    undefined method `invoke_with_build_args' for nil:NilClass

进入ruby安装目录/usr/local/soft/ruby/ruby-2.1.7/ext/zlib,手动编译安装zlib。

[root@bogon create-cluster]# gem install redisERROR:  While executing gem ... (Gem::Exception)    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

yum install openssl-devel

yum install openssl

进入ruby安装目录/usr/local/soft/ruby/ruby-2.1.7/ext/openssl,手动编译安装openssl

上述安装成功后,重新执行gem install redis

[root@bogon openssl]# gem install redisFetching: redis-3.3.1.gem (100%)Successfully installed redis-3.3.1Parsing documentation for redis-3.3.1Installing ri documentation for redis-3.3.1Done installing documentation for redis after 1 seconds1 gem installed

进入脚本创建集群的目录/usr/local/soft/redis-cluster/redis-3.2.1/utils/create-cluster启动节点后创建集群。

1)启动6个节点

[root@bogon create-cluster]# ./create-cluster startStarting 20001Starting 20002Starting 20003Starting 20004Starting 20005Starting 20006

2)创建集群,3主3从

[root@bogon create-cluster]# ./create-cluster create>>> Creating cluster>>> Performing hash slots allocation on 6 nodes...Using 3 masters:127.0.0.1:20001127.0.0.1:20002127.0.0.1:20003Adding replica 127.0.0.1:20004 to 127.0.0.1:20001Adding replica 127.0.0.1:20005 to 127.0.0.1:20002Adding replica 127.0.0.1:20006 to 127.0.0.1:20003M: d3bef4dff6260735c0ff12b8add62636c2bc7e4f 127.0.0.1:20001   slots:0-5460 (5461 slots) masterM: 351691e42b2207cf0322dbf4904c9b9fc6e6d18a 127.0.0.1:20002   slots:5461-10922 (5462 slots) masterM: 54f86341f254d453f5e9221ecc6ab1623fdc7ed2 127.0.0.1:20003   slots:10923-16383 (5461 slots) masterS: cbf8299efc5ef5422d3f160f54d7f7fb5452d613 127.0.0.1:20004   replicates d3bef4dff6260735c0ff12b8add62636c2bc7e4fS: 43a8538ace038e638ecc98c162bedfe4ed43798c 127.0.0.1:20005   replicates 351691e42b2207cf0322dbf4904c9b9fc6e6d18aS: 83df222815c36c773c2494486a03ffcd3367210a 127.0.0.1:20006   replicates 54f86341f254d453f5e9221ecc6ab1623fdc7ed2Can I set the above configuration? (type 'yes' to accept): yes>>> Nodes configuration updated>>> Assign a different config epoch to each node>>> Sending CLUSTER MEET messages to join the clusterWaiting for the cluster to join.>>> Performing Cluster Check (using node 127.0.0.1:20001)M: d3bef4dff6260735c0ff12b8add62636c2bc7e4f 127.0.0.1:20001   slots:0-5460 (5461 slots) masterM: 351691e42b2207cf0322dbf4904c9b9fc6e6d18a 127.0.0.1:20002   slots:5461-10922 (5462 slots) masterM: 54f86341f254d453f5e9221ecc6ab1623fdc7ed2 127.0.0.1:20003   slots:10923-16383 (5461 slots) masterM: cbf8299efc5ef5422d3f160f54d7f7fb5452d613 127.0.0.1:20004   slots: (0 slots) master   replicates d3bef4dff6260735c0ff12b8add62636c2bc7e4fM: 43a8538ace038e638ecc98c162bedfe4ed43798c 127.0.0.1:20005   slots: (0 slots) master   replicates 351691e42b2207cf0322dbf4904c9b9fc6e6d18aM: 83df222815c36c773c2494486a03ffcd3367210a 127.0.0.1:20006   slots: (0 slots) master   replicates 54f86341f254d453f5e9221ecc6ab1623fdc7ed2[OK] All nodes agree about slots configuration.>>> Check for open slots...>>> Check slots coverage...[OK] All 16384 slots covered.

 

 

参考资料:

https://rubygems.org/pages/download/

https://ruby.taobao.org/

http://www.runoob.com/ruby/ruby-installation-unix.html

http://stackoverflow.com/questions/9727908/cannot-load-such-file-zlib-even-after-using-rvm-pkg-install-zlib

http://blog.csdn.net/kenera/article/details/25962587

转载于:https://my.oschina.net/u/914290/blog/716507

你可能感兴趣的文章
OSChina 技术周刊第八期 —— 10 大常见的 web 开发错误
查看>>
Android Camera&Matrix图像变换
查看>>
什么是JSONP?
查看>>
How to provision a Domain Controller as File Share Witness for an Exchange 2010 DAG
查看>>
Python自学笔记之函数式编程1——高阶函数
查看>>
简单数据库查询通用方法
查看>>
FFmpeg数据结构彻底分析——AVClass
查看>>
【华为悦读汇】技术发烧友:闲话大二层网络
查看>>
后台返回来的json字符串的对象化和遍历
查看>>
Ambari在线部署hdp
查看>>
ubuntu apache php 部署
查看>>
IOException: Packet len5601403 is out of range!
查看>>
《oracle数据库递归查询以及给结果赋初值》
查看>>
hadoop 安装2
查看>>
AM企业即时通讯软件大企业的选择
查看>>
System Center 2012 各模块组件简介及架构图
查看>>
Python 错误和异常小结
查看>>
perl pool ping
查看>>
weblogic10.3.6安装、卸载
查看>>
Struts2+JQuery+Json实例(2)
查看>>