CA02.GBase 8c V5 分布式集群版安装示例

发布时间:2026/9/15 10:35:20
CA02.GBase 8c V5 分布式集群版安装示例 GBase 8c V5 分布式集群版安装示例一、前言二、环境准备三、集群安装四、数据库启停五、连接和 SQL 测试六、卸载七、常见问题与解决一、前言GBase 8c 是GBASE公司天津南大通用数据技术股份有限公司自主研发的一款多模多态的企业级分布式数据库支持行存、列存、内存等多种存储模式支持单机、主备式、分布式等多种部署形态。GBase 8c 具备高性能、高可用、弹性伸缩、高安全性等特性可以部署在物理机、虚拟机、容器、私有云和公有云为关键行业核心系统、互联网业务系统和政企业务系统提供安全、稳定、可靠的数据存储和管理服务。本文讲解集群版安装部署步骤、卸载、连接测试。属于入门级别的实操课程。二、环境准备0、标识符约定命令前的#表示以 root 账户执行命令前的$表示以 DBA 账户执行。1、节点软硬件配置硬件配置CPUIntel® Xeon® CPU E5-2699 v3 2.30GHzMemory8GDiskSSD 50G操作系统CentOS Linux release 7.9.2009 (Core)☆针对内存 4G 的节点需要增加 8G SWAP 才能安装成功。具体步骤① 创建 8G 的 Swap 文件#dd if/dev/zero of/etc/swapfile bs1024 count8192000② 制作为 Swap 文件#mkswap /etc/swapfile③ 令 Swap 文件生效#swapon /etc/swapfile④ 查看当前SWAP#swapon -s文件名 类型 大小 已用 权限 /dev/dm-1 partition104857259840-2/etc/swapfilefile81919963148-3⑤ 自动挂载编辑/etc/fstab将以下行追加到文件末尾/etc/swapfile swap swap defaults 0 0#vi /etc/fstab/dev/vda1 / ext3 noatime,acl,user_xattr 1 1proc /proc proc defaults 0 0sysfs /sys sysfs noauto 0 0debugfs /sys/kernel/debug debugfs noauto 0 0devpts /dev/pts devpts mode0620,gid5 0 0/etc/swapfile swap swap defaults 0 0⑥ 查看创建好的 SWAP已经增长了 8G#free -mtotal usedfreeshared buff/cache available Mem:3770166011717401992138Swap:90236189622、集群服务配置三个节点IP角色10.168.10.70gha_server高可用服务、dcs分布式配置存储、gtm全局事务管理、coordinator协调器10.168.10.71datanode1数据节点、dcs分布式配置存储10.168.10.72datanode2数据节点、dcs分布式配置存储3、确保集群每个节点的防火墙是关闭的(1) 检查每个节点的防火墙状态#systemctl status firewalld.service如果系统提示以下信息说明防火墙已被禁用● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded(/usr/lib/systemd/system/firewalld.service;disabled;vendor preset: enabled)Active: inactive(dead)Docs: man:firewalld(1)(2) 如果防火墙没有关闭则执行#systemctl stop firewalld.service#systemctl disable firewalld.service以上两条命令关闭防火墙并禁止防火墙开机自启动。4、确保每个节点的 SELINUX 是关闭的(1) 检查每个节点的 SELINUX 状态#sestatus如果系统提示以下信息说明 selinux 已被禁用SELinux status: disabled(2) 如果 SELINUX 没有关闭需要编辑当前节点的 selinux 配置文件#vi /etc/selinux/config# This file controls the state of SELinux on the system.# SELINUX can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUXenforcing# SELINUXTYPE can take one of three values:# targeted - Targeted processes are protected,# minimum - Modification of targeted policy. Only selected processes are protected.# mls - Multi Level Security protection.SELINUXTYPEtargeted将 SELINUX 关键字的值修改为disabled存盘退出执行#shutdown -r重启操作系统。5、规范三个节点的主机名[10.168.10.70]#hostnamectl set-hostname gbase8c_70[10.168.10.71]#hostnamectl set-hostname gbase8c_71[10.168.10.72]#hostnamectl set-hostname gbase8c_726、配置三个节点的 IP 主机名映射编辑三个节点的 hosts 文件#vi /etc/hosts将以下三行信息追加到 hosts 文件中10.168.10.70 gbase8c_7010.168.10.71 gbase8c_7110.168.10.72 gbase8c_72三、集群安装1、每个节点都要创建 DBA 用户#useradd gbase#passwd gbase2、添加gbase 用户至sudoer 列表三个节点都要执行如下操作——#visudo打开 sudoer 配置文件找到 “root ALL(ALL) ALL” 行在下方增加“gbase ALL(ALL) NOPASSWD:ALL”## Allow root to run any commands anywhererootALL(ALL)ALL gbaseALL(ALL)NOPASSWD:ALL完成 sudoer 配置后数据库安装就可以用 gbase 用户了。本文使用的安装包是不能在 root 账户下安装的。个别操作系统经过以上的设置后gbase 用户执行 sudo 命令时第一次还是有密码提示。需要有以下补救措施(1) root 账户下进入 /etc/sudoers.d/ 目录#cd /etc/sudoers.d/(2) 生成新文件 gbase#vi gbase添加如下信息后存盘即可gbaseALL(ALL)NOPASSWD:ALL3、配置gbase用户ssh互信每个节点都要执行以下命令——(1) 切换到 gbase 用户下#su - gbase(2) 创建秘钥目录和必要的授权$mkdir ~/.ssh$chmod 700 ~/.ssh(3) 生成秘钥文件连续回车即可$ssh-keygen -t rsa(4) 将公钥文件上传至其他节点即可实现免密登录此操作需输入 gbase 的密码所有节点都要执行——$ssh-copy-id gbase10.168.10.70$ssh-copy-id gbase10.168.10.71$ssh-copy-id gbase10.168.10.72$echo StrictHostKeyChecking no ~/.ssh/config; echo UserKnownHostsFile ~/.ssh/known_hosts ~/.ssh/config; chmod 644 ~/.ssh/config(5) 检查是否已实现互信免密在主安装节点10.168.10.70上执行$ssh -E /dev/null -p 22 gbase10.168.10.70 hostname$ssh -E /dev/null -p 22 gbase10.168.10.71 hostname$ssh -E /dev/null -p 22 gbase10.168.10.72 hostname如果不需要输入密码即能显示主机名则表明互信配置成功4、配置系统时间同步(1) 主安装节点10.168.10.70作为 server执行$vi /etc/ntp.conf打开 NTP 服务配置文件修改如下# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.restrict10.168.10.70 nomodify notrap nopeer noquery restrict127.0.0.1 restrict ::1# Hosts on local network are less restricted.#restrict 10.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).#server 0.centos.pool.ntp.org iburst#server 1.centos.pool.ntp.org iburst#server 2.centos.pool.ntp.org iburst#server 3.centos.pool.ntp.org iburstserver127.127.1.0 Fudge127.127.1.0 stratum10ntp.conf 文件存盘退出后执行$sudo service ntpd start # 启动NTP服务$sudo chkconfig ntpd on # 设置 NTP 服务开机自启(2) 修改数据节点一10.168.10.71NTP 配置执行$vi /etc/ntp.conf打开 NTP 服务配置文件修改如下# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.restrict10.168.10.71 nomodify notrap nopeer noquery restrict127.0.0.1 restrict ::1# Hosts on local network are less restricted.#restrict 10.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).#server 0.centos.pool.ntp.org iburst#server 1.centos.pool.ntp.org iburst#server 2.centos.pool.ntp.org iburst#server 3.centos.pool.ntp.org iburstserver10.168.10.70 Fudge10.168.10.70 stratum10ntp.conf 文件存盘退出后执行$sudo service ntpd start # 启动NTP服务$sudo chkconfig ntpd on # 设置 NTP 服务开机自启(3) 修改数据节点二10.168.10.72NTP 配置执行$vi /etc/ntp.conf打开 NTP 服务配置文件修改如下# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.restrict10.168.10.72 nomodify notrap nopeer noquery restrict127.0.0.1 restrict ::1# Hosts on local network are less restricted.#restrict 10.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).#server 0.centos.pool.ntp.org iburst#server 1.centos.pool.ntp.org iburst#server 2.centos.pool.ntp.org iburst#server 3.centos.pool.ntp.org iburstserver10.168.10.70 Fudge10.168.10.70 stratum10ntp.conf 文件存盘退出后执行$sudo service ntpd start # 启动NTP服务$sudo chkconfig ntpd on # 设置 NTP 服务开机自启5、上传安装包[10.168.10.70]$cd /home/gbase[10.168.10.70]$mkdir gbase_package最后使用 SSH 工具上传GBase8cV5_S3.0.0B114_centos7.8_x86_64.tar.gz到主安装节点10.168.10.70 /home/gbase/gbase_package 下。6、解压安装包$cd /home/gbase/gbase_package$sudo tar xvf GBase8cV5_S3.0.0B114_centos7.8_x86_64.tar.gz解压成功新增五个文件GBase8cV5_S3.0.0B114_CentOS_x86_64_om.sha256 GBase8cV5_S3.0.0B114_CentOS_x86_64_om.tar.gz GBase8cV5_S3.0.0B114_CentOS_x86_64_pgpool.tar.gz GBase8cV5_S3.0.0B114_CentOS_x86_64.sha256 GBase8cV5_S3.0.0B114_CentOS_x86_64.tar.bz2再次解压$sudo tar xvf GBase8cV5_S3.0.0B114_CentOS_x86_64_om.tar.gz7、开始安装(1) 编辑集群部署文件 gbase8c.yml[10.168.10.70]$vi /home/gbase/gbase_package/gbase.yml修改如下——gha_server: - gha_server1: host:10.168.10.70 port:20001dcs: - host:10.168.10.70 port:2379- host:10.168.10.71 port:2379- host:10.168.10.72 port:2379gtm: - gtm1: host:10.168.10.70 agent_host:10.168.10.70 role: primary port:6666agent_port:8001work_dir: /home/gbase/data/gtm/gtm1 coordinator: - cn1: host:10.168.10.70 agent_host:10.168.10.70 role: primary port:5432agent_port:8003work_dir: /home/gbase/data/coord/cn1 datanode: - dn1: - dn1_1: host:10.168.10.71 agent_host:10.168.10.71 role: primary port:15432agent_port:8005work_dir: /home/gbase/data/dn1/dn1_1 - dn2: - dn2_1: host:10.168.10.72 agent_host:10.168.10.72 role: primary port:20010agent_port:8007work_dir: /home/gbase/data/dn2/dn2_1 env:# cluster_type allowed values: multiple-nodes, single-inst, default is multiple-nodescluster_type: multiple-nodes pkg_path: /home/gbase/gbase_package# 安装包所在目录prefix: /home/gbase/gbase_db# 运行目录version: V5_S3.0.0B114 user: gbase port:22# constant:# virtual_ip: 100.0.1.254/24(2) 执行安装脚本[10.168.10.70]$cd /home/gbase/gbase_package/script[10.168.10.70]$./gha_ctlinstall -c gbase -p /home/gbase/gbase_packageA.-c参数数据库名称缺省 gbase B.-p参数配置文件路径缺省 /home/gbase。执行时间 3 分钟安装结束后脚本会提示{ ret:0, msg:Success }集群安装成功❈异常处理在没有安装开发组件的操作系统上执行安装脚本可能出现以下现象{ret:-1,msg:Host localhost install or upgrade dependency {libaio: None} failed! Host 172.168.10.227 install or upgrade dependency {libaio: None} failed! Host 172.168.10.108 install or upgrade dependency {libaio: None} failed! }——解决在集群所有节点安装 libaio 组件[10.168.10.70]#yum -y install libaio[10.168.10.71]#yum -y install libaio[10.168.10.72]#yum -y install libaio(3) 节点状态检查在主安装节点上执行[10.168.10.70]$exit[10.168.10.70]#su - gbase以上两个命令是保证环境变量生效[10.168.10.70]$gha_ctlmonitor -l http://10.168.10.70:2379 -H结果如下说明集群安装正常数据服务启动中-------------------------------------------------------|No|name|host|port|state|leader|-------------------------------------------------------|0|gha_server1|10.168.10.70|20001|running|True|------------------------------------------------------- ---------------------------------------------------------------------------|No|name|host|port|work_dir|state|role|---------------------------------------------------------------------------|0|gtm1|10.168.10.70|6666|/home/gbase/data/gtm/gtm1|running|primary|--------------------------------------------------------------------------- ----------------------------------------------------------------------------|No|name|host|port|work_dir|state|role|----------------------------------------------------------------------------|0|cn1|10.168.10.70|5432|/home/gbase/data/coord/cn1|running|primary|---------------------------------------------------------------------------- -------------------------------------------------------------------------------------|No|group|name|host|port|work_dir|state|role|-------------------------------------------------------------------------------------|0|dn1|dn1_1|10.168.10.71|15432|/home/gbase/data/dn1/dn1_1|running|primary||1|dn2|dn2_1|10.168.10.72|20010|/home/gbase/data/dn2/dn2_1|running|primary|------------------------------------------------------------------------------------- ---------------------------------------------------------|No|url|name|state|isLeader|---------------------------------------------------------|0|http://10.168.10.70:2379|node_0|healthy|False||1|http://10.168.10.72:2379|node_1|healthy|True|---------------------------------------------------------四、数据库启停停止数据库服务[10.168.10.70]$/home/gbase/script/gha_ctl stop all-l http://10.168.10.70:2379启动数据库服务[10.168.10.70]$/home/gbase/script/gha_ctl start all-l http://10.168.10.70:2379五、连接和 SQL 测试在主节点10.168.10.70执行$gsql -d postgres -p 5432出现postgres#操作符说明客户端工具 gsql 成功连接 8c 数据库postgres#create database testdb;CREATE DATABASEpostgres#create table student(ID int, Name varchar(10));CREATE TABLEpostgres#insert into student values(1, Mike),(2,John);INSERT 0 2postgres#select * from student;id | name----±-----1 | Mike2 | John(2 rows)六、卸载在主节点10.168.10.70执行以下命令——1、停止所有节点的集群服务$gha_ctl stop all-l http://10.168.10.70:23792、集群程序的卸载$gha_ctl uninstall-l http://10.168.10.70:23793、移除 dcs 集群$cd /home/gbase/script$./gha_ctl destroydcs -l http://10.168.10.70:2379七、常见问题与解决请参考 GBase 8c 安装过程中常见的问题与解决方法

关于本文作者

来自尧图内容编辑团队

尧图内容编辑团队 内容团队

尧图内容编辑团队

本文由尧图网络内容编辑团队执笔。团队由资深项目经理、前端工程师与设计师组成,所有内容均来自亲手交付的真实项目,先讲清问题、再给出可落地的解法。尧图深耕北京网站建设十年,服务过京华建材集团、智造科技等各行业客户,把一线经验沉淀为可复用的行业观察。

  • 十年建站经验,覆盖建材、制造、服务、文创等
  • 项目经理把关选题与事实准确性
  • 工程师与设计师联合撰写专业细节
  • 统一编辑规范,保证文风与排版一致
  • 每月复盘转化数据,迭代选题方向

延伸阅读

相关资讯与近期热门内容

深度阅读推荐

建站决策前值得细读的三篇

网站改版的5个关键决策
2024-08-12

网站改版的5个关键决策

什么时候该改版、改到什么程度、如何避免流量掉光,京华建材集团改版复盘给出答案。

获取专属建站方案

看完文章,把您的行业与预算告诉我们,免费获取一份量身定制的官网建设方案与报价。

立即免费咨询