原作者:计议
1.PTK 简介
PTK (Provisioning Toolkit)是一款针对 MogDB 数据库开发的软件安装和运维工具,旨在帮助用户更便捷地安装部署MogDB数据库。
使用场景
开发人员快速启动多个本地MogDB环境
用户通过PTK快速安装部署MogDB
DBA日常运维使用
第三方运维平台集成
推荐部署架构
PTK 的定位是一个多集群管理软件,作为一个中控机的角色,通过 SSH 的方式远程管理多个数据库集群,所以,我们推荐您将PTK部署在单独的一台控制服务器上,然后将数据库部署到数据库专属的服务器上,如下图。当然,PTK也支持本地部署,您可以根据您的机器情况自行安排安装位置。
+-----------+
| PTK |
+-----------+
/---ssh-----/ | \---ssh----\
/ ssh \
/ | \
+-----------+ +-----------+ +-----------+
| MogDB | | MogDB | | MogDB |
+-----------+ +-----------+ +-----------+

PTK工具下载链接:https://docs.mogdb.io/zh/ptk/v0.2/release
PTK工具支持在线安装,安装指令如下
如果用户想要运行 MogDB 或者 MogDB 的相关组件时,仅需要执行一行命令即可实现。
|主机|IP|角色|系统信息|
2.操作系统安装前准备
实验环境信息
| column1 | column2 | column3 | column4 |
|---|---|---|---|
| mogdb01 | 192.168.10.13 | 主 | CentOS Linux release 7.6 |
| mogdb02 | 192.168.10.14 | 备 | CentOS Linux release 7.6 |
2.1 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld
2.2 关闭SELinux
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
setenforce 0
getenforce
2.3 配置YUM源
[root@mogdb01 yum.repos.d]# more my.repo
[CentOS7]
name=CentOS7
baseurl=file:///mnt
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
安装依赖包
yum install -y lksctp*
yum install -y psmisc bzip2 unzip gcc gcc-c++ perl libxml2-devel
yum install libaio-devel flex bison ncurses-devel glibc-devel patch readline-devel redhat-lsb-core openssh expect tcl
2.4 设置字符集参数
echo $LANG
cat>> /etc/profile<<EOF
export LANG=en_US.UTF-8
EOF
[root@mogdb01 ~]# cat /etc/profile | grep LANG
export LANG=en_US.UTF-8
2.5 设置时区和时间
将各数据库节点的时区设置为相同时区,可以将/usr/share/zoneinfo/目录下的时区文件拷贝为/etc/localtime文件。
rm -fr /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ls -lrt /etc/localtime
2.6 关闭swap交换内存(可选)
cp /etc/fstab /etc/fstab.bak
sed -i ‘/swap/s/^/#/’ /etc/fstab
cat /etc/fstab|grep -v ^#|grep -v ‘^$’
#临时关闭swap
swapoff -a
2.7 设置网卡MTU值
将各数据库节点的网卡MTU值设置为相同大小。对于x86,MTU值推荐1500;
对于ARM,MTU值推荐8192。
#首先使用ifconfig查看网卡编号
ifconfig
#本实验环境网卡编号都为ens33,将MTU值设置为1500
ifconfig ens33 mtu 1500
##2.7 关闭RemoveIPC(openEulor需要)
##说明:在各数据库节点上,关闭RemoveIPC。CentOS操作系统无该参数,可以跳过该步骤。
sed -i ‘/^RemoveIPC/d’ /usr/lib/systemd/system/systemdlogind.service
echo “RemoveIPC=no” >> /etc/systemd/logind.conf
echo “RemoveIPC=no” >> /usr/lib/systemd/system/systemdlogind.service
systemctl daemon-reload
systemctl restart systemd-logind
#检查修改是否生效。
loginctl show-session | grep RemoveIPC
systemctl show systemd-logind | grep RemoveIPC
##2.8 设置root用户远程登陆
#配置SSH服务(允许root登录,关闭Banner)
#允许root登录,关闭登录Banner,配置文件需要重启生效
sed -i ‘/Banner/s/^/#/’ /etc/ssh/sshd_config
sed -i ‘/PermitRootLogin/s/^/#/’ /etc/ssh/sshd_config
echo -e “\n” >> /etc/ssh/sshd_config
echo "Banner none " >> /etc/ssh/sshd_config
echo “PermitRootLogin yes” >> /etc/ssh/sshd_config
cat /etc/ssh/sshd_config |grep -v ^#|grep -E ‘PermitRootLogin|Banner’
Banner none
PermitRootLogin yes
systemctl restart sshd
2.8 安装python3.6.x
[root@mogdb01 ~]# python --version
Python 2.7.5
mkdir -p /usr/local/python3
cd /usr/local/python3
如果在线获取慢,单独下载上传到服务器
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar -zxvf Python-3.6.5.tgz
cd Python-3.6.5
./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC && make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@mogdb01 Python-3.6.5]# find / -name libpython3.6m.so.1.0
/tmp/Python-3.6.5/libpython3.6m.so.1.0
/usr/local/python3/lib/libpython3.6m.so.1.0
[root@mogdb01 Python-3.6.5]# cp /usr/local/python3/lib/libpython3.6m.so.1.0 /usr/lib64
[root@mogdb01 Python-3.6.5]# python3 --version
Python 3.6.5
2.9 关闭透明页transparent_hugepage
sed -i ‘/^GRUB_CMDLINE_LINUX/d’ /etc/default/grub
echo “GRUB_CMDLINE_LINUX=“rhgb quiet transparent_hugepage=never”” >> /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file …
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-c6e7c68d3248485d9d8f764f587db157
Found initrd image: /boot/initramfs-0-rescue-c6e7c68d3248485d9d8f764f587db157.img
done
echo “11.Close transparent_hugepage completed.”
echo -e “\n”
重启主机检查
[root@mogdb01 ~]# reboot
[root@mogdb01 ~]# grep AnonHugePages /proc/meminfo
AnonHugePages: 0 kB
3. PTK工具
3.1 PTK工具介绍
PTK (Provisioning Toolkit)是一款针对 MogDB 数据库开发的软件安装和运维工具,旨在帮助用户更便捷地安装部署MogDB数据库。
3.2 在线安装PTK
[root@mogdb01 ~]# curl --proto '=https' --tlsv1.2 -sSf https://cdn-mogdb.enmotech.com/ptk/install.sh | sh
Downloading ptk package...
Detected shell: bash
Shell profile: /root/.bash_profile
ptk has been added to PATH in /root/.bash_profile
open a new terminal or source /root/.bash_profile to active it
Installed path: /root/.ptk/bin/ptk
[root@mogdb01 ~]# cd /root/.ptk/bin/
[root@mogdb01 bin]# ls -lrt
total 13452
-rw-r--r--. 1 501 games 294 Sep 1 15:56 README.md
-rwxr-xr-x. 1 501 games 13770752 Sep 20 18:01 ptk
[root@mogdb01 ~]# cd /root/.ptk/bin/
[root@mogdb01 bin]# ls -lrt
total 13452
-rw-r--r--. 1 501 games 294 Sep 1 15:56 README.md
-rwxr-xr-x. 1 501 games 13770752 Sep 20 18:01 ptk
3.3 查看当前版本
[root@mogdb01 ~]# ptk -v
PTK Version: v0.4.2
Go Version: go1.17.1
Build Date: 2022-09-20T10:01:20Z
Git Hash: 807d6f8
3.4 PTK CANDIDATE
该命令有两个子命令:
ptk candidate db - 列出支持安装的 MogDB 数据库版本列表
[root@mogdb01 ~]# ptk candidate db
software | version
-----------+----------
MogDB | 3.0.2
| 3.0.1
| 3.0.0
| 2.1.1
| 2.0.3
| 2.0.1
| 2.0.0
ptk candidate os - 列出支持安装 MogDB 的操作系统
[root@mogdb01 ~]# ptk candidate os
id | os | tested version(s)
----------+-------------------------------------+----------------------------
1007010 | CentOS Linux 7 (Core) (x86_64) | 7.6.1810 (Core)
1008010 | Centos 8 (x86_64) | 8.0.1905 (Core)
1008020 | Centos 8 (arm64) | 8.0.1905 (Core)
1120010 | openEuler 20 (x86_64) | 20.03 LTS
1120020 | openEuler 20 (arm64) | 20.03 LTS
1122010 | openEuler 22 (x86_64) | 22.03 LTS
1122020 | openEuler 22 (arm64) | 22.03 LTS
1210010 | Kylin V10 (x86_64) | V10 (Tercel)
1210020 | Kylin V10 (arm64) | V10 (Tercel)
1320010 | UOS 20 A (x86_64) | 1002a/1020a/1050a
1320020 | UOS 20 A (arm64) | 1050a (kongzi)
1420010 | UOS 20 D/E (x86_64) | 1040d (fou)
1420020 | UOS 20 D/E (arm64) | 1040d (fou)
1520010 | Ubuntu 20 (x86_64) | 20.04.3 LTS (Focal Fossa)
1522010 | Ubuntu 22 (x86_64) | 22.04 (Jammy Jellyfish)
1607010 | Red Hat Enterprise Linux 7 (x86_64) | 7.5 (Maipo)
1608010 | Red Hat Enterprise Linux 8 (x86_64) | 8.5 (Ootpa)
1702010 | EulerOS 2 (x86_64) | 2.0 (SP3)
1702020 | EulerOS 2 (arm64) | 2.0 (SP3)
1812010 | SLES 12SP5 (x86_64) | 12SP5
1907010 | Oracle Linux 7 (x86_64) | 7.9 (Maipo)
1908010 | Oracle Linux 8 (x86_64) | 8.6 (Ootpa)
2008010 | Rocky Linux 8 (x86_64) | 8.5 (Green Obsidian)
2107010 | NeoKylin V7 (x86_64) | V7Update6
2222010 | FusionOS 22 (x86_64) | 22.0.2
2222020 | FusionOS 22 (arm64) | 22.0.2
4.安装数据库
4.1 准备拓补配置文件
PTK安装需要提供配置文件config.yaml,PTK支持单节点安装以及多节点安装。此次实验以一主一备节点安装为例。
[root@mogdb01 ~]# ptk template --local > config.yaml
[root@mogdb01 ~]# ls -lrt
total 12
-rw-------. 1 root root 1471 Jul 5 12:11 anaconda-ks.cfg
-rw-r--r--. 1 root root 1519 Jul 5 12:52 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 Jul 5 15:52 Templates
drwxr-xr-x. 2 root root 6 Jul 5 15:52 Public
drwxr-xr-x. 2 root root 6 Jul 5 15:52 Music
drwxr-xr-x. 2 root root 6 Jul 5 15:52 Downloads
drwxr-xr-x. 2 root root 6 Jul 5 15:52 Documents
drwxr-xr-x. 2 root root 6 Jul 5 15:52 Desktop
drwxr-xr-x. 2 root root 6 Jul 5 15:52 Videos
drwxr-xr-x. 2 root root 6 Jul 5 15:52 Pictures
-rw-r--r--. 1 root root 471 Sep 23 17:17 config.yaml
[root@mogdb01 ~]# ptk encrypt oracle
oracle: pTk6Y2QwYWIxZmY8RT5APT9BQ04zRFdkX1dnel82Tk85UWpVUHZoc29wY21lRER3ejhveThNeExHRkZBQ0U=
[root@mogdb02 ~]# ptk encrypt oracle
oracle: pTk6MmVlYTZjZWQ8RT5APT9BREpxTjAwc1k0WEVuREplNTRhWDdOeEhjbzR5Rlh4c2Z5QlF5bW5wemZpYTQ=
vi config.yaml
# config.yaml
global:
cluster_name: mogdb_cluster1
user: omm
group: omm
base_dir: /opt/mogdb
db_servers:
- host: 192.168.10.13
db_port: 26000
role: primary
ssh_option:
port: 22
user: root
password: pTk6MTk1M2FhM2Q8RT5APTxBQHF6eTd0YjZHMnMyWWd2cnZ3UVlONXFYemRiZ25jVENGUlhzd3VpbVZZVk0=
- host: 192.168.10.14
db_port: 26000
role: standby
ssh_option:
port: 22
user: root
password: pTk6MmYxMTY4OTQ8RT5APTxBPkFHVGM1LVpFTFBCVmk0OUdzM1d4ZzdvN19PTU5jV1RQWDVZZV9NZ2Fqc0E=
4.2 执行检查
检查等级
OK:符合预期值,满足安装需求
Warning: 不符合预期值,但可以满足安装需求
Abnormal: 不满足安装要求,可能会导致安装过程失败,需根据 PTK 给出的修改建议脚本,人工执行修改
ExecuteError: 执行错误,该等级表示 PTK 在检查时执行命令失败,可能为用户环境工具缺失或内部BUG,需根据实际错误提示进行修正
在安装数据库之前,需确保所有的检查项都在 OK 或 Warning 级别,如果存在 Abnormal 的检查结果,在安装时会报错退出。
[root@mogdb01 ~]# ptk checkos -f config.yaml
INFO[2022-09-24T13:59:08.272] prechecking dependent tools...
INFO[2022-09-24T13:59:08.371] platform: centos_7_64bit host=192.168.10.14
INFO[2022-09-24T13:59:08.371] platform: centos_7_64bit host=192.168.10.13
INFO[2022-09-24T13:59:08.375] kernel version: 3.10.0-957.el7.x86_64 host=192.168.10.13
INFO[2022-09-24T13:59:08.386] kernel version: 3.10.0-957.el7.x86_64 host=192.168.10.14
INFO[2022-09-24T13:59:08.405] locale: LANG=en_US.UTF-8 host=192.168.10.13
INFO[2022-09-24T13:59:08.416] locale: LANG=en_US.UTF-8 host=192.168.10.14
INFO[2022-09-24T13:59:08.421] timezone: +0800 host=192.168.10.13
INFO[2022-09-24T13:59:08.432] timezone: +0800 host=192.168.10.14
INFO[2022-09-24T13:59:08.438] swap memory 8388604kB, total memory 8155144kB host=192.168.10.13
INFO[2022-09-24T13:59:08.448] swap memory 8388604kB, total memory 8155152kB host=192.168.10.14
WARN[2022-09-24T13:59:08.459] net.ipv4.tcp_tw_reuse=0, expect 1 host=192.168.10.13
WARN[2022-09-24T13:59:08.464] net.ipv4.tcp_tw_recycle=0, expect 1 host=192.168.10.13
WARN[2022-09-24T13:59:08.470] net.ipv4.tcp_retries1=3, expect 5 host=192.168.10.13
WARN[2022-09-24T13:59:08.478] net.ipv4.tcp_wmem=4096 16384 4194304, expect 8192 250000 16777216 host=192.168.10.13
WARN[2022-09-24T13:59:08.483] net.core.somaxconn=128, expect 65535 host=192.168.10.14
WARN[2022-09-24T13:59:08.487] net.core.wmem_default=212992, expect 21299200 host=192.168.10.13
WARN[2022-09-24T13:59:08.496] net.ipv4.tcp_syn_retries=6, expect 5 host=192.168.10.13
WARN[2022-09-24T13:59:08.500] net.core.rmem_default=212992, expect 21299200 host=192.168.10.13
WARN[2022-09-24T13:59:08.509] vm.min_free_kbytes=11420, expect 407757 host=192.168.10.13
WARN[2022-09-24T13:59:08.518] net.ipv4.tcp_keepalive_intvl=75, expect 30 host=192.168.10.13
WARN[2022-09-24T13:59:08.526] net.core.netdev_max_backlog=1000, expect 65535 host=192.168.10.13
WARN[2022-09-24T13:59:08.539] net.ipv4.tcp_keepalive_time=7200, expect 30 host=192.168.10.13
WARN[2022-09-24T13:59:08.544] net.core.somaxconn=128, expect 65535 host=192.168.10.13
WARN[2022-09-24T13:59:08.548] net.core.wmem_max=212992, expect 21299200 host=192.168.10.13
WARN[2022-09-24T13:59:08.548] net.ipv4.tcp_tw_reuse=0, expect 1 host=192.168.10.14
WARN[2022-09-24T13:59:08.552] net.ipv4.tcp_max_syn_backlog=256, expect 65535 host=192.168.10.13
WARN[2022-09-24T13:59:08.560] net.core.rmem_max=212992, expect 21299200 host=192.168.10.13
WARN[2022-09-24T13:59:08.565] net.ipv4.tcp_retries2=15, expect 12 host=192.168.10.14
WARN[2022-09-24T13:59:08.569] net.ipv4.tcp_retries2=15, expect 12 host=192.168.10.13
WARN[2022-09-24T13:59:08.572] net.ipv4.tcp_rmem=4096 87380 6291456, expect 8192 250000 16777216 host=192.168.10.13
WARN[2022-09-24T13:59:08.581] kernel.sem=250 32000 32 128, expect 250 6400000 1000 25600 host=192.168.10.13
INFO[2022-09-24T13:59:08.581] check kernel.core_pattern host=192.168.10.13
WARN[2022-09-24T13:59:08.581] net.ipv4.tcp_max_syn_backlog=256, expect 65535 host=192.168.10.14
INFO[2022-09-24T13:59:08.589] check removeIPC value host=192.168.10.13
WARN[2022-09-24T13:59:08.596] net.core.netdev_max_backlog=1000, expect 65535 host=192.168.10.14
WARN[2022-09-24T13:59:08.628] vm.min_free_kbytes=11420, expect 407757 host=192.168.10.14
WARN[2022-09-24T13:59:08.657] net.core.rmem_max=212992, expect 21299200 host=192.168.10.14
WARN[2022-09-24T13:59:08.688] kernel.sem=250 32000 32 128, expect 250 6400000 1000 25600 host=192.168.10.14
WARN[2022-09-24T13:59:08.704] net.core.wmem_max=212992, expect 21299200 host=192.168.10.14
WARN[2022-09-24T13:59:08.720] net.core.wmem_default=212992, expect 21299200 host=192.168.10.14
WARN[2022-09-24T13:59:08.735] net.ipv4.tcp_keepalive_intvl=75, expect 30 host=192.168.10.14
WARN[2022-09-24T13:59:08.749] net.ipv4.tcp_retries1=3, expect 5 host=192.168.10.14
WARN[2022-09-24T13:59:08.795] net.ipv4.tcp_keepalive_time=7200, expect 30 host=192.168.10.14
WARN[2022-09-24T13:59:08.810] net.ipv4.tcp_wmem=4096 16384 4194304, expect 8192 250000 16777216 host=192.168.10.14
WARN[2022-09-24T13:59:08.824] net.ipv4.tcp_syn_retries=6, expect 5 host=192.168.10.14
WARN[2022-09-24T13:59:08.838] net.ipv4.tcp_tw_recycle=0, expect 1 host=192.168.10.14
WARN[2022-09-24T13:59:08.867] net.ipv4.tcp_rmem=4096 87380 6291456, expect 8192 250000 16777216 host=192.168.10.14
WARN[2022-09-24T13:59:08.911] net.core.rmem_default=212992, expect 21299200 host=192.168.10.14
INFO[2022-09-24T13:59:08.911] check kernel.core_pattern host=192.168.10.14
INFO[2022-09-24T13:59:08.942] check removeIPC value host=192.168.10.14
WARN[2022-09-24T13:59:08.993] device(/dev/sda) readahead value=8192, expect 16384. host=192.168.10.13
WARN[2022-09-24T13:59:09.029] device(/dev/sda) readahead value=8192, expect 16384. host=192.168.10.14
WARN[2022-09-24T13:59:09.109] device(dm-0) 'IO Request'=128, expect 256 host=192.168.10.13
WARN[2022-09-24T13:59:09.109] device(dm-1) 'IO Request'=128, expect 256 host=192.168.10.13
WARN[2022-09-24T13:59:09.109] device(sda) 'IO Request'=128, expect 256 host=192.168.10.13
WARN[2022-09-24T13:59:09.109] device(sr0) 'IO Request'=128, expect 256 host=192.168.10.13
WARN[2022-09-24T13:59:09.122] device(dm-0) 'IO Request'=128, expect 256 host=192.168.10.14
WARN[2022-09-24T13:59:09.122] device(dm-1) 'IO Request'=128, expect 256 host=192.168.10.14
WARN[2022-09-24T13:59:09.122] device(sda) 'IO Request'=128, expect 256 host=192.168.10.14
WARN[2022-09-24T13:59:09.122] device(sr0) 'IO Request'=128, expect 256 host=192.168.10.14
[host 192.168.10.13]: not found package: numactl
[host 192.168.10.14]: not found package: numactl
INFO[2022-09-24T13:59:14.418] check port 26000 host=192.168.10.14
INFO[2022-09-24T13:59:14.418] check port 26000 host=192.168.10.13
INFO[2022-09-24T13:59:14.468] port 26000 is free host=192.168.10.13
INFO[2022-09-24T13:59:14.491] port 26000 is free host=192.168.10.14
INFO[2022-09-24T13:59:14.492] write fix os script to root_fix_os.2022.0924.135907.sh successfully
INFO[2022-09-24T13:59:14.492] all checkers finished
# Check Results
Item | Level
------------------------------------+-----------
A1.Check_OS_Version | OK
A2.Check_Kernel_Version | OK
A3.Check_Unicode | OK
A4.Check_TimeZone | OK
A5.Check_Swap_Memory_Configure | Warning
A6.Check_SysCtl_Parameter | Abnormal
A7.Check_FileSystem_Configure | OK
A8.Check_Disk_Configure | OK
A9.Check_BlockDev_Configure | Warning
A9.Check_Logical_Block | OK
A10.Check_IO_Request | Warning
A10.Check_Asynchronous_IO_Request | OK
A10.Check_IO_Configure | OK
A11.Check_Network_Configure | OK
A12.Check_Time_Consistency | OK
A13.Check_Firewall_Service | OK
A14.Check_THP_Service | OK
A15.Check_Dependent_Package | Abnormal
A16.Check_CPU_Instruction_Set | OK
A17.Check_Port | OK
Total count 20, abnormal count 2, warning count 3
Failed to check os, can’t perform installation unless fix all the abnormal items
You can use 'ptk checkos -i ITEM --detail' to see detail message
Please check root_fix_os.[TIMESTAMP].sh for commands to resolve.
执行修复脚本
[root@mogdb01 ~]# ./root_fix_os.2022.0924.135907.sh
安装依赖包
[root@mogdb01 ~]# yum install -y numactl
重新检查
[root@mogdb01 ~]# ptk checkos -f config.yaml
# Check Results
Item | Level
------------------------------------+-----------
A1.Check_OS_Version | OK
A2.Check_Kernel_Version | OK
A3.Check_Unicode | OK
A4.Check_TimeZone | OK
A5.Check_Swap_Memory_Configure | Warning
A6.Check_SysCtl_Parameter | Abnormal
A7.Check_FileSystem_Configure | OK
A8.Check_Disk_Configure | OK
A9.Check_BlockDev_Configure | Warning
A9.Check_Logical_Block | OK
A10.Check_IO_Request | Warning
A10.Check_Asynchronous_IO_Request | OK
A10.Check_IO_Configure | OK
A11.Check_Network_Configure | OK
A12.Check_Time_Consistency | OK
A13.Check_Firewall_Service | OK
A14.Check_THP_Service | OK
A15.Check_Dependent_Package | Warning
A16.Check_CPU_Instruction_Set | OK
A17.Check_Port | OK
Total count 20, abnormal count 1, warning count 4
确保输出的检查结果均为 OK 或者 Warning ,如果有 Abnormal 或 ExecuteError出现,需用户根据日志提示先修正系统参数.
4.3 执行安装
[root@mogdb01 ~]# ptk install -f config.yaml --skip-check-os
INFO[2022-09-24T16:56:22.113] no package specified, use online package: https://cdn-mogdb.enmotech.com/mogdb-media/3.0.2/MogDB-3.0.2-CentOS-x86_64.tar.gz
INFO[2022-09-24T16:56:22.113] skip check operating system
INFO[2022-09-24T16:56:22.113] [stage=precheck]: start host=192.168.10.14
INFO[2022-09-24T16:56:22.113] check user 'omm' host=192.168.10.14
⣾ executing...INFO[2022-09-24T16:56:22.113] [stage=precheck]: start host=192.168.10.13
INFO[2022-09-24T16:56:22.113] check user 'omm' host=192.168.10.13
INFO[2022-09-24T16:56:22.121] [stage=precheck]: successful host=192.168.10.13
INFO[2022-09-24T16:56:22.132] [stage=precheck]: successful host=192.168.10.14
=============================
global:
cluster_name: mogdb_cluster1
user: omm
group: omm
db_port: 26000
base_dir: /opt/mogdb
app_dir: /opt/mogdb/app
data_dir: /opt/mogdb/data
log_dir: /opt/mogdb/log
tool_dir: /opt/mogdb/tool
tmp_dir: /opt/mogdb/tmp
db_servers:
- host: 192.168.10.13
db_port: 26000
ha_ips:
- 192.168.10.13
ha_port: 26001
role: primary
az_name: AZ1
az_priority: 1
- host: 192.168.10.14
db_port: 26000
ha_ips:
- 192.168.10.14
ha_port: 26001
role: standby
az_name: AZ1
az_priority: 1
=============================
Is cluster topo correct?[Y/N](default=Y) y
INFO[2022-09-24T16:56:35.444] downloading package...
> download MogDB-3.0.2-CentOS...: 132.50 MiB / 132.80 MiB [--------------------------------------------------------------------------------->] 99.77% 2.58 MiB p/s ETA 0s
> download MogDB-3.0.2-CentOS...: 132.80 MiB / 132.80 MiB [------------------------------------------------------------------------------------] 100.00% 3.48 MiB p/s 38s
INFO[2022-09-24T16:57:16.012] validation: installation package is safe
INFO[2022-09-24T16:57:16.013] parse version.cfg from MogDB-3.0.2-CentOS-64bit.tar.gz
INFO[2022-09-24T16:57:18.043] detected db version: MogDB-3.0.2, number: 92.605, commit_id: 9bc79be5
Please enter db password (8~16 characters):
Retype db password:
INFO[2022-09-24T16:57:56.958] scp file from /root/.ptk/cache/MogDB-3.0.2-CentOS-x86_64.tar.gz to 192.168.10.13:/tmp/MogDB-3.0.2-CentOS-x86_64.tar.gz host=192.168.10.13
INFO[2022-09-24T16:57:56.959] scp file from /root/.ptk/cache/MogDB-3.0.2-CentOS-x86_64.tar.gz to 192.168.10.14:/tmp/MogDB-3.0.2-CentOS-x86_64.tar.gz host=192.168.10.14
> upload MogDB-3.0.2-CentOS-x...: 132.80 MiB / 132.80 MiB [----------------------------------------------------------------------------------] 100.00% 24.17 MiB p/s 5.7s
INFO[2022-09-24T16:58:02.683] [stage=initial]: start host=192.168.10.14
INFO[2022-09-24T16:58:02.683] [stage=initial]: start host=192.168.10.13
INFO[2022-09-24T16:58:02.689] create os user omm, group omm host=192.168.10.13
INFO[2022-09-24T16:58:02.708] create os user omm, group omm host=192.168.10.14
INFO[2022-09-24T16:58:02.727] set ulimits host=192.168.10.13
INFO[2022-09-24T16:58:02.732] set user omm profiles host=192.168.10.13
INFO[2022-09-24T16:58:02.765] set ulimits host=192.168.10.14
INFO[2022-09-24T16:58:02.783] set user omm profiles host=192.168.10.14
INFO[2022-09-24T16:58:02.794] add c library /usr/local/lib to /etc/ld.so.conf.d/libc.conf host=192.168.10.13
INFO[2022-09-24T16:58:02.799] mkdir /opt/mogdb/tool host=192.168.10.13
INFO[2022-09-24T16:58:02.858] decompress MogDB-3.0.2-CentOS-x86_64.tar.gz to dir /opt/mogdb/tool host=192.168.10.13
INFO[2022-09-24T16:58:02.894] add c library /usr/local/lib to /etc/ld.so.conf.d/libc.conf host=192.168.10.14
INFO[2022-09-24T16:58:02.914] mkdir /opt/mogdb/tool host=192.168.10.14
INFO[2022-09-24T16:58:03.020] decompress MogDB-3.0.2-CentOS-x86_64.tar.gz to dir /opt/mogdb/tool host=192.168.10.14
INFO[2022-09-24T16:58:04.096] remove files /tmp/MogDB-3.0.2-CentOS-x86_64.tar.gz host=192.168.10.13
INFO[2022-09-24T16:58:04.123] decompress *-om.tar.gz to dir /opt/mogdb/tool host=192.168.10.13
INFO[2022-09-24T16:58:04.376] remove files /tmp/MogDB-3.0.2-CentOS-x86_64.tar.gz host=192.168.10.14
INFO[2022-09-24T16:58:04.416] decompress *-om.tar.gz to dir /opt/mogdb/tool host=192.168.10.14
INFO[2022-09-24T16:58:04.590] fix psutil lib host=192.168.10.13
WARN[2022-09-24T16:58:04.594]
Not found python3.6 or 3.7, skip fix psutil dynamic lib,
please install proper python and fix it manually or reinstall by ptk
if you don't fix this, it will cause that gs_om and cm_ctl cannot run proper,but not ptk and database host=192.168.10.13
INFO[2022-09-24T16:58:04.594] change /opt/mogdb/tool owner to omm host=192.168.10.13
INFO[2022-09-24T16:58:04.607] mkdir /opt/mogdb/app host=192.168.10.13
INFO[2022-09-24T16:58:04.704] decompress MogDB-3.0.2-CentOS-64bit.tar.gz to dir /opt/mogdb/app host=192.168.10.13
INFO[2022-09-24T16:58:04.856] fix psutil lib host=192.168.10.14
WARN[2022-09-24T16:58:04.874]
Not found python3.6 or 3.7, skip fix psutil dynamic lib,
please install proper python and fix it manually or reinstall by ptk
if you don't fix this, it will cause that gs_om and cm_ctl cannot run proper,but not ptk and database host=192.168.10.14
INFO[2022-09-24T16:58:04.874] change /opt/mogdb/tool owner to omm host=192.168.10.14
INFO[2022-09-24T16:58:04.897] mkdir /opt/mogdb/app host=192.168.10.14
INFO[2022-09-24T16:58:05.037] decompress MogDB-3.0.2-CentOS-64bit.tar.gz to dir /opt/mogdb/app host=192.168.10.14
INFO[2022-09-24T16:58:08.012] fix dynamic library for gs_initdb host=192.168.10.13
INFO[2022-09-24T16:58:08.075] fix dynamic library for mogdb host=192.168.10.13
INFO[2022-09-24T16:58:08.129] change /opt/mogdb/app owner to omm host=192.168.10.13
INFO[2022-09-24T16:58:08.143] mkdir /opt/mogdb/log/gs_profile,/opt/mogdb/log/pg_log,/opt/mogdb/log/pg_audit,/opt/mogdb/log/bin,/opt/mogdb/log/pg_log/dn_6001,/opt/mogdb/log/pg_audit/dn_6001,/opt/mogdb/log/pg_log/dn_6002,/opt/mogdb/log/pg_audit/dn_6002 host=192.168.10.13
INFO[2022-09-24T16:58:08.435] fix dynamic library for gs_initdb host=192.168.10.14
INFO[2022-09-24T16:58:08.523] fix dynamic library for mogdb host=192.168.10.14
INFO[2022-09-24T16:58:08.599] change /opt/mogdb/app owner to omm host=192.168.10.14
INFO[2022-09-24T16:58:08.625] mkdir /opt/mogdb/log/gs_profile,/opt/mogdb/log/pg_log,/opt/mogdb/log/pg_audit,/opt/mogdb/log/bin,/opt/mogdb/log/pg_log/dn_6001,/opt/mogdb/log/pg_audit/dn_6001,/opt/mogdb/log/pg_log/dn_6002,/opt/mogdb/log/pg_audit/dn_6002 host=192.168.10.14
INFO[2022-09-24T16:58:09.234] mkdir /opt/mogdb/tmp host=192.168.10.13
INFO[2022-09-24T16:58:09.312] save version to /opt/mogdb/app/bin/upgrade_version host=192.168.10.13
INFO[2022-09-24T16:58:09.353] create cluster_manual_start file host=192.168.10.13
INFO[2022-09-24T16:58:09.389] generate static config to /opt/mogdb/app/bin/cluster_static_config host=192.168.10.13
INFO[2022-09-24T16:58:09.399] change /opt/mogdb/app/bin/cluster_static_config owner to omm host=192.168.10.13
INFO[2022-09-24T16:58:09.405] mkdir /opt/mogdb/data host=192.168.10.13
INFO[2022-09-24T16:58:09.492] change /opt/mogdb/data owner to omm host=192.168.10.13
INFO[2022-09-24T16:58:09.496] initial database host=192.168.10.13
INFO[2022-09-24T16:58:10.144] mkdir /opt/mogdb/tmp host=192.168.10.14
INFO[2022-09-24T16:58:10.264] save version to /opt/mogdb/app/bin/upgrade_version host=192.168.10.14
INFO[2022-09-24T16:58:10.347] create cluster_manual_start file host=192.168.10.14
INFO[2022-09-24T16:58:10.394] generate static config to /opt/mogdb/app/bin/cluster_static_config host=192.168.10.14
INFO[2022-09-24T16:58:10.436] change /opt/mogdb/app/bin/cluster_static_config owner to omm host=192.168.10.14
INFO[2022-09-24T16:58:10.452] mkdir /opt/mogdb/data host=192.168.10.14
INFO[2022-09-24T16:58:10.562] change /opt/mogdb/data owner to omm host=192.168.10.14
INFO[2022-09-24T16:58:10.582] initial database host=192.168.10.14
INFO[2022-09-24T16:58:30.101] set 192.168.10.13 postgresql.conf host=192.168.10.13
INFO[2022-09-24T16:58:30.174] set 192.168.10.13 hba config host=192.168.10.13
INFO[2022-09-24T16:58:30.224] create certification authority files host=192.168.10.13
INFO[2022-09-24T16:58:30.746] move certification authority files to server host=192.168.10.13
INFO[2022-09-24T16:58:30.760] download certification authority files from host 192.168.10.13 host=192.168.10.13
INFO[2022-09-24T16:58:30.832] [stage=initial]: successful host=192.168.10.13
INFO[2022-09-24T16:58:32.423] set 192.168.10.14 postgresql.conf host=192.168.10.14
INFO[2022-09-24T16:58:32.500] set 192.168.10.14 hba config host=192.168.10.14
INFO[2022-09-24T16:58:32.555] waiting for generate certification authority files... host=192.168.10.14
INFO[2022-09-24T16:58:32.555] upload certification authority files host=192.168.10.14
INFO[2022-09-24T16:58:32.841] move certification authority files to server host=192.168.10.14
INFO[2022-09-24T16:58:32.862] [stage=initial]: successful host=192.168.10.14
INFO[2022-09-24T16:58:32.862] start make ssh mutual trust for omm
INFO[2022-09-24T16:58:33.053] make ssh mutual trust successfully
INFO[2022-09-24T16:58:33.053] [stage=launch]: start host=192.168.10.14
INFO[2022-09-24T16:58:33.053] start 192.168.10.14 database by gs_ctl host=192.168.10.14
⣾ executing...INFO[2022-09-24T16:58:33.053] [stage=launch]: start host=192.168.10.13
INFO[2022-09-24T16:58:33.053] start 192.168.10.13 database by gs_ctl host=192.168.10.13
INFO[2022-09-24T16:58:35.928] waiting for primary startup... host=192.168.10.14
INFO[2022-09-24T16:58:36.366] alter initial user password host=192.168.10.13
INFO[2022-09-24T16:58:36.513] [stage=launch]: successful host=192.168.10.13
INFO[2022-09-24T16:58:36.513] primary startuped, start build current db host=192.168.10.14
INFO[2022-09-24T16:58:36.513] build 192.168.10.14 database by gs_ctl host=192.168.10.14
INFO[2022-09-24T16:58:46.316] [stage=launch]: successful host=192.168.10.14
INFO[2022-09-24T16:58:46.316] Time elapsed: 2m24s
cluste_name | host | user | port | stage | status | message
-----------------+---------------+------+-------+--------+---------------+----------
mogdb_cluster1 | 192.168.10.13 | omm | 26000 | launch | start_success | success
| 192.168.10.14 | omm | 26000 | launch | start_success | success
–skip-check-os参数是指跳过检查系统环境,因为之前忽略了两个报错,所以要跳过这一步检查
-没有指定安装包,ptk会自己选择合适的安装包进行下载
4.4 集群/实例状态管理
ptk ls
列出当前用户已经安装的所有数据库列表,PTK以使用用户作为区分,所以不同用户之间仅能看到自己安装的列表
[root@mogdb01 ~]# ptk ls
cluster_name | instances | user | data_dir | db_version | create_time | comment
-----------------+---------------------+------+-----------------+------------------------------+---------------------+----------
mogdb_cluster1 | 192.168.10.13:26000 | omm | /opt/mogdb/data | MogDB 3.0.2 (build 9bc79be5) | 2022-09-24 16:58:02 |
| 192.168.10.14:26000 |
查看数据库实例状态
[root@mogdb01 ~]# ptk cluster status -n mogdb_cluster1
[ Cluster State ]
database_version : MogDB-3.0.2
cluster_name : mogdb_cluster1
cluster_state : Normal
current_az : AZ_ALL
[ Datanode State ]
id | ip | port | user | instance | db_role | state
-------+---------------+-------+------+----------+---------+---------
6001 | 192.168.10.13 | 26000 | omm | dn_6001 | primary | Normal
6002 | 192.168.10.14 | 26000 | omm | dn_6002 | standby | Normal
[root@mogdb01 ~]# su - omm
Last login: Sat Sep 24 16:58:36 CST 2022
[omm@mogdb01 ~]$ gs_om -t status --detail
[ Cluster State ]
cluster_state : Normal
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip port instance state
----------------------------------------------------------------------------------
1 mogdb01 192.168.10.13 26000 6001 /opt/mogdb/data P Primary Normal
2 mogdb02 192.168.10.14 26000 6002 /opt/mogdb/data S Standby Normal
PTK 命令参考
ptk candidate - 打印 PTK 支持的软件版本列表
ptk checkos - 检查集群服务器系统依赖是否满足安装数据库需求
ptk encrypt - 提供一个便捷的方式来加密您的文本或密码
ptk env - 打印 PTK 环境变量信息
ptk install - 基于给定的拓扑配置部署MogDB数据库集群
ptk ls - 列出所有MogDB集群列表
ptk self - 操作 PTK 自身安装包
ptk cluster -数据库集群操作
ptk template - 打印配置模板
ptk uninstall - 卸载 MogDB 数据库集群
ptk gen-om-xml - 生成 gs_om 的 XML 配置文件
ptk version - 打印 PTK 版本
ptk completion - 为指定的 shell 生成自动补全




