暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PTK安装部署一主一备MogDB(CentOS8 arm)

原创 张均 云和恩墨 2022-09-09
1024

一. 实验环境

本次实验环境是通过mac电脑上的vmware软件部署的两套centos 8(arm)操作系统,具体信息如下:

角色 IP 主机名 操作系统信息 PTK版本
172.16.117.128 mogdbA Linux mogdbA 5.11.12-300.el8.aarch64 #1 SMP Fri Jul 30 12:03:15 CST 2021 aarch64 aarch64 aarch64 GNU/Linux v0.3.8
172.16.117.129 mogdbB Linux mogdbA1 5.11.12-300.el8.aarch64 #1 SMP Fri Jul 30 12:03:15 CST 2021 aarch64 aarch64 aarch64 GNU/Linux v0.3.8
curl --proto '=https' --tlsv1.2 -sSf https://cdn-mogdb.enmotech.com/ptk/install.sh | sh

二. 操作系统安装前准备

在安装部署mogdb前,需要对两套操作系统进行配置

2.1 关闭操作系统防火墙

  • 修改/etc/selinux/config文件中的“SELINUX”值为“disabled”。
vim /etc/selinux/config

修改“SELINUX”的值“disabled”,执行:wq保存并退出修改。

SELINUX=disabled
  • 使用systemctl命令停止防火墙并禁止开机自启
#查看firewalld状态
[root@mogdbA ~]# systemctl status firewalld
#停止firewalld服务
[root@mogdbA ~]# systemctl stop firewalld
#关闭firewalld服务开机自启
[root@mogdbA ~]# systemctl disable firewalld

若防火墙状态显示为active (running),则表示防火墙未关闭.
若防火墙状态显示为inactive (dead), 则表示防火墙已关闭

2.2 各个节点设置为相同字符集

查看各节点的字符集:

[root@mogdbA ~]# echo $LANG
zh_CN.UTF-8
[root@mogdbA1 ~]# echo $LANG
zh_CN.UTF-8

2.3 设置时区和时间

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

2.4 关闭swap交换内存

swapoff -a

2.5 设置各节点网卡MTU值相同

  • 使用ifconfig命令查看网卡信息。
  • 修改网卡MTU
ifconfig 网卡编号 mtu value

三. PTK工具

3.1 PTK工具介绍

PTK (Provisioning Toolkit)是一款针对 MogDB 数据库开发的软件安装和运维工具,旨在帮助用户更便捷地安装部署MogDB数据库。

3.2 在线安装PTK

[root@mogdbA hugepages]# 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

安装好后,执行一下命令使环境变量生效

source /root/.bash_profile

3.3 查看当前版本

[root@mogdbA hugepages]# ptk -v

PTK Version: v0.3.8
Go Version: go1.17.1
Build Date: 2022-08-31T14:12:21Z
Git Hash: b3fa51b

3.4 PTK CANDIDATE

该命令有两个子命令:

  • ptk candidate db - 列出支持安装的 MogDB 数据库版本列表
[root@mogdbA hugepages]# ptk candidate db
  software | version
-----------+----------
  MogDB    | 3.0.1
           | 3.0.0
           | 2.1.1
           | 2.0.3
           | 2.0.1
           | 2.0.0

本次安装选择3.0.1版本

  • ptk candidate os - 列出支持安装 MogDB 的操作系统
[root@mogdbA hugepages]# ptk candidate os
  id |                 os                  |     tested version(s)
-----+-------------------------------------+----------------------------
   1 | CentOS 7 (x86_64)                   | 7.6.1810 (Core)
   2 | openEuler 20 (x86_64)               | 20.03 LTS
   3 | openEuler 20 (arm64)                | 20.03 LTS
   4 | openEuler 22 (x86_64)               | 22.03 LTS
   5 | openEuler 22 (arm64)                | 22.03 LTS
   6 | Kylin V10 (x86_64)                  | V10 (Tercel)
   7 | Kylin V10 (arm64)                   | V10 (Tercel)
   8 | UOS 20 A (x86_64)                   | 1002a/1020a/1050a
   9 | UOS 20 A (arm64)                    | 1050a (kongzi)
  10 | Ubuntu 20 (x86_64)                  | 20.04.3 LTS (Focal Fossa)
  11 | CentOS 8 (arm64)                    | 8.0.1905 (Core)
  12 | CentOS 8 (x86_64)                   | 8.0.1905 (Core)
  13 | Red Hat Enterprise Linux 7 (x86_64) | 7.5 (Maipo)
  14 | Red Hat Enterprise Linux 8 (x86_64) | 8.5 (Ootpa)
  15 | EulerOS 2 (x86_64)                  | 2.0 (SP3)
  16 | EulerOS 2 (arm64)                   | 2.0 (SP3)
  18 | SLES 12SP5 (x86_64)                 | 12SP5
  19 | Oracle Linux 7 (x86_64)             | 7.9 (Maipo)
  20 | Oracle Linux 8 (x86_64)             | 8.6 (Ootpa)
  21 | Rocky Linux 8 (x86_64)              | 8.5 (Green Obsidian)
  22 | NeoKylin V7 (x86_64)                | V7Update6
  23 | UOS 20 D/E (x86_64)                 | 1040d (fou)
  24 | UOS 20 D/E (arm64)                  | 1040d (fou)
  25 | Ubuntu 22 (x86_64)                  | 22.04 (Jammy Jellyfish)

第11行CentOS 8 (arm64)是支持安装的。

四. 安装数据库

4.1 准备拓补配置文件

PTK安装需要提供配置文件config.yaml,PTK支持单节点安装以及多节点安装。此次实验以一主一备节点安装为例。

[root@mogdbA ~]# vi config.yaml

在文件中添加一下信息

# config.yaml
global:
    cluster_name: mogdb_cluster1
    user: omm
    group: omm
    base_dir: /opt/mogdb
db_servers:
    - host: 172.16.117.128
      db_port: 26000
      role: primary
      ssh_option:
        port: 22
        user: root
        password:Enmo@123
    - host: 172.16.117.129
      db_port: 26000
      role: standby
      ssh_option:
        port: 22
        user: root
        password:Enmo@123

4.2 检查本机系统

ptk checkos -f config.yaml

确保输出的检查结果均为 OK 或者 Warning ,如果有 Abnormal 或 ExecuteError出现,需用户根据日志提示先修正系统参数.

  • 出现报错
[root@mogdbA ~]# ptk checkos -f config.yaml
[PTK-4036] password field [172.16.117.128.ssh_optino.password] must be encrypted with ptk, raw password in config is not allowed
Please type "ptk encrypt -h" for more help

解决方法:使用ptk encrypt Enmo@123加密密码,将获得的文本替换config.yaml中的password

[root@mogdbA ~]# ptk encrypt Enmo@123
Enmo@123: pTk6MGZlYjk4OWQ8RTxDPj4/QXBDSDFsT0VCRDBWUEhtSVNtTlQyRFVUd3ZMNDRRTkZ4aVV0cXgzUmNRSlk=
  • 再次执行checkos,输出列表:
# 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    | OK
  A6.Check_SysCtl_Parameter         | Warning
  A7.Check_FileSystem_Configure     | OK
  A8.Check_Disk_Configure           | OK
  A9.Check_BlockDev_Configure       | Warning
  A9.Check_Logical_Block            | OK
  A10.Check_IO_Configure            | Warning
  A10.Check_IO_Request              | Warning
  A10.Check_Asynchronous_IO_Request | OK
  A11.Check_Network_Configure       | OK
  A12.Check_Time_Consistency        | OK
  A13.Check_Firewall_Service        | OK
  A14.Check_THP_Service             | ExecuteError
  A15.Check_Dependent_Package       | Abnormal
  A16.Check_CPU_Instruction_Set     | Abnormal
  A17.Check_Port                    | OK
Total count 20, abnormal count 3, warning count 4

A14的问题是无法找到透明大页的文件,可以忽略
A15的问题是依赖包问题,使用yum install可以下载缺少的依赖包即可
A6的问题是找不到bmi2指令集,不影响测试,可以忽略

4.2 执行安装

[root@mogdbA ~]# ptk install  -f config.yaml  --skip-check-os
INFO[2022-09-07T22:58:01.756] 未指定安装包路径,默认使用在线包: https://cdn-mogdb.enmotech.com/mogdb-media/3.0.1/MogDB-3.0.1-openEuler-arm64.tar.gz
INFO[2022-09-07T22:58:01.756] skip check operating system
=============================
global:
  cluster_name: mogdb_cluster1
  user: omm
  group: omm
  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: 172.16.117.128
  db_port: 26000
  role: primary
  az_name: AZ1
  az_priority: 1
- host: 172.16.117.129
  db_port: 26000
  role: standby
  az_name: AZ1
  az_priority: 1

=============================
请确认集群拓扑配置是否正确?[Y|Yes](default=N) y
INFO[2022-09-07T22:58:18.625] 正在下载安装包...
> download MogDB-3.0.1-openEu...: 71.60 MiB / 128.22 MiB [----------------------------------------->________________________________] 55.84% 7.15 MiB p/s ETA 7s

–skip-check-os参数是指跳过检查系统环境,因为之前忽略了两个报错,所以要跳过这一步检查
-没有指定安装包,ptk会自己选择合适的安装包进行下载

4.3 安装回显

INFO[2022-09-07T22:58:37.762] 安装包下载成功
INFO[2022-09-07T22:58:38.733] validation: installation package is safe
INFO[2022-09-07T22:58:38.733] parse version.cfg from MogDB-3.0.1-openEuler-64bit.tar.gz
INFO[2022-09-07T22:58:40.507] detected db version: MogDB-3.0.1, number: 92.605, commit_id: 1a363ea9
INFO[2022-09-07T22:58:40.510] [stage=precheck]: start                       host=172.16.117.129
INFO[2022-09-07T22:58:40.510] check user 'omm'                              host=172.16.117.129
INFO[2022-09-07T22:58:40.510] [stage=precheck]: start                       host=172.16.117.128
INFO[2022-09-07T22:58:40.510] check user 'omm'                              host=172.16.117.128
INFO[2022-09-07T22:58:40.516] [stage=precheck]: successful                  host=172.16.117.128
INFO[2022-09-07T22:58:40.533] [stage=precheck]: successful                  host=172.16.117.129
请输入数据库初始密码(需8到16位)
请再次输入数据库初始密码:
INFO[2022-09-07T22:59:55.847] scp file from /root/.ptk/cache/MogDB-3.0.1-openEuler-arm64.tar.gz to 172.16.117.129:/tmp/MogDB-3.0.1-openEuler-arm64.tar.gz  host=172.16.117.129
INFO[2022-09-07T22:59:55.848] scp file from /root/.ptk/cache/MogDB-3.0.1-openEuler-arm64.tar.gz to 172.16.117.128:/tmp/MogDB-3.0.1-openEuler-arm64.tar.gz  host=172.16.117.128
> upload MogDB-3.0.1-openEule...: 128.22 MiB / 128.22 MiB [-------------------------------------------------------------------------] 100.00% 13.55 MiB p/s 9.7s
INFO[2022-09-07T23:00:05.571] [stage=initial]: start                        host=172.16.117.129
INFO[2022-09-07T23:00:05.571] [stage=initial]: start                        host=172.16.117.128
INFO[2022-09-07T23:00:05.577] total memory(3GB) is less then 4GB, use default guc config  host=172.16.117.128
INFO[2022-09-07T23:00:05.577] create os user omm, group omm                 host=172.16.117.128
INFO[2022-09-07T23:00:05.603] total memory(3GB) is less then 4GB, use default guc config  host=172.16.117.129
INFO[2022-09-07T23:00:05.603] create os user omm, group omm                 host=172.16.117.129
INFO[2022-09-07T23:00:06.047] set ulimits                                   host=172.16.117.128
INFO[2022-09-07T23:00:06.049] set user omm profiles                         host=172.16.117.128
INFO[2022-09-07T23:00:06.085] add c library /usr/local/lib to /etc/ld.so.conf.d/libc.conf  host=172.16.117.128
INFO[2022-09-07T23:00:06.088] mkdir /opt/mogdb/tool                         host=172.16.117.128
INFO[2022-09-07T23:00:06.104] set ulimits                                   host=172.16.117.129
INFO[2022-09-07T23:00:06.129] set user omm profiles                         host=172.16.117.129
INFO[2022-09-07T23:00:06.131] decompress MogDB-3.0.1-openEuler-arm64.tar.gz to dir /opt/mogdb/tool  host=172.16.117.128
INFO[2022-09-07T23:00:06.204] add c library /usr/local/lib to /etc/ld.so.conf.d/libc.conf  host=172.16.117.129
INFO[2022-09-07T23:00:06.226] mkdir /opt/mogdb/tool                         host=172.16.117.129
INFO[2022-09-07T23:00:06.319] decompress MogDB-3.0.1-openEuler-arm64.tar.gz to dir /opt/mogdb/tool  host=172.16.117.129
INFO[2022-09-07T23:00:07.016] remove files /tmp/MogDB-3.0.1-openEuler-arm64.tar.gz  host=172.16.117.128
INFO[2022-09-07T23:00:07.024] decompress *-om.tar.gz to dir /opt/mogdb/tool  host=172.16.117.128
INFO[2022-09-07T23:00:07.171] remove files /tmp/MogDB-3.0.1-openEuler-arm64.tar.gz  host=172.16.117.129
INFO[2022-09-07T23:00:07.198] decompress *-om.tar.gz to dir /opt/mogdb/tool  host=172.16.117.129
INFO[2022-09-07T23:00:07.326] fix psutil lib                                host=172.16.117.128
INFO[2022-09-07T23:00:07.336] change /opt/mogdb/tool owner to omm           host=172.16.117.128
INFO[2022-09-07T23:00:07.340] mkdir /opt/mogdb/app                          host=172.16.117.128
INFO[2022-09-07T23:00:07.396] decompress MogDB-3.0.1-openEuler-64bit.tar.gz to dir /opt/mogdb/app  host=172.16.117.128
INFO[2022-09-07T23:00:07.519] fix psutil lib                                host=172.16.117.129
INFO[2022-09-07T23:00:07.594] change /opt/mogdb/tool owner to omm           host=172.16.117.129
INFO[2022-09-07T23:00:07.617] mkdir /opt/mogdb/app                          host=172.16.117.129
INFO[2022-09-07T23:00:07.724] decompress MogDB-3.0.1-openEuler-64bit.tar.gz to dir /opt/mogdb/app  host=172.16.117.129
INFO[2022-09-07T23:00:09.473] fix dynamic library for gs_initdb             host=172.16.117.128
INFO[2022-09-07T23:00:09.511] fix dynamic library for mogdb                 host=172.16.117.128
INFO[2022-09-07T23:00:09.547] change /opt/mogdb/app owner to omm            host=172.16.117.128
INFO[2022-09-07T23:00:09.553] 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=172.16.117.128
INFO[2022-09-07T23:00:09.887] fix dynamic library for gs_initdb             host=172.16.117.129
INFO[2022-09-07T23:00:09.961] fix dynamic library for mogdb                 host=172.16.117.129
INFO[2022-09-07T23:00:10.034] change /opt/mogdb/app owner to omm            host=172.16.117.129
INFO[2022-09-07T23:00:10.056] 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=172.16.117.129
INFO[2022-09-07T23:00:10.311] mkdir /opt/mogdb/tmp                          host=172.16.117.128
INFO[2022-09-07T23:00:10.366] save version to /opt/mogdb/app/bin/upgrade_version  host=172.16.117.128
INFO[2022-09-07T23:00:10.396] create cluster_manual_start file              host=172.16.117.128
INFO[2022-09-07T23:00:10.424] generate static config to /opt/mogdb/app/bin/cluster_static_config  host=172.16.117.128
INFO[2022-09-07T23:00:10.429] change /opt/mogdb/app/bin/cluster_static_config owner to omm  host=172.16.117.128
INFO[2022-09-07T23:00:10.431] mkdir /opt/mogdb/data                         host=172.16.117.128
INFO[2022-09-07T23:00:10.488] change /opt/mogdb/data owner to omm           host=172.16.117.128
INFO[2022-09-07T23:00:10.490] initial database                              host=172.16.117.128
INFO[2022-09-07T23:00:11.496] mkdir /opt/mogdb/tmp                          host=172.16.117.129
INFO[2022-09-07T23:00:11.611] save version to /opt/mogdb/app/bin/upgrade_version  host=172.16.117.129
INFO[2022-09-07T23:00:11.720] create cluster_manual_start file              host=172.16.117.129
INFO[2022-09-07T23:00:11.765] generate static config to /opt/mogdb/app/bin/cluster_static_config  host=172.16.117.129
INFO[2022-09-07T23:00:11.865] change /opt/mogdb/app/bin/cluster_static_config owner to omm  host=172.16.117.129
INFO[2022-09-07T23:00:11.885] mkdir /opt/mogdb/data                         host=172.16.117.129
INFO[2022-09-07T23:00:12.047] change /opt/mogdb/data owner to omm           host=172.16.117.129
INFO[2022-09-07T23:00:12.066] initial database                              host=172.16.117.129
INFO[2022-09-07T23:00:15.719] set 172.16.117.128 postgresql.conf            host=172.16.117.128
INFO[2022-09-07T23:00:15.754] set 172.16.117.128 hba config                 host=172.16.117.128
INFO[2022-09-07T23:00:15.785] create CA files                               host=172.16.117.128
INFO[2022-09-07T23:00:15.975] move CA files to server                       host=172.16.117.128
INFO[2022-09-07T23:00:15.980] download ca files from host 172.16.117.128    host=172.16.117.128
INFO[2022-09-07T23:00:16.012] [stage=initial]: successful                   host=172.16.117.128
INFO[2022-09-07T23:00:17.149] set 172.16.117.129 postgresql.conf            host=172.16.117.129
INFO[2022-09-07T23:00:17.203] set 172.16.117.129 hba config                 host=172.16.117.129
INFO[2022-09-07T23:00:17.251] waitting for generate CA files...             host=172.16.117.129
INFO[2022-09-07T23:00:17.251] upload CA files                               host=172.16.117.129
INFO[2022-09-07T23:00:17.573] move CA files to server                       host=172.16.117.129
INFO[2022-09-07T23:00:17.594] [stage=initial]: successful                   host=172.16.117.129
INFO[2022-09-07T23:00:17.594] start make ssh mutual trust for omm
INFO[2022-09-07T23:00:17.791] make ssh mutual trust successfully
INFO[2022-09-07T23:00:17.791] [stage=launch]: start                         host=172.16.117.129
INFO[2022-09-07T23:00:17.791] start 172.16.117.129 database by gs_ctl       host=172.16.117.129
⣾ executing...INFO[2022-09-07T23:00:17.791] [stage=launch]: start                         host=172.16.117.128
INFO[2022-09-07T23:00:17.791] start 172.16.117.128 database by gs_ctl       host=172.16.117.128
INFO[2022-09-07T23:00:18.858] alter initial user password                   host=172.16.117.128
INFO[2022-09-07T23:00:18.874] waitting for primary startup...               host=172.16.117.129
INFO[2022-09-07T23:00:18.957] [stage=launch]: successful                    host=172.16.117.128
INFO[2022-09-07T23:00:18.957] primary startuped, start build current db     host=172.16.117.129
INFO[2022-09-07T23:00:18.957] build 172.16.117.129 database by gs_ctl       host=172.16.117.129
INFO[2022-09-07T23:00:26.595] [stage=launch]: successful                    host=172.16.117.129
INFO[2022-09-07T23:00:26.595] Time elapsed: 2m25s
   cluste_name   |      host      | user | port  | stage  |    status     | message
-----------------+----------------+------+-------+--------+---------------+----------
  mogdb_cluster1 | 172.16.117.128 | omm  | 26000 | launch | start_success | success
                 | 172.16.117.129 | omm  | 26000 | launch | start_success | success
[root@mogdbA ~]#

4.4 集群/实例状态管理

  • ptk ls
    列出当前用户已经安装的所有数据库列表,PTK以使用用户作为区分,所以不同用户之间仅能看到自己安装的列表
[root@mogdbA ~]# ptk ls
   cluster_name  |      instances       | user |    data_dir     |          db_version          |     create_time     | comment
-----------------+----------------------+------+-----------------+------------------------------+---------------------+----------
  mogdb_cluster1 | 172.16.117.128:26000 | omm  | /opt/mogdb/data | MogDB 3.0.1 (build 1a363ea9) | 2022-09-07 23:00:05 |
                 | 172.16.117.129:26000 |      |                 |                              |                     |
  • ptk cluster

ptk cluster status: 查询集群或实例状态
ptk cluster start: 启动数据库集群或实例
ptk cluster stop: 停止数据库集群或实例
ptk cluster restart: 重启数据库集群或实例

  • 查看数据库实例状态
[root@mogdbA ~]# ptk cluster status -n mogdb_cluster1
[   Cluster State   ]
database_version			: MogDB-3.0.1
cluster_name				: mogdb_cluster1
cluster_state   			: Normal
current_az      			: AZ_ALL

[  Datanode State   ]
   id  |       ip       | port  | user | instance | db_role | state
-------+----------------+-------+------+----------+---------+---------
  6001 | 172.16.117.128 | 26000 | omm  | dn_6001  | primary | Normal
  6002 | 172.16.117.129 | 26000 | omm  | dn_6002  | standby | Normal

一主一备正常运行

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论