这篇文章主要为大家展示了“如何使用Ruby脚本部署Redis Cluster集群”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何使用Ruby脚本部署Redis Cluster集群”这篇文章吧。
安装Ruby和Gem
下载ruby wget 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 install cd /usr/local/ruby cp 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.conf daemonize yes port 8000 logfile "8000.log" dir "/server/redis_data" dbfilename "dump-8000.rdb" cluster-enabled yes cluster-config-file nodes-8000.conf cluster-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 info cluster_state:ok cluster_slots_assigned:16384 cluster_slots_ok:16384 cluster_slots_pfail:0 cluster_slots_fail:0 cluster_known_nodes:6 cluster_size:3 cluster_current_epoch:6 cluster_my_epoch:1 cluster_stats_messages_sent:695 cluster_stats_messages_received:695
# redis-cli -p 8000 cluster nodes 4dd758d1f84285cbe82cd51f4b1bdce08f10d067 10.238.162.34:8004 slave cbcb2f95d3c66c3ad2203fb268be39eef8567317 0 1547215299946 5 connected 860069c03aefeb7449aa6daf2f198d90f1f19b01 10.238.162.34:8002 master - 0 1547215297941 3 connected 10923-16383 cbcb2f95d3c66c3ad2203fb268be39eef8567317 10.238.162.34:8001 master - 0 1547215298944 2 connected 5461-10922 e84313e39765087ff8bfe4bf86b10717d82c9698 10.238.162.34:8003 slave 90d1c2da65f7ee8cd7d16a7790384903bd4ccc8e 0 1547215297440 4 connected bc0e954a60920a24c2bfa351c042470f1d8dda07 10.238.162.34:8005 slave 860069c03aefeb7449aa6daf2f198d90f1f19b01 0 1547215296940 6 connected 90d1c2da65f7ee8cd7d16a7790384903bd4ccc8e 10.238.162.34:8000 myself,master - 0 0 1 connected 0-5460
以上是“如何使用Ruby脚本部署Redis Cluster集群”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。