版本
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
部署
- 复制
kvrocks.conf
至kvrocks.{port}.conf
- 修改
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,2步骤,多弄几个节点配置出来,我是从端口6664到6672
- 启动节点,参考命令:
nohup ./build/kvrocks -c kvrocks.{port}.conf > /var/log/kvrocks.{port}.log 2>&1 &
Kvrocks Controller 部署
编译环境准备
- 这里依赖go编译环境
- 建议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
参考
https://github.com/apache/kvrocks
https://github.com/apache/kvrocks-controller