redis创建cluster

在Redis 5及更高版本中,创建Redis集群不再需要redis-trib.rb脚本,而是通过redis-cli的集群管理命令完成。例如,可以使用`redis-cli --cluster create --cluster-replicas 1`命令,指定节点地址和副本数量来创建集群。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在一些文档中,创建redis cluster需要采用redis-trib.rb脚本实现

但是,在redis5中,已经修改为采用redis-cli实现了,语法如下:

redis-cli --cluster help
Cluster Manager Commands:
  create         host1:port1 ... hostN:portN
                 --cluster-replicas <arg>
  check          host:port
  info           host:port
  fix            host:port
  reshard        host:port
                 --cluster-from <arg>
                 --cluster-to <arg>
                 --cluster-slots <arg>
                 --cluster-yes
                 --cluster-timeout <arg>
                 --cluster-pipeline <arg>
  rebalance      host:port
                 --cluster-weight <node1=w1...nodeN=wN>
                 --cluster-use-empty-masters
                 --cluster-timeout <arg>
                 --cluster-simulate
                 --cluster-pipeline <arg>
                 --cluster-threshold <arg>
  add-node       new_host:new_port existing_host:existing_port
                 --cluster-slave
                 --cluster-master-id <arg>
  del-node       host:port node_id
  call           host:port command arg arg .. arg
  set-timeout    host:port milliseconds
  import         host:port
                 --cluster-from <arg>
                 --cluster-copy
                 --cluster-replace
  help

实例:

redis-cli --cluster create --cluster-replicas 1 192.168.1.10:6481 192.168.1.10:6482 192.168.1.10:6483 192.168.1.10:6484 192.168.1.10:6485 192.168.1.10:6486

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值