首页 > 数据库 > Redis > 正文

使用Ruby脚本部署Redis Cluster集群步骤讲解

2020-10-28 21:31:09
字体:
来源:转载
供稿:网友

安装Ruby和Gem

下载rubywget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.8.tar.gz解压tar xvf ruby-2.3.8.tar.gz生成Makefile并且后面会被安装到/usr/local/ruby目录下./configure -prefix /usr/local/ruby编译make 安装make installcd /usr/local/rubycp bin/ruby /usr/local/bin/cp bin/gem /usr/local/bin/

安装Ruby和redis接口

下载

wget  https://rubygems.org/downloads/redis-4.1.0.gem

安装

gem install -l redis-4.1.0.gem

将脚本移动到/usr/local/bin/下,方便直接执行

cp /usr/local/redis/src/redis-trib.rb /usr/local/bin/

启动Redis节点

8000端口配置文件模板,其余节点只有端口不同

# redis-8000.confdaemonize yesport 8000logfile "8000.log"dir "/server/redis_data"dbfilename "dump-8000.rdb"cluster-enabled yescluster-config-file nodes-8000.confcluster-require-full-coverage no

启动节点

redis-server redis-8000.conf redis-server redis-8001.conf redis-server redis-8002.conf redis-server redis-8003.conf redis-server redis-8004.conf redis-server redis-8005.conf 

一键开启

redis-trib.rb create --replicas 1 10.238.162.34:8000 10.238.162.34:8001/10.238.162.34:8002 10.238.162.34:8003/10.238.162.34:8004 10.238.162.34:8005

# redis-cli -p 8000 cluster infocluster_state:okcluster_slots_assigned:16384cluster_slots_ok:16384cluster_slots_pfail:0cluster_slots_fail:0cluster_known_nodes:6cluster_size:3cluster_current_epoch:6cluster_my_epoch:1cluster_stats_messages_sent:695cluster_stats_messages_received:695
# redis-cli -p 8000 cluster nodes4dd758d1f84285cbe82cd51f4b1bdce08f10d067 10.238.162.34:8004 slave cbcb2f95d3c66c3ad2203fb268be39eef8567317 0 1547215299946 5 connected860069c03aefeb7449aa6daf2f198d90f1f19b01 10.238.162.34:8002 master - 0 1547215297941 3 connected 10923-16383cbcb2f95d3c66c3ad2203fb268be39eef8567317 10.238.162.34:8001 master - 0 1547215298944 2 connected 5461-10922e84313e39765087ff8bfe4bf86b10717d82c9698 10.238.162.34:8003 slave 90d1c2da65f7ee8cd7d16a7790384903bd4ccc8e 0 1547215297440 4 connectedbc0e954a60920a24c2bfa351c042470f1d8dda07 10.238.162.34:8005 slave 860069c03aefeb7449aa6daf2f198d90f1f19b01 0 1547215296940 6 connected90d1c2da65f7ee8cd7d16a7790384903bd4ccc8e 10.238.162.34:8000 myself,master - 0 0 1 connected 0-5460

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对武林网的支持。如果你想了解更多相关内容请查看下面相关链接

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表