lightdb 单机多实例集群部署

发布时间 2023-06-11 22:20:59作者: winter-loo

本文章主要介绍我在部署 lightdb 单机多实例集群过程中开发的 shell 脚本,方便后续快速搭建集群。在搭建集群过程中我主要参考了以下文档。

参考文档

脚本 node.sh

该脚本运行在已经安装过 lightdb 单实例的机器。

最终我的目录结构:

image

脚本使用样例

准备工作

  1. mkdir -p ~/foo/cloud
  2. git clone https://github.com/winter-loo/shutils.git
  3. cp shutils/node.sh cloud/ && cd cloud

添加三个节点

  1. ./node.sh add 01
  2. ./node.sh add 02
  3. ./node.sh add 03

启动数据库实例

  1. ./node.sh initdb
  2. ./node.sh config shared_preload_libraries
  3. ./node.sh start

配置集群

参见 lightdb distributed guide

修改配置

# 查看配置当前值
./node.sh config wal_level

# 修改单值
./node.sh config wal_level=logical

# 修改多值
./node.sh config shared_preload_libraries=\'canopy,lt_cluster,lt_statement\'

# 从多值中删除一个值, ',' 是必须的
./node.sh config shared_preload_libraries-='canopy,'

# 添加一个值到多值中,',' 是必须的
./node.sh config shared_preload_libraries+='canopy,'

其他命令

# 重启
./node.sh restart

# 重新加载配置文件
./node.sh reload

# 查看各实例状态
./node.sh status

单节点操作

以上所有批量操作对单节点操作都有效,但需要在 ./node.sh 后面加上节点编号,如:

./node.sh 01 status
./node.sh 02 config wal_level
./node.sh 03 stop