本文章主要介绍我在部署 lightdb 单机多实例集群过程中开发的 shell 脚本,方便后续快速搭建集群。在搭建集群过程中我主要参考了以下文档。
参考文档
脚本 node.sh
该脚本运行在已经安装过 lightdb 单实例的机器。
最终我的目录结构:
脚本使用样例
准备工作
mkdir -p ~/foo/cloud
git clone https://github.com/winter-loo/shutils.git
cp shutils/node.sh cloud/ && cd cloud
添加三个节点
./node.sh add 01
./node.sh add 02
./node.sh add 03
启动数据库实例
./node.sh initdb
./node.sh config shared_preload_libraries
./node.sh start
配置集群
修改配置
# 查看配置当前值
./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