使用Ruby脚本部署Redis Cluster集群步骤讲解
程序员文章站
2023-02-20 19:22:21
安装ruby和gem
下载ruby
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.8.tar.g...
安装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
安装
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
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接