Centos7 单机部署Kvrocks集群

版本

Kvrocks v2.8.0
Kvrocks Controller v0.3.1

Kvrocks 部署

编译环境准备

yum install -y centos-release-scl-rh
yum install -y git devtoolset-11 autoconf automake libtool libstdc++-static python3 openssl-devel
wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.sh -O cmake.sh
bash cmake.sh --skip-license --prefix=/usr
source /opt/rh/devtoolset-11/enable

ps
重启系统,source /opt/rh/devtoolset-11/enable 需要重新执行

编译

git clone https://github.com/apache/kvrocks.git
cd kvrocks
./x.py build

部署

  1. 复制 kvrocks.confkvrocks.{port}.conf
  2. 修改kvrocks.{port}.conf
bind 192.168.56.xxx
unixsocket /root/kvrocks/socks/kvrocks{port}.sock
port {port}
cluster-enabled yes
dir /root/kvrocks/data/kvrocks{port}
  1. 重复1,2步骤,多弄几个节点配置出来,我是从端口6664到6672
  2. 启动节点,参考命令:nohup ./build/kvrocks -c kvrocks.{port}.conf > /var/log/kvrocks.{port}.log 2>&1 &

Kvrocks Controller 部署

编译环境准备

  1. 这里依赖go编译环境
  2. 建议go配置代理

编译

git clone https://github.com/apache/kvrocks-controller
cd kvrocks-controller
make 

部署

1.启动服务端nohup ./_build/kvctl-server -c ./config/config.yaml > /var/log/kvctl-server.log 2>&1 &

集群运维


创建namespace 
./_build/kvctl create namespace test-ns

组件一个3分片2副本的集群
./_build/kvctl create cluster test-cluster --replica 2  -n test-ns --nodes  192.168.56.xxx:6664,192.168.56.xxx:6665,192.168.56.xxx:6666,192.168.56.xxx:6667,192.168.56.xxx:6668,192.168.56.xxx:6669

删除集群
./_build/kvctl delete cluster test-cluster -n test-ns

主从切换
./_build/kvctl failover shard 2 -n test-ns -c test-cluster

增加shard
./_build/kvctl create shard -n test-ns -c test-cluster --nodes 192.168.56.xxx:6670,192.168.56.xxx:6671

迁移槽位
./_build/kvctl migrate slot 16382 --target 3 -n test-ns -c test-cluster

shard增加节点
./_build/kvctl create node 192.168.56.xxx:6672 -n test-ns -c test-cluster --shard 2

集群节点信息

问题

移动槽位16383失败,感觉像是bug
移动槽位16383失败截图
移动其他槽位成功

参考

https://github.com/apache/kvrocks
https://github.com/apache/kvrocks-controller

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在CentOS 7上部署Redis集群需要以下步骤: 1. 更新yum:使用命令`yum update`来更新yum软件包管理器。 2. 安装Docker:使用命令`yum install docker`来安装Docker。 3. 启动Docker服务:使用命令`systemctl start docker`来启动Docker服务,并使用命令`systemctl enable docker`将其设置为开机启动。 4. 创建Redis集群的文件夹:使用命令`mkdir /usr/local/src/redis-cluster`来创建存放Redis集群配置文件和数据的文件夹。 5. 下载Redis配置文件:使用命令`wget https://raw.githubusercontent.com/antirez/redis/4.0/redis.conf`来下载Redis配置文件。 6. 修改Redis配置文件:使用命令`vi redis.conf`打开Redis配置文件,并进行以下修改: - 将`bind 127.0.0.1`修改为`bind 0.0.0.0`,允许外部访问Redis。 - 将`protected-mode yes`修改为`protected-mode no`,关闭保护模式。 - 将`cluster-enabled no`修改为`cluster-enabled yes`,启用集群模式。 - 将`cluster-config-file nodes-6379.conf`修改为`cluster-config-file nodes.conf`。 - 将`appendonly no`修改为`appendonly yes`,开启AOF持久化。 - 将`requirepass foobared`修改为`requirepass yourpassword`,设置Redis密码。 - 保存并退出配置文件。 7. 创建Redis集群容器:使用下面的命令来创建6个Redis容器,并启动集群: ``` for port in `seq 6000 6005`; do docker run -d -ti -p ${port}:${port} -p 1${port}:1${port} -v /usr/local/src/redis-cluster/${port}/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /usr/local/src/redis-cluster/${port}/data:/data --restart always --name redis-${port} --net redis-net --sysctl net.core.somaxconn=1024 redis redis-server /usr/local/etc/redis/redis.conf; done ``` 8. 构建Redis集群:进入其中一个Redis容器,使用下面的命令来创建Redis集群: ``` docker exec -it <container_id> /bin/bash redis-cli --cluster create ip:6000 ip:6001 ip:6002 ip:6003 ip:6004 ip:6005 --cluster-replicas 1 ``` 注意替换`<container_id>`为任意一个创建的Redis容器的ID。 9. 配置每个Redis的密码:进入每个Redis容器,使用下面的命令来设置密码: ``` docker exec -it <container_id> /bin/bash redis-cli -a yourpassword config set requirepass yourpassword ``` 注意替换`<container_id>`为每个Redis容器的ID和`yourpassword`为你想设置的密码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值