写点什么

Gbase8a 学习笔记 - 学习环境安装

作者:南渡北归
  • 2021 年 12 月 09 日
  • 本文字数:5001 字

    阅读完需:约 16 分钟

这个版本是需要 license 的,需要和南大通用公司相关部门申请,这里因为是报的官方培训班,所以..嗯,这个 Gbase8a,也有免费版本的.建议到官网上查一下对应的版本和安装步骤.


1. 虚拟机规划


系统: CentOS Linux release 7.9.2009 (Core)


需要提前做的准备:


  • 打通各节点\开启 SSH 服务\关闭防火墙\关闭 selinux 服务.

  • 创建 DBA 用户(gbase \ gbase2021)


systemctl status firewalld.service # 查看防火墙状态.(active表示开启中)
systemctl stop firewalld # 关闭防火墙systemctl disable firewalld.service # 禁止开机自启
sestatus # 查看selinux服务是否启动vim /etc/selinux/config # 关闭selinux
SELINUX=disabled
# 添加用户useradd gbasepasswd gbase2021
复制代码

2. 安装步骤

安装其实并不复杂,简单的来说,可以分为以下几步:

  1. 解压安装文件,拷贝环境配置文件到所有节点.执行安装程序.

  2. 导出指纹信息,联系客服申请密钥.然后注册.

  3. 启动集群服务.设置分片信息

  4. 初始化数据.

2.1 分发安装文件,执行安装程序

# 1.上传安装压缩包到主节点的/opt目录.并解压tar xfj GBase8a_MPP_Cluster-License-9.5.2.39-redhat7.3-x86_64.tar.bz2
cd gbinstall # 进入目录
# 2. 拷贝SetSysEnv.py到其他节点的opt目录.并执行脚本(在每个节点上都执行)python SetSysEnv.py --dbaUser=gbase --installPrefix=/opt/gbase --cgroup
# 3.修改主节点的安装配置文件.# 切换到gbase用户su - gbasecd /opt/gcinstall/vi demo.options---------------------------------------------------------installPrefix= /opt/gbasecoordinateHost = 192.168.176.120,192.168.176.121,192.168.176.122coordinateHostNodeID = 120,121,122dataHost = 192.168.176.120,192.168.176.121,192.168.176.122#existCoordinateHost =#existDataHost =dbaUser = gbasedbaGroup = gbasedbaPwd = '******' # dba用户rootPwd = '******' # root密码#rootPwdFile = rootPwd.json---------------------------------------------------------
# 执行gcinstall.py,安装程序.
python gcinstall.py --silent=demo.option
# 如果没有配置错误,虚拟机也正常的话.应该一会儿就可以安装完成.# cat dependRpms 可以查看程序依赖的包.
复制代码

2.2 激活数据库

#导出指纹./gethostsid -n 192.168.176.120,192.168.176.121,192.168.176.122 -u root -p 密码 -f /tmp/finger.txt# 导入激活文件 (额,这里感觉不是很智能,激活文件只能放/tmp目录???./License -n 192.168.176.120,192.168.176.121,192.168.176.122 -f /tmp/20211209-02.lic -u gbase -p gbase2021# 结果======================================================================Successful node nums:  3======================================================================# 检查激活情况./chkLicense -n 192.168.176.120,192.168.176.121,192.168.176.122  -u gbase -p gbase2021
======================================================================192.168.176.122is_exist:yesversion:trialexpire_time:20220309is_valid:yes======================================================================192.168.176.121is_exist:yesversion:trialexpire_time:20220309is_valid:yes======================================================================192.168.176.120is_exist:yesversion:trialexpire_time:20220309is_valid:yes
复制代码

2.3 启动数据库服务,配置分片信息

# 1. 在所有节点上执行启动命令$gcluster_services all start
# 2. 检查集群状态$gcadmin
CLUSTER STATE: ACTIVE
==================================================================| GBASE COORDINATOR CLUSTER INFORMATION |==================================================================| NodeName | IpAddress | gcware | gcluster | DataState |------------------------------------------------------------------| coordinator1 | 192.168.176.120 | OPEN | OPEN | 0 |------------------------------------------------------------------| coordinator2 | 192.168.176.121 | OPEN | OPEN | 0 |------------------------------------------------------------------| coordinator3 | 192.168.176.122 | OPEN | OPEN | 0 |------------------------------------------------------------------================================================================| GBASE CLUSTER FREE DATA NODE INFORMATION |================================================================| NodeName | IpAddress | gnode | syncserver | DataState |----------------------------------------------------------------| FreeNode1 | 192.168.176.120 | OPEN | OPEN | 0 |----------------------------------------------------------------| FreeNode2 | 192.168.176.121 | OPEN | OPEN | 0 |----------------------------------------------------------------| FreeNode3 | 192.168.176.122 | OPEN | OPEN | 0 |----------------------------------------------------------------
0 virtual cluster3 coordinator node3 free data node

# 设置分片信息# 回到 /opt/gcinstall 目录,执行gcadmin distribution gcChangeInfo.xml p 2 d 1 pattern 1

# 查看生成的 gcChangeInfo.xml [gbase@localhost gcinstall]$ cat gcChangeInfo.xml <?xml version="1.0" encoding="utf-8"?><servers> <rack> <node ip="192.168.176.120"/> <node ip="192.168.176.121"/> <node ip="192.168.176.122"/> </rack></servers>
# 查看发布信息[gbase@localhost gcinstall]$ gcadminCLUSTER STATE: ACTIVEVIRTUAL CLUSTER MODE: NORMAL
==================================================================| GBASE COORDINATOR CLUSTER INFORMATION |==================================================================| NodeName | IpAddress | gcware | gcluster | DataState |------------------------------------------------------------------| coordinator1 | 192.168.176.120 | OPEN | OPEN | 0 |------------------------------------------------------------------| coordinator2 | 192.168.176.121 | OPEN | OPEN | 0 |------------------------------------------------------------------| coordinator3 | 192.168.176.122 | OPEN | OPEN | 0 |------------------------------------------------------------------=========================================================================================================| GBASE DATA CLUSTER INFORMATION |=========================================================================================================| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |---------------------------------------------------------------------------------------------------------| node1 | 192.168.176.120 | 1 | OPEN | OPEN | 0 |---------------------------------------------------------------------------------------------------------| node2 | 192.168.176.121 | 1 | OPEN | OPEN | 0 |---------------------------------------------------------------------------------------------------------| node3 | 192.168.176.122 | 1 | OPEN | OPEN | 0 |---------------------------------------------------------------------------------------------------------
# 或者执行这个命令查看: gcadmin showdistribution node[gbase@localhost gcinstall]$ gcadmin showdistribution nodeDistribution ID: 1 | State: new | Total segment num: 6
=============================================================================================================================| nodes | 192.168.176.120 | 192.168.176.121 | 192.168.176.122 |-----------------------------------------------------------------------------------------------------------------------------| primary | 1 | 2 | 3 || segments | 4 | 5 | 6 |-----------------------------------------------------------------------------------------------------------------------------|duplicate | 3 | 1 | 2 ||segments 1| 5 | 6 | 4 |=============================================================================================================================
复制代码

2.4 数据库初始化


# 在管理节点执行命令(默认root密码为空): gccli -u root -p[gbase@localhost gcinstall]$ gccli -u root -pEnter password: 
GBase client 9.5.2.39.126761. Copyright (c) 2004-2021, GBase. All Rights Reserved.# 再执行下这个命令.gbase> initnodedatamap;Query OK, 0 rows affected (Elapsed: 00:00:00.85)
# 测试一下,常用操作
gbase> create database mydb;Query OK, 1 row affected (Elapsed: 00:00:00.04)
gbase> show databases;+--------------------+| Database |+--------------------+| information_schema || performance_schema || gbase || gctmpdb || gclusterdb || mydb |+--------------------+6 rows in set (Elapsed: 00:00:00.00)gbase> use mydb;Query OK, 0 rows affected (Elapsed: 00:00:00.01)
gbase> create table u_test (id int ,name varchar(100));Query OK, 0 rows affected (Elapsed: 00:00:00.17)
gbase> show tables;+----------------+| Tables_in_mydb |+----------------+| u_test |+----------------+1 row in set (Elapsed: 00:00:00.01)
复制代码

3.集群卸载

# 停止节点上的服务(每个节点都执行)gcluster_services all stop 
# 执行卸载命令./unInstall.py --silent=demo.options
复制代码

4.Note

零碎的点:


  1. 安装文件不要删除...后面的升级\备份,可能还要用相关的一些脚本.

  2. 注意安装的时候用 root,之后主要用 gbase 用户.

  3. 安装环境其实挺折腾的,其实可以直接用 docker 部署下单机版的学习.不过学习过程中,大概了解下怎么安装也是应该的.

  4. 关于分片的设置.

在安装的时候,涉及到一个设置集群信息,生成distribution(coordinator节点的过程),命令如下:
gcadmin distribution <gcChangeInfo.xml> <p number> [d number] [pattern 1|2]
命令说明: * gcChangeInfo.xml: 描述集群类节点和rack(机柜)对应关系的文件 * p: 每个数据节点存放主分片的数量.在pattern 1 模式下,p的取值范围为 1<=p<rack内节点数 * d: 每个主分片的备份输入.取值为0,1,2.默认为1 * pattern: 描述分片备份规则的模板,1为rack高可用,2为节点高可用,默认为1.

复制代码


用户头像

南渡北归

关注

还未添加个人签名 2019.09.02 加入

Hello World?

评论

发布
暂无评论
Gbase8a学习笔记-学习环境安装