今天我们继续扒国产分布式数据库,前面陆续介绍了
OceanBase 和
TiDB 的安装,今天我们将目光转向 GaussDB,一个既让人感觉“熟悉”却又带有几分“神秘色彩”的国产数据库标杆。
与
OceanBase、
TDSQL 以及
GoldenDB 类似,
GaussDB 并非单一的数据库引擎,而是一套完整的数据库解决方案,同时支持
分布式与
集中式两种部署形态,并配套提供
TPOPS 统一运维管理平台、
DRS 数据实时同步、
UGO 数据库结构迁移等工具。
以下是 5 大主流国产分布式数据库的组件及其对比:
| 数据库产品 | 计算服务 | 存储服务 | 元数据 / 集群管理 | 全局事务号(TSO/GTS) | 运维管理平台 |
|---|---|---|---|---|---|
| OceanBase | OBServer | OBServer | RootService | RootService 提供 TSO | OCP |
| TDSQL For MySQL | ProxySQL | mysqld | ZooKeeper | MetaCluster 提供 GTS | 赤兔 |
| GaussDB | CN | DN | ETCD + System Catalog | GTM-Lite | TPOPS |
| GoldenDB | CN(DBProxy) | DN(mysqld) | MetadataServer | GTM | Insight |
| TiDB | TiDB Server | TiKV Server | Placement Driver(PD) | PD 提供 TSO | TEM |
之前的文章介绍了
OceanBase 三节点集群的 3 种部署方式,分别是纯命令行部署、
OCP 部署(界面安装)和
OBD 工具部署(脚本安装)。
GaussDB 的集中式和分布式集群也可以通过这三种方式安装,本文先介绍纯命令部署,后面再介绍通过
TPOPS 平台 和
Python 脚本的方式,在麒麟V10SP3 系统上安装
GaussDB 三节点集群。
| 主机名 | IP地址 | 配置大小 | 安装组件 |
|---|---|---|---|
| gauss1 | 192.168.182.138 | 4C16G200g | DN,CM |
| gauss2 | 192.168.182.139 | 4C16G200g | DN,CM |
| gauss3 | 192.168.182.140 | 4C16G200g | DN,CM |
集中式集群可安装的组件主要是:DN、CM 和 ETCD(可选),分布式集群多了 CN 和 GTM(后面再介绍)。
DN:实际存储和处理数据的数据库实例,主
DN 提供读写服务,两个备
DN 通过 Quorum 协议复制重放
WAL 日志;CM:集群管理与监控组件(
Cluster Manager),由
CM Server、
CM Agent 和
OM Monitor 组成,并不负责存储业务数据,而是管理集群中的数据库实例,
CM Agent 部署在每台主机上,
CM Server 自身也可采用一主多备部署;ETCD(可选):保存和协调一些集群状态、配置以及组件之间的协调信息。顺便提一下,在
PostgreSQL 和 海量数据
VastBase的高可用方案中,也借助
Patroni +
ETCD组件实现了一主两从的高可用架构。 既然
ETCD 可以选择不安装,用什么来存储集群状态信息呢?GaussDB 提供了
DCF(Distributed Consensus Framework) 自研分布式一致性共识框架,它基于 Paxos 协议开发,实现多数派节点自选主自仲裁、日志复制、一致性控制等高可用功能。
CM Server 可以选择使用
ETCD 或者
DCC,由参数 ddb_type 控制。
DCC 是基于
DCF 实现的一个状态机,用于实现集群中配置信息的管理。
DCC 内嵌在
CM 中,跟
ETCD 相比,少了一个进程。
💡 简单说:
DCF 是 GaussDB 研发的"Paxos 引擎",类似
ETCD 底层用的
Raft 库,但是用 Paxos 协议实现的,且深度嵌入 DN 进程。
DCC(Distributed Configuration Center),华为自研的分布式配置中心组件,
底层基于 DCF 实现,支持 KV 存储,可以想象成
ETCD。
总共 2 个安装包,上传到其中一个节点即可。
GaussDB-Kernel_505.1.RC1.SPC0100.B006_Server_X86_Centralized.tar.gz# 安装包 780M [root@gauss1 server]# du -sh GaussDB-Kernel_505.1.RC1.SPC0100.B006_Server_X86_Centralized.tar.gz 780M GaussDB-Kernel_505.1.RC1.SPC0100.B006_Server_X86_Centralized.tar.gz # 查看 tar 包内容 [root@gauss1 server]# tar -ztvf GaussDB-Kernel_505.1.RC1.SPC0100.B006_Server_X86_Centralized.tar.gz -rw-r--r-- slave1/slave1 100572176 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit.tar.gz -rw-r--r-- slave1/slave1 44389297 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_CM_Symbol.tar.gz -rw-r--r-- slave1/slave1 38308834 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_DBMind.tar.gz -rw-r--r-- slave1/slave1 16110 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Gds.tar.gz -rw-r--r-- slave1/slave1 97378 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Go.tar.gz -rw-r--r-- slave1/slave1 6674533 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Gsql.tar.gz -rw-r--r-- slave1/slave1 4987782 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Jdbc.tar.gz -rw-r--r-- slave1/slave1 5640650 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Libpq.tar.gz -rw-r--r-- slave1/slave1 9387605 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Odbc.tar.gz -rw-r--r-- slave1/slave1 4013094 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Python.tar.gz -rwxr-xr-x slave1/slave1 587143501 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Symbol.tar.gz -rw-r--r-- slave1/slave1 11968266 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Xbsa.tar.gz -rw-r--r-- slave1/slave1 4008239 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Windows_X64_Odbc.tar.gz -rw-r--r-- slave1/slave1 3880177 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Windows_X86_Odbc.tar.gz
GaussDB-Kernel_505.1.RC1.SPC0100.B006_Om_X86_Centralized.tar.gz[root@gauss1 server]# tar -ztvf GaussDB-Kernel_505.1.RC1.SPC0100.B006_Om_X86_Centralized.tar.gz -rw-r--r-- slave1/slave1 10313903 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Agent.tar.gz -rw-r--r-- slave1/slave1 22612632 2024-03-24 16:42 GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Om.tar.gz
hostnamectl set-hostname gauss1 hostnamectl set-hostname gauss2 hostnamectl set-hostname gauss3
cat >> /etc/hosts << 'EOF' 192.168.182.138 gauss1 192.168.182.139 gauss2 192.168.182.140 gauss3 EOF
sed -i 's/^.*swap.*$/#&/' /etc/fstab
yum 源将安装麒麟V10操作系统的ISO镜像上传到虚拟机,解压并挂载,然后配置本地源。
[root@gaussdb1 ~]# cat /etc/yum.repos.d/kylin_x86_64.repo ###Kylin Linux Advanced Server 10 - os repo### [local] name = localrepo baseurl = file:///yum_repo gpgcheck = 0 enabled = 1
yum源要求能连公网,
NAT 模式虚拟机还需在
/etc/resolv.conf 配置网关。
cat >> /etc/resolv.conf << 'EOF' nameserver 192.168.182.2 EOF cat >> /etc/yum.repos.d/kylin.repo << 'EOF' [ks10-adv-os] name = Kylin Linux Advanced Server 10 - Os baseurl = https://update.cs2c.com.cn/NS/V10/V10SP3/os/adv/lic/base/$basearch/ gpgcheck = 1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin enabled = 1 [ks10-adv-updates] name = Kylin Linux Advanced Server 10 - Updates baseurl = https://update.cs2c.com.cn/NS/V10/V10SP3/os/adv/lic/updates/$basearch/ gpgcheck = 1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin enabled = 1 [ks10-adv-addons] name = Kylin Linux Advanced Server 10 - Addons baseurl = https://update.cs2c.com.cn/NS/V10/V10SP3/os/adv/lic/addons/$basearch/ gpgcheck = 1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin enabled = 0 EOF yum clean all yum makecache
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
groupadd dbgrp useradd -g dbgrp omm echo "Huawei_1234" | passwd --stdin omm
rm -rf /data/gaussdb
mkdir -p /data/gaussdb/{core,log,tmp,tools}
mkdir -p /data/gaussdb/tools/om
mkdir -p /data/gaussdb/log/{data,temp,agent}
mkdir -p /data/gaussdb/data/{cm,etcd,gtm,cn}
chown -R omm:dbgrp /data/gaussdb
chmod -R 755 /data/gaussdb
(1)会生成一堆压缩包
[root@gauss1 gaussdb_server]# tar -zxvf GaussDB-Kernel_505.1.RC1.SPC0100.B006_Server_X86_Centralized.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_CM_Symbol.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_DBMind.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Gds.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Go.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Gsql.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Jdbc.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Libpq.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Odbc.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Python.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Symbol.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Xbsa.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Windows_X64_Odbc.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Windows_X86_Odbc.tar.gz
(2)继续解压其中的
GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit.tar.gz 包,会生成安装所需要的
GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit.bin 文件
[root@gauss1 gaussdb_server]# tar -zxvf GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit.tar.gz ./GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit.bin ./GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit.sha256 ./components/ ./components/cm/ ./components/cm/bin/ ./components/cm/bin/alarmConfig.conf ./components/cm/bin/alarmItem.conf ./components/cm/bin/cm_agent ...
(1)生成两个压缩包;
[root@gauss1 gaussdb_server]# tar -zxvf GaussDB-Kernel_505.1.RC1.SPC0100.B006_Om_X86_Centralized.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Agent.tar.gz GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Om.tar.gz
(2)继续解压其中的
GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Om.tar.gz 包,会生成
script、
kernel、
lib 等文件夹,
kernel/bin/script/gspylib/etc/conf/ 存放了集群配置文件模板。
[root@gauss1 gaussdb_server]# tar -zxvf GaussDB-Kernel_505.1.RC1.SPC0100_Kylin_64bit_Om.tar.gz drwx------ 2 20001 20001 89 Mar 24 2024 bin -rwx------ 1 20001 20001 7024 Mar 24 2024 cluster_default_agent.xml drwx------ 2 20001 20001 43 Mar 24 2024 configtemplate drwx------ 4 20001 20001 30 Mar 24 2024 kernel drwx------ 12 20001 20001 215 Mar 24 2024 lib -rwx------ 1 20001 20001 57 Mar 24 2024 om_version drwx------ 11 20001 20001 4096 Mar 24 2024 script [root@gauss1 gaussdb_server]# ll kernel/bin/script/gspylib/etc/conf/ total 320 drwx------ 2 20001 20001 4096 Mar 24 2024 centralized -rwx------ 1 20001 20001 1931 Mar 24 2024 check_list.conf -rwx------ 1 20001 20001 4955 Mar 24 2024 cluster_config_template_masterStandby.xml -rwx------ 1 20001 20001 4955 Mar 24 2024 cluster_config_template_mutilAZ.xml -rwx------ 1 20001 20001 4955 Mar 24 2024 cluster_config_template_single.xml
在 script 目录 编辑配置文件 cluster_config.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?> <ROOT> <!-- openGauss整体信息 --> <CLUSTER> <!-- 数据库名称 --> <PARAM name="clusterName" value="MyGauss" /> <!-- 数据库节点名称(hostname) --> <PARAM name="nodeNames" value="gauss1,gauss2,gauss3" /> <!-- 节点IP,与nodeNames一一对应 --> <PARAM name="backIp1s" value="192.168.182.138,192.168.182.139,192.168.182.140"/> <!-- 数据库安装目录--> <PARAM name="gaussdbAppPath" value="/data/gaussdb/core/app" /> <!-- 日志目录--> <PARAM name="gaussdbLogPath" value="/data/gaussdb/log" /> <!-- 临时文件目录--> <PARAM name="tmpMppdbPath" value="/data/gaussdb/tmp"/> <!--数据库工具目录--> <PARAM name="gaussdbToolPath" value="/data/gaussdb/tools/om" /> <!--数据库core文件目录--> <PARAM name="corePath" value="/data/gaussdb/corefile"/> <!-- openGauss类型,此处示例为单机类型,"single-inst"表示单机一主多备部署形态--> <PARAM name="clusterType" value="single-inst"/> </CLUSTER> <!-- 每台服务器上的节点部署信息 --> <DEVICELIST> <!-- gauss1上的节点部署信息 --> <DEVICE sn="1000001"> <!-- gauss1的hostname --> <PARAM name="name" value="gauss1"/> <!-- gauss1所在的AZ及AZ优先级 --> <PARAM name="azName" value="AZ1"/> <PARAM name="azPriority" value="1"/> <!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP --> <PARAM name="backIp1" value="192.168.182.138"/> <PARAM name="sshIp1" value="192.168.182.138"/> <!--CM--> <!--CM数据目录--> <PARAM name="cmDir" value="/data/gaussdb/data/cm" /> <PARAM name="cmsNum" value="1" /> <!--CM监听端口--> <PARAM name="cmServerPortBase" value="5000" /> <PARAM name="cmServerlevel" value="1" /> <!--CM所有实例所在节点名及监听ip--> <PARAM name="cmServerListenIp1" value="192.168.182.138,192.168.182.139,192.168.182.140" /> <PARAM name="cmServerRelation" value="gauss1,gauss2,gauss3" /> <!--dbnode--> <PARAM name="dataNum" value="1"/> <!--DBnode端口号--> <PARAM name="dataPortBase" value="26000"/> <!--DBnode主节点上数据目录,及备机数据目录--> <PARAM name="dataNode1" value="/data/gaussdb/data/dn/db1,gauss2,/data/gaussdb/data/dn/db1,gauss3,/data/gaussdb/data/dn/db1"/> <!--DBnode节点上设定同步模式的节点数--> <PARAM name="dataNode1_syncNum" value="0"/> </DEVICE> <!-- gauss2上的节点部署信息,其中"name"的值配置为主机名称(hostname) --> <DEVICE sn="1000002"> <PARAM name="name" value="gauss2"/> <PARAM name="azName" value="AZ1"/> <PARAM name="azPriority" value="1"/> <PARAM name="backIp1" value="192.168.182.139"/> <PARAM name="sshIp1" value="192.168.182.139"/> <PARAM name="cmDir" value="/data/gaussdb/data/cm" /> </DEVICE> <!-- gauss3上的节点部署信息,其中"name"的值配置为主机名称(hostname) --> <DEVICE sn="1000003"> <PARAM name="name" value="gauss3"/> <PARAM name="azName" value="AZ1"/> <PARAM name="azPriority" value="1"/> <PARAM name="backIp1" value="192.168.182.140"/> <PARAM name="sshIp1" value="192.168.182.140"/> <PARAM name="cmDir" value="/data/gaussdb/data/cm" /> </DEVICE> </DEVICELIST> </ROOT>
可以看到在第一个节点的配置里DN 指定了三个节点的 DN 路径,后面两个节点只提供了
ip 和
ClusterManager 的信息。
以
root 用户执行
gs_preinstall 命令进行预安装,期间会输入
root 和
omm 用户的密码,会自动配置内核参数等。
[root@gauss1 script]# ./gs_preinstall -X cluster_config.xml -U omm -G dbgrp --alarm-type=1 Parsing the configuration file. Successfully parsed the configuration file. Successfully delete task result file Installing the tools on the local node. Successfully installed the tools on the local node. Are you sure you want to create trust for root (yes/no)?yes Please enter password for root Password: Successfully created SSH trust for the root permission user. Setting HOST_IP env Successfully set HOST_IP env. set hotpatch env. clear hotpatch env. Distributing package. Successfully distribute local lib to remote pylib. Begin to distribute package to tool path. Successfully distribute package to tool path. Begin to distribute package to package path. Successfully distribute package to package path. Successfully distributed package. Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes Preparing SSH service. Successfully prepared SSH service. Installing the tools in the cluster. Successfully installed the tools in the cluster. Checking hostname mapping. Successfully checked hostname mapping. Creating SSH trust for [omm] user. Please enter password for current user[omm] Password: Successfully created SSH trust for [omm] user. Checking OS version. Successfully checked OS version. Creating cluster's path. Successfully created cluster's path. Set and check OS parameter. Setting OS parameters. Successfully set OS parameters. Warning: Installation environment contains some warning messages. Please get more details by "/root/gaussdb_server/script/gs_checkos -i A -h gauss1,gauss2,gauss3". Set and check OS parameter completed. Preparing CRON service. Successfully prepared CRON service. Setting user environmental variables. Successfully set user environmental variables. Configuring alarms on the cluster nodes. Successfully configured alarms on the cluster nodes. Setting the dynamic link library. Successfully set the dynamic link library. Setting Core file Successfully set core path. Setting pssh path Successfully set pssh path. Setting Cgroup. Successfully set Cgroup. Set ARM Optimization. Successfully set ARM Optimization. Setting finish flag. Scene: non-huaweiyun Successfully set finish flag. Preinstallation succeeded.
这时候可以看到
xml 文件里
gaussdbAppPath 指定的
/data/gaussdb/core/app目录里面已经有数据库软件了,注意
app 目录不能自己创建。
[root@gauss1 core]# pwd /data/gaussdb/core [root@gauss1 core]# ll total 0 lrwxrwxrwx 1 omm dbgrp 12 Aug 17 12:20 app -> app_b579cd12 drwx------ 8 omm dbgrp 83 Aug 17 12:20 app_b579cd12 [root@gauss1 core]# cd app [root@gauss1 app]# ll total 16 drwx------ 3 omm dbgrp 4096 Aug 17 12:27 bin drwx------ 4 omm dbgrp 67 Aug 17 12:20 etc drwx------ 5 omm dbgrp 46 Mar 24 2024 include drwx------ 5 omm dbgrp 8192 Mar 24 2024 lib drwx------ 6 omm dbgrp 64 Mar 24 2024 share drwx------ 2 omm dbgrp 20 Aug 17 12:20 utilslib
将刚刚执行预安装的文件夹修改为
omm 的属主,因为正式安装要用
omm 用户。
chown -R omm:dbgrp /gaussdb_server/ chmod -R 755 /gaussdb_server/
使用
omm 用户正式安装,发现
PGHOME 是
/data/gaussdb/tools/om ,预安装会将压缩包拷贝到了
xml 文件
gaussdbToolPath 里指定的目录,也就是
/data/gaussdb/tools/om。
[omm@gauss1 ~]$ gs_install -X /data/gaussdb/tools/om/script/cluster_config.xml Parsing the configuration file. Check preinstall on every node. Successfully checked preinstall on every node. Creating the backup directory. Creating a Parameter File for Cascading Standby Nodes Successfully created the backup directory. Installing the cluster. Checking the installation environment on all nodes. begin install Cluster.. Installing applications on all nodes. Successfully installed APP. begin init Instance.. Cluster installation is completed. Configuring. Deleting instances from all nodes. Successfully deleted instances from all nodes. Checking node configuration on all nodes. Initializing instances on all nodes. Start to init instance. Updating instance configuration on all nodes. Check consistence of memCheck and coresCheck on db nodes. Successful check consistence of memCheck and coresCheck on all nodes. Configuring pg_hba on all nodes. Configuration is completed. Starting cluster. ====================================================================== Successfully started primary instance. Wait for standby instance. ====================================================================== . Successfully started cluster. ====================================================================== cluster_state : Normal redistributing : No node_count : 3 Coordinator State normal : 0 abnormal : 0 GTM State primary : 0 standby : 0 abnormal : 0 down : 0 Datanode State primary : 1 standby : 2 secondary : 0 building : 0 abnormal : 0 down : 0 Successfully installed application.
安装成功,下面检查一下数据库状态。
分别显示了
CM、
DN 的详细信息,并没有
ETCD。
[omm@gauss1 ~]$ gs_om -t status --detail [ CMServer State ] node node_ip instance state ---------------------------------------------------------------------- 1 gauss1 192.168.182.138 1 /data/gaussdb/data/cm/cm_server Primary 2 gauss2 192.168.182.139 2 /data/gaussdb/data/cm/cm_server Standby 3 gauss3 192.168.182.140 3 /data/gaussdb/data/cm/cm_server Standby [ Cluster State ] cluster_state : Normal redistributing : No balanced : Yes current_az : AZ_ALL [ Datanode State ] node node_ip instance state | node node_ip instance state | node node_ip instance state ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 1 gauss1 192.168.182.138 6001 /data/gaussdb/data/dn/db1 P Primary Normal | 2 gauss2 192.168.182.139 6002 /data/gaussdb/data/dn/db1 S Standby Normal | 3 gauss3 192.168.182.140 6003 /data/gaussdb/data/dn/db1 S Standby Normal
[omm@gauss1 ~]$ cm_ctl query -Cv [ CMServer State ] node instance state -------------------------- 1 gauss1 1 Primary 2 gauss2 2 Standby 3 gauss3 3 Standby [ Cluster State ] cluster_state : Normal redistributing : No balanced : Yes current_az : AZ_ALL [ Datanode State ] node instance state | node instance state | node instance state ------------------------------------------------------------------------------------------------------------------ 1 gauss1 6001 P Primary Normal | 2 gauss2 6002 S Standby Normal | 3 gauss3 6003 S Standby Normal # 显示详细信息 [omm@gauss1 ~]$ cm_ctl query -Cvipd [ CMServer State ] node node_ip instance state ---------------------------------------------------------------------- 1 gauss1 192.168.182.138 1 /data/gaussdb/data/cm/cm_server Primary 2 gauss2 192.168.182.139 2 /data/gaussdb/data/cm/cm_server Standby 3 gauss3 192.168.182.140 3 /data/gaussdb/data/cm/cm_server Standby [ Cluster State ] cluster_state : Normal redistributing : No balanced : Yes current_az : AZ_ALL [ Datanode State ] node node_ip instance state | node node_ip instance state | node node_ip instance state --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 gauss1 192.168.182.138 6001 26000 /data/gaussdb/data/dn/db1 P Primary Normal | 2 gauss2 192.168.182.139 6002 26000 /data/gaussdb/data/dn/db1 S Standby Normal | 3 gauss3 192.168.182.140 6003 26000 /data/gaussdb/data/dn/db1 S Standby Normal
第一次连接会要求修改
omm 用户的密码,跟
PostgreSQL 和
Oracle 一样,所属用户本地免密登录。
[omm@gauss1 ~]$ gsql -p 26000 -d postgres gsql ((GaussDB Kernel 505.1.RC1.SPC0100 build b579cd12) compiled at 2024-03-24 16:42:44 commit 8436 last mr 16721 release) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. gaussdb=# \l ERROR: Please use "ALTER ROLE "omm" PASSWORD 'password';" to set the password of the user before other operations! gaussdb=# alter user omm password 'Huawei_1234'; ALTER ROLE gaussdb=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+-------+-----------+---------+-------+------------------- postgres | omm | SQL_ASCII | C | C | template0 | omm | SQL_ASCII | C | C | =c/omm + | | | | | omm=CTc/omm template1 | omm | SQL_ASCII | C | C | =c/omm + | | | | | omm=CTc/omm templatem | omm | SQL_ASCII | C | C | =c/omm + | | | | | omm=CTc/omm (4 rows) -- 建表插入数据 gaussdb=# create table tb1 (id int, name text); CREATE TABLE gaussdb=# insert into tb1 (id,name) values (10,'James'); INSERT 0 1 -- 其他两个节点可以查询到数据,插入数据则报错 [omm@gauss2 ~]$ gsql -d postgres -p 26000 gsql ((GaussDB Kernel 505.1.RC1.SPC0100 build b579cd12) compiled at 2024-03-24 16:42:44 commit 8436 last mr 16721 release) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. gaussdb=# \d+ tb1 Table "public.tb1" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+----------+--------------+------------- id | integer | | plain | | name | text | | extended | | Has OIDs: no Options: orientation=row, compression=no, storage_type=USTORE, segment=off, toast.storage_type=USTORE, toast.toast_storage_type=enhanced_toast gaussdb=# select * from tb1; id | name ----+------- 10 | James (1 row) gaussdb=# insert into tb1 values(20,'Peter'); ERROR: cannot execute INSERT in a read-only transaction -- 节点3 亦如此 [omm@gauss3 ~]$ gsql -d postgres -p 26000 gsql ((GaussDB Kernel 505.1.RC1.SPC0100 build b579cd12) compiled at 2024-03-24 16:42:44 commit 8436 last mr 16721 release) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. gaussdb=# \d+ tb1 Table "public.tb1" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+----------+--------------+------------- id | integer | | plain | | name | text | | extended | | Has OIDs: no Options: orientation=row, compression=no, storage_type=USTORE, segment=off, toast.storage_type=USTORE, toast.toast_storage_type=enhanced_toast gaussdb=# select * from tb1; id | name ----+------- 10 | James (1 row) gaussdb=# insert into tb1 values(30,'Susie'); ERROR: cannot execute INSERT in a read-only transaction gaussdb=#
最后,我们看一下哪里配置了
DCC。操作系统层面没有
ETCD 进程。
[omm@gauss1 ~]$ cat /data/gaussdb/data/cm/cm_server/cm_server.conf | grep ddb_type ddb_type = 1 # 0 etcd 1 dcc [root@gauss1 gaussdb_server]# ps -ef |grep omm omm 85336 1 0 11:51 ? 00:00:00 ssh-agent -a /home/omm/gaussdb_tmp/gauss_socket_tmp omm 193026 1 0 12:20 ? 00:00:00 /usr/lib/systemd/systemd --user omm 193030 193026 0 12:20 ? 00:00:00 (sd-pam) omm 204281 1 0 12:21 ? 00:00:02 /data/gaussdb/core/app/bin/om_monitor -L /data/gaussdb/log/omm/cm/om_monitor omm 237883 204281 0 12:25 ? 00:01:12 /data/gaussdb/core/app/bin/cm_agent omm 237967 1 5 12:25 ? 00:08:52 /data/gaussdb/core/app/bin/cm_server omm 237991 1 5 12:25 ? 00:08:05 /data/gaussdb/core/app/bin/gaussdb -D /data/gaussdb/data/dn/db1 -M pending omm 237998 1 0 12:25 ? 00:00:01 gaussdb fenced UDF master process
om_monitor 进程是 GaussDB 后台自动配置的定时任务,每隔一分钟拉起。
[root@gauss3 cm]# crontab -l -u omm PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/bin */1 * * * * source ~/.bashrc;python3 /data/gaussdb/tools/om/script/local/CheckSshAgent.py >>/dev/null 2>&1 & */1 * * * * source /etc/profile;(if [ -f ~/.profile ];then source ~/.profile;fi);source ~/.bashrc;nohup /data/gaussdb/core/app/bin/om_monitor -L /data/gaussdb/log/omm/cm/om_monitor >>/dev/null 2>&1 &
总结:本文介绍了
GaussDB 505.1 版本的三节点集中式数据库集群的安装,
GaussDB 能查的资料不是特别多,网络上主要是
openGauss 或者是
GaussDB T 或者
GaussDB 100 较老版本的安装,不过总体来说步骤相差不大,集中式部署起来较为简单。
这里是《实战派K8S&DB》,更多干货敬请关注公众号。如果本文对你有所帮助,欢迎点赞、推荐和转发,也欢迎关注后续文章,一起考证、一起学习 GaussDB 分布式数据库。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31444449/viewspace-3181892/ ,如需转载,请注明出处,否则将追究法律责任。