南大通用GBase 8a多实例版本9.5.3安装实例和运维常用命令

GBase 8a 在9.5.3系列开始支持多实例版本,主要目标是应对充分利用超多处理器和超大内存,比如arm处理器,512G内存。

该版本的限制和变动,请参考 GBase 8a多实例版本9.5.3变动介绍

名词

管理节点

指运行gcware服务的节点,其组成的集群,叫管理集群

调度节点

指运行gclusterd,对外提供连接,对内分析执行计划,调度计算节点工作。其组成的集群叫调度集群。

计算节点

指gbased,提供数据存储和计算服务。其组成的集群叫计算集群。

准备环境

系统环境

操作系统:redhat 7.3
内存:8G
IP: 10.0.2.103 - 105 共3个

[gbase@gbase_rh7_003 gcinstall]$ free -g
              total        used        free      shared  buff/cache   available
Mem:              7           0           6           0           0           5
Swap:             3           0           3

[gbase@gbase_rh7_003 gcinstall]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:8e:d9:28 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.103/24 brd 10.0.2.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet 10.0.2.104/24 brd 10.0.2.255 scope global secondary enp0s3
       valid_lft forever preferred_lft forever
    inet 10.0.2.105/24 brd 10.0.2.255 scope global secondary enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::ab19:72ea:2472:cc28/64 scope link
       valid_lft forever preferred_lft forever

环境配置

V9版本运行期间,不再使用root操作系统用户,所以需要提前创建运行数据库的操作系统用户,dbaUser,以及设置操作系统环境变量,包括参数。

注意:需要在每个数据库节点上都做环境准备,这些是root才能做的。

创建用户这个步骤这里就不写了。本文使用默认的gbase用户,作为dbaUser。 请一定区分,这个是操作系统的gbase用户,不要和数据库连接账号的gbase用户混淆了。

设置操作系统环境,通过如下命令,在root用户下进行。

[root@gbase_rh7_003 gcinstall]# ./SetSysEnv.py --installPrefix=/opt/gbase  --dbaUser=gbase

其中SetSysEnv.py程序,在数据库安装包内,可以提前解压,发到每台服务上,在创建操作系统gbase用户后,运行即可。

其中installPrefix是安装目录,该目录必须存在,且拥有gbase用户的读取和写入权限。可以通过gbase用户,创建一个目录来测试是否正确。

其中dbaUser就是我们前面创建的操作系统用户,我们使用 gbase

依赖包

目前已知需要如下的几个类库需要提前安装

compat-db-headers-4.7.25-28.el7.noarch.rpm
compat-db47-4.7.25-28.el7.x86_64.rpm

[root@gbase_rh7_003 ~]# rpm -qa|grep compat-db
compat-db-headers-4.7.25-28.el7.noarch
compat-db47-4.7.25-28.el7.x86_64
[root@gbase_rh7_003 ~]#

操作系统自带这些类库。

[root@gbase_rh7_003 Packages]# ll compat-db*
-r--r--r--  691 root root 831040 Aug 25  2014 compat-db47-4.7.25-28.el7.i686.rpm
-r--r--r--  692 root root 814144 Aug 25  2014 compat-db47-4.7.25-28.el7.x86_64.rpm
-r--r--r-- 1305 root root  49248 Aug 25  2014 compat-db-headers-4.7.25-28.el7.noarch.rpm
[root@gbase_rh7_003 Packages]# rpm -ivh compat-db-headers-4.7.25-28.el7.noarch.rpm
warning: compat-db-headers-4.7.25-28.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:compat-db-headers-4.7.25-28.el7  ################################# [100%]
[root@gbase_rh7_003 Packages]# rpm -ivh compat-db47-4.7.25-28.el7.x86_64.rpm
warning: compat-db47-4.7.25-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:compat-db47-4.7.25-28.el7        ################################# [100%]
[root@gbase_rh7_003 Packages]#

解压缩

在gbase目录下解压缩,得到gcinstall目录。

[gbase@gbase_rh7_003 ~]$ tar xvf GBase8a_MPP_Cluster-NoLicense-9.5.3.18-redhat7.3-x86_64.tar.bz2
gcinstall/
gcinstall/extra_rpms/
gcinstall/extra_rpms/SUSE11/
gcinstall/extra_rpms/SUSE11/libboost_filesystem1_36_0-1.36.0-12.3.1.x86_64.rpm
gcinstall/extra_rpms/SUSE11/libboost_system1_36_0-1.36.0-12.3.1.x86_64.rpm
gcinstall/gbase_data_timezone.sql
gcinstall/gcexec.py
gcinstall/unInstall_fulltext.py
gcinstall/SetSysEnv.py
gcinstall/CorosyncConf.py
gcinstall/gcwareGroup.json
gcinstall/fulltext.py
gcinstall/license.txt
gcinstall/unInstall.py
gcinstall/UpdateSysTable.json
gcinstall/FileCheck.py
gcinstall/InstallTar.py
gcinstall/extendCfg.xml
gcinstall/rootPwd.json
gcinstall/gcinstall.py
gcinstall/replaceStop.py
gcinstall/chkLicense
gcinstall/Restore.py
gcinstall/SSHThread.py
gcinstall/demo.options
gcinstall/RestoreLocal.py
gcinstall/InstallFuns.py
gcinstall/rmt.py
gcinstall/example.xml
gcinstall/CGConfigChecker.py
gcinstall/pexpect.py
gcinstall/replace.py
gcinstall/gccopy.py
gcinstall/BUILDINFO
gcinstall/dependRpms
gcinstall/bundle_data.tar.bz2
gcinstall/bundle.tar.bz2

[gbase@gbase_rh7_003 ~]$ cd gcinstall/
[gbase@gbase_rh7_003 gcinstall]$ cat BUILDINFO
release_version =  9.5.3.18
os_ventor =  redhat
build_version = release
license = none
install_svn:123901
autobuild_svn:123901
monit_svn: 76343
gcrcman_svn: 123675
corosync_svn: 123912
gcware_svn: 123881
gcluster_svn: 123926
logCollector_svn: 94134
GCMonit_svn: 123555
gnode_svn: 123926
[gbase@gbase_rh7_003 gcinstall]$

编辑配置文件

其中参数与其它V95版本一致。

installPrefix 安装目录,请与环境准备的目录一致。
coordinateHost 管理协调节点IP. 注意1台物理机,只能写一个IP。
dataHost 数据计算节点IP。
gcwareHost 集群管理节点IP,同样1台物理机,只能写1个IP。
dbaUser 操作系统数据库用户名
dbaGroup 操作系统数据库用户组
dbaPwd 操作系统数据库用户密码

[gbase@gbase_rh7_003 gcinstall]$ cat demo.options
installPrefix= /opt/gbase
coordinateHost = 10.0.2.103
coordinateHostNodeID = 103
dataHost = 10.0.2.103,10.0.2.104,10.0.2.105
#existCoordinateHost =
#existDataHost =
#existGcwareHost=
gcwareHost = 10.0.2.103
gcwareHostNodeID = 103
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase1234'
rootPwd = ''
#rootPwdFile = rootPwd.json
#characterSet = utf8
#dbPort = 5258
#sshPort = 22

安装

[gbase@gbase_rh7_003 gcinstall]$ ./gcinstall.py --silent=demo.options
*********************************************************************************
Thank you for choosing GBase product!

。。。。。。。


10.0.2.104              install cluster on host 10.0.2.104 successfully.
10.0.2.105              install cluster on host 10.0.2.105 successfully.
10.0.2.103              install gcware and cluster on host 10.0.2.103 successfully.
Starting all gcluster nodes ...
adding new datanodes to gcware ...
[gbase@gbase_rh7_003 gcinstall]$

查看集群状态

管理集群(gcware)1个节点;
调度集群(coordinator)1个节点;
计算节点3个,当前还没组成集群。

[gbase@gbase_rh7_003 ~]$ gcadmin
CLUSTER STATE:         ACTIVE

====================================
| GBASE GCWARE CLUSTER INFORMATION |
====================================
| NodeName |  IpAddress   | gcware |
------------------------------------
| gcware1  |  10.0.2.103  |  OPEN  |
------------------------------------
====================================================
|      GBASE COORDINATOR CLUSTER INFORMATION       |
====================================================
|   NodeName   | IpAddress  | gcluster | DataState |
----------------------------------------------------
| coordinator1 | 10.0.2.103 |   OPEN   |     0     |
----------------------------------------------------
===========================================================
|        GBASE CLUSTER FREE DATA NODE INFORMATION         |
===========================================================
| NodeName  | IpAddress  | gnode | syncserver | DataState |
-----------------------------------------------------------
| FreeNode1 | 10.0.2.103 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------
| FreeNode2 | 10.0.2.104 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------
| FreeNode3 | 10.0.2.105 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------

0 virtual cluster
1 coordinator node
3 free data node

[gbase@gbase_rh7_003 ~]$

组建计算集群

我们还是使用常规的1个分片,1个副本的策略。如下创建集群并初始化。

[gbase@gbase_rh7_003 gcinstall]$ cat gcChangeInfo.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
    <rack>
        <node ip="10.0.2.103"/>
        <node ip="10.0.2.104"/>
        <node ip="10.0.2.105"/>
    </rack>
</servers>
[gbase@gbase_rh7_003 gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 1
gcadmin generate distribution ...

NOTE: node [10.0.2.103] is coordinator node, it shall be data node too
gcadmin generate distribution successful

[gbase@gbase_rh7_003 gcinstall]$ gccli

GBase client 9.5.3.18.123926. Copyright (c) 2004-2020, GBase.  All Rights Reserved.

gbase> initnodedatamap;
Query OK, 0 rows affected (Elapsed: 00:00:00.53)

gbase> ^CAborted
[gbase@gbase_rh7_003 gcinstall]$

[gbase@gbase_rh7_003 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

====================================
| GBASE GCWARE CLUSTER INFORMATION |
====================================
| NodeName |  IpAddress   | gcware |
------------------------------------
| gcware1  |  10.0.2.103  |  OPEN  |
------------------------------------
====================================================
|      GBASE COORDINATOR CLUSTER INFORMATION       |
====================================================
|   NodeName   | IpAddress  | gcluster | DataState |
----------------------------------------------------
| coordinator1 | 10.0.2.103 |   OPEN   |     0     |
----------------------------------------------------
=========================================================================================================
|                                    GBASE DATA CLUSTER INFORMATION                                     |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |                10.0.2.103                |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------
|  node2   |                10.0.2.104                |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------
|  node3   |                10.0.2.105                |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

[gbase@gbase_rh7_003 gcinstall]$

查看多实例的目录

可以看到安装目录下,是根据IP创建了各自的目录。
其中只有103目录包含了gcluster完整目录,其它非调度节点的gcluster下只有个gcrman用于备份还原的程序。
其中只有103目录包含了gcware完整目录,其它非调度节点的gcware下只有个include和lib64依赖类库和头文件等。

[gbase@gbase_rh7_003 gcinstall]$ ll /opt/gbase/
total 0
drwxrwxr-x 5 gbase gbase 144 Dec  9 10:33 10.0.2.103
drwxrwxr-x 5 gbase gbase  96 Dec  9 10:32 10.0.2.104
drwxrwxr-x 5 gbase gbase  96 Dec  9 10:33 10.0.2.105
[gbase@gbase_rh7_003 gcinstall]$ ll /opt/gbase/10.0.2.103
total 8
srwxrwxrwx  1 gbase gbase    0 Dec  9 10:32 gbase_8a_5050.sock
-rw-rw-r--  1 gbase gbase 1047 Dec  9 10:29 gbase_profile
drwxr-xr-x  8 gbase gbase   92 Dec  9 10:33 gcluster
srwxrwxrwx  1 gbase gbase    0 Dec  9 10:33 gcluster_5258.sock
drwxrwxr-x 14 gbase gbase  169 Dec  9 10:33 gcware
-rw-rw-r--  1 gbase gbase  145 Dec  9 10:29 gcware_profile
drwxrwxr-x  8 gbase gbase   92 Dec  9 10:32 gnode
[gbase@gbase_rh7_003 gcinstall]$ ll /opt/gbase/10.0.2.104
total 4
srwxrwxrwx 1 gbase gbase   0 Dec  9 10:32 gbase_8a_5050.sock
-rw-rw-r-- 1 gbase gbase 680 Dec  9 10:29 gbase_profile
drwxr-xr-x 5 gbase gbase  45 Dec  9 10:32 gcluster
drwxrwxr-x 4 gbase gbase  34 Dec  9 10:32 gcware
drwxrwxr-x 8 gbase gbase  92 Dec  9 10:32 gnode
[gbase@gbase_rh7_003 gcinstall]$ ll /opt/gbase/10.0.2.105
total 4
srwxrwxrwx 1 gbase gbase   0 Dec  9 10:33 gbase_8a_5050.sock
-rw-rw-r-- 1 gbase gbase 680 Dec  9 10:29 gbase_profile
drwxr-xr-x 5 gbase gbase  45 Dec  9 10:32 gcluster
drwxrwxr-x 4 gbase gbase  34 Dec  9 10:32 gcware
drwxrwxr-x 8 gbase gbase  92 Dec  9 10:33 gnode
[gbase@gbase_rh7_003 gcinstall]$

只有103的gcware包含了完整的程序,其它的只有客户端部分。

[gbase@gbase_rh7_003 gcinstall]$ ll /opt/gbase/10.0.2.103/gcware
total 4
drwxr-xr-x 2 gbase gbase  151 Dec  9 10:31 bin
drwxr-xr-x 2 gbase gbase  151 Dec  9 10:32 config
drwxr-xr-x 3 gbase gbase   20 Dec  9 10:32 data
drwxr-xr-x 2 gbase gbase  158 Dec  9 10:32 gcware_server
drwxr-xr-x 4 gbase gbase   36 Dec  9 10:31 include
drwxr-xr-x 3 gbase gbase 4096 Dec  9 10:31 lib64
drwxr-xr-x 3 gbase gbase  125 Dec  9 10:32 libexec
drwxr-x--- 2 gbase gbase   54 Dec  9 10:33 liblog
drwxr-xr-x 2 gbase gbase   98 Dec  9 10:33 log
drwxr-xr-x 2 gbase gbase   41 Dec  9 10:31 python
drwxr-xr-x 2 gbase gbase   24 Dec  9 10:32 run
drwxr-xr-x 2 gbase gbase  122 Dec  9 10:32 sbin
[gbase@gbase_rh7_003 gcinstall]$ ll /opt/gbase/10.0.2.104/gcware
total 4
drwxr-xr-x 4 gbase gbase   36 Dec  9 10:32 include
drwxr-xr-x 3 gbase gbase 4096 Dec  9 10:32 lib64
[gbase@gbase_rh7_003 gcinstall]$ ll /opt/gbase/10.0.2.105/gcware
total 4
drwxr-xr-x 4 gbase gbase   36 Dec  9 10:32 include
drwxr-xr-x 3 gbase gbase 4096 Dec  9 10:32 lib64
[gbase@gbase_rh7_003 gcinstall]$

业务使用

建库,建表,SQL等完全相同,没有变动。

[gbase@gbase_rh7_003 gcinstall]$ gccli

GBase client 9.5.3.18.123926. Copyright (c) 2004-2020, GBase.  All Rights Reserved.

gbase> create database testdb;
Query OK, 1 row affected (Elapsed: 00:00:00.02)

gbase> use testdb;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)

gbase> create table t1(id int) distributed by('id');
Query OK, 0 rows affected (Elapsed: 00:00:00.12)

gbase> insert into t1 values(1);
Query OK, 1 row affected (Elapsed: 00:00:00.09)

gbase> insert into t1 select t1+1 from t1;
ERROR 1054 (42S22): Unknown column 't1' in 'field list'
gbase>
gbase>
gbase> insert into t1 select id+1 from t1;
Query OK, 1 row affected (Elapsed: 00:00:00.15)
Records: 1  Duplicates: 0  Warnings: 0

gbase> insert into t1 select id+2 from t1;
Query OK, 2 rows affected (Elapsed: 00:00:00.17)
Records: 2  Duplicates: 0  Warnings: 0

gbase> insert into t1 select id+4 from t1;
Query OK, 4 rows affected (Elapsed: 00:00:00.20)
Records: 4  Duplicates: 0  Warnings: 0

gbase> insert into t1 select id+8 from t1;
Query OK, 8 rows affected (Elapsed: 00:00:00.20)
Records: 8  Duplicates: 0  Warnings: 0

gbase> select * from t1;
+------+
| id   |
+------+
|    2 |
|    8 |
|   15 |
|    1 |
|    3 |
|    5 |
|    9 |
|   13 |
|    4 |
|    7 |
|    6 |
|   12 |
|   14 |
|   10 |
|   16 |
|   11 |
+------+
16 rows in set (Elapsed: 00:00:00.00)

gcware服务启停

有单独的gcware_services命令。

[gbase@gbase_rh7_003 ~]$ gcware_services --help
Usage:
        gcware_services <gcware|all>  <start|stop [--force]|restart [--force]|info>
        gcware_services help
[gbase@gbase_rh7_003 ~]$ gcware_services all stop
Stopping GCWareMonit success!
Stopping gcware :                                          [  OK  ]
[gbase@gbase_rh7_003 ~]$ 

其它服务启停

通过 gcluster_services 进行

命令参数

其中因为gbase和syncserver是多IP的,所有支持了带IP的格式做单独的启停。其它服务都是本机只有1份。

[gbase@gbase_rh7_003 gcinstall]$ gcluster_services --help
Usage:
        gcluster_services <gcluster|gcrecover|gbase|syncserver|gbase_ip|syncserver_ip|all>  <start|stop [--force]|restart [--force]|info>
        gcluster_services help

全部启停

原有的命令,会将本机器的所有服务都启停,包括多实例的计算节点。

[gbase@gbase_rh7_003 gcinstall]$ gcluster_services all stop
Stopping gcrecover :                                       [  OK  ]
Stopping gcluster :                                        [  OK  ]
Stopping gbase :                                           [  OK  ]
Stopping gbase :                                           [  OK  ]
Stopping gbase :                                           [  OK  ]
Stopping syncserver :                                      [  OK  ]
Stopping syncserver :                                      [  OK  ]
Stopping syncserver :                                      [  OK  ]
[gbase@gbase_rh7_003 gcinstall]$
[gbase@gbase_rh7_003 gcinstall]$ gcluster_services all start
Starting gbase :                                           [  OK  ]
Starting gbase :                                           [  OK  ]
Starting gbase :                                           [  OK  ]
Starting syncserver :                                      [  OK  ]
Starting syncserver :                                      [  OK  ]
Starting syncserver :                                      [  OK  ]
Starting gcluster :                                        [  OK  ]
Starting gcrecover :                                       [  OK  ]
[gbase@gbase_rh7_003 gcinstall]$

单个服务启停

[gbase@gbase_rh7_003 gcinstall]$ gcluster_services gbase stop
Stopping gbase :                                           [  OK  ]
Stopping gbase :                                           [  OK  ]
Stopping gbase :                                           [  OK  ]
[gbase@gbase_rh7_003 gcinstall]$ gcluster_services gcluster stop
Stopping gcluster :                                        [  OK  ]
[gbase@gbase_rh7_003 gcinstall]$ 

单独启停某个IP的服务

只支持gbase和syncserver两种服务。

[gbase@gbase_rh7_003 gcinstall]$ gcluster_services gbase_10.0.2.105 stop
Stopping gbase :                                           [  OK  ]
[gbase@gbase_rh7_003 gcinstall]$ gcluster_services syncserver_10.0.2.105 stop
Stopping syncserver :                                      [  OK  ]
[gbase@gbase_rh7_003 gcinstall]$

查看配置文件变动

部分配置,已经增加或变动到各自的IP目录下。

调度节点

[gbase@gbase_rh7_003 config]$ cat gbase_8a_gcluster.cnf  | grep '10\.0'
socket = /opt/gbase/10.0.2.103/gcluster_5258.sock
basedir = /opt/gbase/10.0.2.103/gcluster/server
datadir = /opt/gbase/10.0.2.103/gcluster/userdata/gcluster
socket = /opt/gbase/10.0.2.103/gcluster_5258.sock
pid_file = /opt/gbase/10.0.2.103/gcluster/log/gcluster/gclusterd.pid
[gbase@gbase_rh7_003 config]$

计算节点

[gbase@gbase_rh7_003 config]$ cat gbase_8a_gbase.cnf  | grep '10\.0'
socket = /opt/gbase/10.0.2.103/gbase_8a_5050.sock
basedir = /opt/gbase/10.0.2.103/gnode/server
datadir = /opt/gbase/10.0.2.103/gnode/userdata/gbase
bind_address = 10.0.2.103
socket = /opt/gbase/10.0.2.103/gbase_8a_5050.sock
pid_file = /opt/gbase/10.0.2.103/gnode/log/gbase/gbased.pid

参考

GBase 8a多实例版本9.5.3安装实例和运维常用命令

GBase 8a多实例9.5.3版本扩容实例操作手顺

GBase 8a多实例版本9.5.3变动介绍