大家好,这里是公众号 DBA学习之路,分享一些学习国产数据库路上的知识和经验。
前言
近期,南大通用 GBase 8s 数据库新一期的 GDCA 认证开启火热报名:培训预告 | 2024十月GBase 8s认证培训班开始报名啦~,通读了官方文档安装部署教程,经过自己的总结后,分享出来一起学习。
本文详尽的记录了 GBase 8s 数据库的安装部署方式以及实战演示,几乎做到了一网打尽,内容较长,希望大家可以耐心看完,建议收藏!!!
介绍
GBase 8s 是天津南大通用数据技术股份有限公司自主研发的、成熟稳定的基于共享存储的数据库集群,拥有自主知识产权。产品达到安全数据库四级标准(国际 B2),支持国密算法,支持 SQL92/99、ODBC、JDBC、ADO.NET、GCI(OCI/OCCI)、Python 接口等国际数据库规范和开发接口。支持集中式部署、共享存储高可用部署、两地三中心高可用部署,具备高容量、高并发、高性能等特性。
GBase 8s 适用于 OLTP 应用场景,包括金融、电信行业的关键核心业务系统,安全、党政、国防等行业对信息安全性有较高要求的信息系统,以及大型企业的经营类、管理类信息系统,能够提供 7*24 小时不间断运行处理能力,在 80% 以上场景中可以替代国际主流数据库。
在两次国测报告中,都可以见到 GBase 数据库的身影:
《安全可靠测评结果公告(2023年第1号)》[1] 《安全可靠测评结果公告(2024年第2号)》[2]
厂商 | 国测产品名称 | 数据库产品 | 安可级别 | 国测批次 | 类型 | 生态 |
---|---|---|---|---|---|---|
南大通用 | 南大通用GBase | 南大通用安全数据库管理系统 GBase 8s V8.8 | 1 | 1 | 集中 | Informix |
南大通用 | 南大通用GBase | GBase 8a MPP Cluster V9 | 1 | 2 | 分布 | |
南大通用 | 南大通用GBase | GBase 8c (openGauss 生态分布式) | 无 | 分布 | openGauss |
由此可知,GBase 数据库还是很值得学习的!
安装包下载
Gbase 8s V8.8 数据库安装包可以在 GBase 官网[3] 直接下载:
Gbase 8s V8.8 x86 的数据库安装介质下载地址:GBase8sV8.8_TL_3.5.1_3x_x86_64.zip[4]
下载完成后的安装包大概 400 多 M,查看 md5 值:
╭─lucifer@Lucifer-7 ~/Downloads
╰─$ md5sum GBase8sV8.8_TL_3.5.1_3x_x86_64.zip
8bdd91c0aeb6d6f1a6897c3fd7537cea GBase8sV8.8_TL_3.5.1_3x_x86_64.zip
解压之后有以下文件:
╭─lucifer@Lucifer-7 ~/Downloads/GBase8sV8.8_TL_3.5.1_3x_x86_64
╰─$ ll
total 1038320
-rwxr-xr-x@ 1 lucifer staff 21K 7 31 17:32 AutoInit_GBase8s.sh
-rwxr-xr-x@ 1 lucifer staff 330M 8 13 10:27 GBase8sV8.8_TL_3.5.1_3X1.tar
-rwxr-xr-x@ 1 lucifer staff 177M 8 13 10:26 clientsdk_3.5.1_3X1.tar
-rwxr-xr-x@ 1 lucifer staff 2.6K 7 31 17:32 readme.txt
╭─lucifer@Lucifer-7 ~/Downloads/GBase8sV8.8_TL_3.5.1_3x_x86_64
╰─$ md5sum GBase8sV8.8_TL_3.5.1_3X1.tar
0dfa4fd3d97a4e9824f37b67b06e3002 GBase8sV8.8_TL_3.5.1_3X1.tar
查看 readme 文档可以发现一些安装提示:
1. 安装预置条件
1)确保安装包和平台适配
2)安装依赖包:jdk(1.6版本以上)、unzip、libaio、libgcc、libstdc、ncurses、pam,如果缺失请提前安装
这里暂时只关注安装前的配置条件,关于 AutoInit_GBase8s.sh 脚本在下面安装的一键安装的章节再讲,这里暂且不表。
安装前准备
环境信息:
主机名 | 版本 | CPU | 内存 | 硬盘 | IP地址 |
---|---|---|---|---|---|
gbase8s | rhel7.9 | x86 | 8G | 100G | 192.168.6.96 |
GBase 8s 的数据库组件安装完成后,大约有 500M,但存储物理日志,逻辑日志,智能大对象,临时数据和事务数据都需要使用磁盘存储空间,建议至少有 10G 以上的磁盘空闲空间。
官方文档中对于系统主机的要求并不多,只需要创建数据库安装用户以及安装目录,上传安装包即可进行安装。
关闭防火墙
这里还是建议关闭防火墙的,因为之前参与过 GBase 8s 新版本测试,如果不关闭防火墙,会有很多不必要的麻烦,所以还是关了吧:
[root@gbase8s ~]# systemctl stop firewalld.service
[root@gbase8s ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
关闭 SELINUX
建议关闭 SELNUX,防止造成一些不必要的问题:
[root@gbase8s ~]# setenforce 0
[root@gbase8s ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@gbase8s ~]# cat /etc/selinux/config | grep SELINUX=
# SELINUX= can take one of these three values:
SELINUX=disabled
配置 hosts 文件
这个也是很必要的,比如配置 GEM 就需要查找 hosts 文件:
[root@gbase8s ~]# cat<<-EOF>>/etc/hosts
192.168.6.96 gbase8s
EOF
[root@gbase8s ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.6.96 gbase8s
创建组和用户
GBase 8s 数据库需要一个名字为 gbasedbt 的操作系统用户,做为数据库的超级用户。官方文档建议在安装前创建好 gbasedbt 组和 gbasedbt 用户:
[root@gbase8s soft]# groupadd gbasedbt
[root@gbase8s soft]# useradd -g gbasedbt gbasedbt
## 修改 gbasedbt 用户密码为 gbasedbt
[root@gbase8s soft]# echo "gbasedbt:gbasedbt" | chpasswd
## 检查是否创建成功
[root@gbase8s ~]# cat /etc/passwd | grep gbasedbt
gbasedbt:x:1001:1001::/home/gbasedbt:/bin/bash
📢注意:如果我们在安装时,没有提前创建这个用户,在安装过程中,会提示要创建这个用户,并输入密码。不过在安装过程中创建的用户,没有创建一个新的目录做为 gbasedbt 的Home,这可能导致在后续的创建数据库实例时,无法自动生成实例的环境变量。
创建安装目录及授权
[root@gbase8s soft]# mkdir -p /opt/GBASE/gbase
[root@gbase8s soft]# chown -R gbasedbt:gbasedbt /opt/GBASE
检查依赖项
在安装包的 readme 中对依赖包有一定的要求,安装依赖包:jdk(1.6版本以上)、unzip、libaio、libgcc、libstdc、ncurses、pam,如果缺失请提前安装:
## 查看 jdk 版本,1.8 符合要求
[root@gbase8s ~]# java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
## 依赖包均已安装
[root@gbase8s ~]# rpm -q unzip libaio libgcc libstdc ncurses pam
unzip-6.0-21.el7.x86_64
libaio-0.3.109-13.el7.x86_64
libgcc-4.8.5-44.el7.x86_64
package libstdc is not installed
ncurses-5.9-14.20130511.el7_4.x86_64
pam-1.1.8-23.el7.x86_64
上传安装包
上传安装包到 /soft 目录下:
[root@gbase8s soft]# ll
-rwxr-xr-x. 1 root root 21797 Oct 10 12:52 AutoInit_GBase8s.sh
-rwxr-xr-x. 1 root root 346408960 Oct 10 12:52 GBase8sV8.8_TL_3.5.1_3X1.tar
## 解压缩 tar 安装包
[root@gbase8s soft]# tar -xf GBase8sV8.8_TL_3.5.1_3X1.tar
[root@gbase8s soft]# ll
-rwxr-xr-x. 1 root root 21797 Oct 10 12:52 AutoInit_GBase8s.sh
drwxr-xr-x. 2 root root 77 Jul 31 14:07 doc
-rwxr-xr-x. 1 root root 346408960 Oct 10 12:52 GBase8sV8.8_TL_3.5.1_3X1.tar
-rwxr-xr-x. 1 root root 346290703 Jul 31 14:16 ids_install
-rw-r--r--. 1 root root 1864 Jul 31 14:16 ids.properties
-rwxr-xr-x. 1 root root 82770 Jul 31 14:16 onsecurity
以上都准备好之后,就可以进行 GBase 8s 数据库的安装了。
GBase 8s 安装
GBase 8s 数据库安装,支持图形界面方式和控制台的命令行方式。默认的安装方式是控制台命令行方式。如果希望使用图形界面安装,只需要在启动安装程序时,后面加上参数 ./ids_install -i swing
即可。
安装过程中,会显示产品的 License,内容较长:
在控制台的命令行方式中,可以连续按 5 次回车。 在图形界面方式中,需要用鼠标拉动界面右侧的滚动条到底部,就可以点那个复选框,确认 License 了。
典型安装
安装 GBase 8s 软件
图形化安装
在 root 用户下,进入安装包目录,运行安装命令 sh ids_install
,启动安装程序即可:
[root@gbase8s soft]# sh ids_install -i swing
Preparing to install...
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
Launching installer...
启动图形化安装程序:
注意,这里需要把许可协议拉到底才可以选择接受:
选择安装目录:
选择典型安装(安装所有组件),这里如果选择自定义安装,就是可以选择安装哪些组件:
不创建数据库实例:
开始安装:
至此,GBase 8s 数据库的组件,全部安装完成。
命令行安装
在 root 用户下,进入安装包目录,运行安装命令 sh ids_install -i console
(命令行不指定 -i 也可以),启动安装程序即可:
[root@gbase8s soft]# sh ids_install -i console
Preparing to install...
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
Launching installer...
===============================================================================
GBase Software Bundle (created with InstallAnywhere)
-------------------------------------------------------------------------------
Preparing CONSOLE Mode Installation...
===============================================================================
Getting Started
---------------
This application will guide you through the installation of GBase Software
Bundle.
Copyright General Data Corporation 2014, 2024. All rights reserved.
1. Release Notes
The Release Notes can be found in /soft/doc/ids_unix_relnotes_12.10.html.
2. Launch Information Center
Access the GBase Information Center at http://www.gbase.cn.
To Begin Installation, respond to each prompt to proceed to the next step in
the installation.
If you want to change something on a previous step, type 'back'.
You may cancel this installation at any time by typing 'quit'.
PRESS <ENTER> TO CONTINUE:
回车继续下一步安装:
## 这一步全都是 License 协议相关内容,不做演示,一路回车直接跳过
===============================================================================
License Agreement
-----------------
Installation and Use of GBase Software Bundle Requires Acceptance of the
Following License Agreement:
Thank you for choosing GBase product!
...
...
...
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): Y
选择安装目录,由于我们创建的安装目录就是 /opt/GBASE/gbase,所以直接回车即可:
===============================================================================
Installation Location
---------------------
Choose location for software installation.
Default Install Folder: /opt/GBASE/gbase
ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
:
安装程序支持典型安装和自定义安装方式,我们选择典型安装(默认),回车下一步:
===============================================================================
Installation or Distribution
----------------------------
Select the installation type.
Typical: Install the database server with all features and a database server
that
is configured with default values. Includes:
** Client Software Development Kit (CSDK)
** Java Database Connectivity (JDBC)
Minimum disk space required: 700-800MB
Custom: Install the database server with specific features and software that
you need.
Optionally install a configured database server instance.
Minimum disk space required: 75 MB (without a server instance)
->1- Typical installation
2- Custom installation
3- Extract the product files (-DLEGACY option)
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::
在安装过程中,可以自动创建一个数据库的实例。由于典型安装中创建的实例在配置上非常简单,不适合后期深入的学习 GBase 8s,因此我们选择不创建实例,在安装后,可以手动执行一个脚本,可以很方便的创建一个新的数据库实例。所以这里选择不创建数据库实例,输入 2,回车下一步:
===============================================================================
Server Instance Creation
------------------------
Create a server instance?
->1- Yes - create an instance
2- No - do not create an instance
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:: 2
# 重要说明:
# 这个选择很重要,选择不创建实例,不但可以减少你的整体安装时间,也会让你对这款数据库,有更深入地了解。
# 安装过程中,自动创建一个数据库实例,在个别情况下,可能出现安装后,不能创建数据库现象(执行 create database 卡住,一段时间后报错退出)。这个问题的原因是sqlhosts 文件中使用了机器名,需要我们修改成服务器的 IP 地址,并重启数据库,就可以解决。也许有其它好的解决方法,不过这是我目前知道的一个方法,而且好用。
安装程序给出一个报告,列出了本次将要安装的数据库组件,按回车将继续安装:
===============================================================================
Installation Summary
--------------------
Please review the following before continuing:
Product Name:
GBase Software Bundle
Install Folder:
/opt/GBASE/gbase
Product Features:
GBase database server,
Base Server,
Extensions and tools,
J/Foundation,
Database extensions,
Conversion and reversion support,
XML publishing,
Demonstration database scripts,
Enterprise Replication,
Data loading utilities,
onunload and onload utilities,
dbload utility,
Backup and Restore,
archecker utility,
ON-Bar utility,
Interface to Tivoli Storage Manager,
Administrative utilities,
Performance monitoring utilities,
Miscellaneous monitoring utilities,
Auditing utilities,
Database import and export utilities,
JSON Client Support,
Global Language Support (GLS),
Chinese
Disk Space Information (for Installation Target):
Required: 578,902,678 Bytes
Available: 92,369,674,240 Bytes
PRESS <ENTER> TO CONTINUE:
安装程序再次让用户确认安装程序的位置,回车继续下一步:
===============================================================================
Ready To Install
----------------
InstallAnywhere is now ready to install GBase Software Bundle onto your system
at the following location:
/opt/GBASE/gbase
PRESS <ENTER> TO INSTALL:
等待几分钟后安装完成:
===============================================================================
Installing...
-------------
[==================|==================|==================|==================]
[------------------|------------------|------------------|------------------]
===============================================================================
Installation Complete
---------------------
Congratulations! GBase Software Bundle installation is complete.
Product install status:
GBase: Successful
GBase Connect: Successful
GBase 8s V8.8
For more information about using GBase products, see the GBase Information
Center at http://www.gbase.cn.
PRESS <ENTER> TO EXIT THE INSTALLER:
[root@gbase8s soft]#
回车退出安装程序,至此,GBase 8s 数据库的组件,全部安装完成。
静默安装
生成响应文件
执行静默安装(又称为无人管理的安装),必须使用响应文件,其中包含关于想要如何进行该产品安装的信息。
响应文件的获取方式有两种:
执行 GBase 8s 安装脚本,录制模板生成响应文件: ./ids_install -r /soft/bundle.properties
,安装完成后,将在 /soft 路径下生成响应文件bundle.properties
。参考安装介质中的 bundle.properties 初始配置文件,创建一个自己的安装配置文件。
📢 注意:请不要对安装介质中的 bundle.properties 文件进行重写、移动或删除。
这里我使用录制模板生成响应文件的方式创建了一个响应文件:
[root@gbase8s soft]# sh ids_install -i swing -r /soft/bundle.properties
Preparing to install...
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
Launching installer...
查看生成后的响应文件内容:
[root@gbase8s soft]# grep -v "^\s*\(#\|$\)" /soft/bundle.properties
USER_INSTALL_DIR=/opt/GBASE/gbase
UNIX_INSTALLTYPE_SELECT=DEFAULT
LICENSE_ACCEPTED=TRUE
USER_INSTALL_DIR=/opt/GBASE/gbase
IDS_INSTALL_TYPE=TYPICAL
DIR_SEC_SEL_BOOLEAN_1=<null>
DIR_SEC_SEL_BOOLEAN_2=<null>
DIR_SEC_SEL_BOOLEAN_3=<null>
后续可以直接使用这个响应文件来安装 GBase 8s 软件。
静默安装 GBase 8s 软件
运行静默安装命令,指示响应文件的相对或绝对路径:
[root@gbase8s soft]# sh ids_install -i silent -f /soft/bundle.properties
全程无输出,无感知,等待一会儿就安装完成了。
创建数据库实例
上面介绍了如何安装 GBase 8s 数据库软件,我们再创建一个数据库实例,就可以工作了。
创建数据库实例,需要切换到 gbasedbt 用户:
[root@gbase8s soft]# su - gbasedbt
[gbasedbt@gbase8s ~]$
GBaseInit_gbasedbt.sh 创建
在数据库安装目录的 etc 目录有,有一个 GBaseInit_gbasedbt.sh
脚本,可以采用向导方式,让我们一步一步,方便地创建一个新的数据库实例:
[gbasedbt@gbase8s ~]$ cd /opt/GBASE/gbase/etc/
[gbasedbt@gbase8s etc]$ ll GBaseInit_gbasedbt.sh
-rwxr-xr-x. 1 gbasedbt gbasedbt 32705 Jul 31 13:44 GBaseInit_gbasedbt.sh
执行创建实例的脚本,开始创建数据库实例:
[gbasedbt@gbase8s etc]$ sh GBaseInit_gbasedbt.sh
脚本默认的实例名称为 gbaseserver,可以在冒号后面输入我们希望的名称,也可以直接回车,使用默认的实例名:
# 说明:实例的名称可以是字母,数字和下划线。不要用减号,不要用减号,不要用减号。
Initializing Program...OK
ENTER THE INSTANCE INFORMATION or PRESS <ENTER> TO ACCEPT THE DEFAULT.
安装脚本询问 GBase 8s 的程序安装在哪个路径下,默认是我们之前安装时指定的路径,直接回车继续:
SEARCHING FOR GBASE INSTALL FOLDER, PLEASE WAIT FOR SECONDS...
GBASE INSTALL FOLDER LIST:
1) /opt/GBASE/gbase
CHOOSE GBASE INSTALL FOLDER(GBASEDBTDIR) [Default:/opt/GBASE/gbase]:
输入数据库服务器 IP 地址(默认为本机 IP,若不是则手动修改为本机 IP),回车继续:
CHOOSE SERVICE IP ADDRESS FROM THE LIST:
1) 192.168.6.96
2) 127.0.0.1
3) 192.168.122.1
ENTER THE NUMBER FOR YOUR CHOICE [Default:192.168.6.96]:
输入监听端口号(默认 9088),回车继续:
SPECIFY THE PORT NUMBER FOR GBASE [Default:9088]:
初始化的类型,建议选择 CUSTOM,自定义特性,回车继续:
INITIALIZE TYPE:
1) TYPICAL -- Initialize the instance with all features configured with default values.
2) CUSTOM -- Initialize the instance with specific features that you need.
ENTER THE NUMBER FOR YOUR CHOICE [Default:1]: 2
选择数据库字符集(默认为 en_US.8859-1),这里选择 utf8:
字符集名称 | 编码 |
---|---|
8859-1 | 819 |
gb | 57357 |
GB2312-80 | 57357 |
utf8 | 57372 |
big5 | 57352 |
GB18030-2000 | 5488 |
GBASE CHARACTER SET LIST:
1) en_US.8859-1
2) zh_CN.GB18030-2000
3) zh_CN.utf8
ENTER THE NUMBER FOR YOUR CHOICE [Default:1]: 3
数据保存目录,默认即可,回车继续:
ENTER THE DATA SPACE PATH [Default:/opt/GBASE/gbase/gbaseserver_dbs]:
保存逻辑日志的数据库空间大小,建议输入 200,回车继续:
# 说明:这个地方指定的值很大时,数据库会按该值分配磁盘空间,可能用时较长。
ENTER THE LOGICAL LOG DBSPACE SIZE(MB) [Default:8880]: 200
保存物理日志的数据库空间大小,建议输入 200,回车继续:
# 说明:这个地方指定的值很大时,数据库会按该值分配磁盘空间,可能用时较长。
ENTER THE PHYSICAL LOG DBSPACE SIZE(MB) [Default:8880]: 200
保存 LOB 数据的数据库空间大小,建议输入 100,回车继续:
# 说明:这个地方指定的值很大时,数据库会按该值分配磁盘空间,可能用时较长。
ENTER THE SMART LOB DBSPACE SIZE(MB) [Default:1806]: 100
保存临时数据的数据库空间大小,建议输入 100,回车继续:
# 说明:这个地方指定的值很大时,数据库会按该值分配磁盘空间,可能用时较长。
ENTER THE TEMPORARY DBSPACE SIZE(MB) [Default:1806]: 100
是否需要进行一些高级设置,输入 Y,回车继续:
ENTER "Y" TO START DATABASE ADVANCED SETTINGS, OR ENTER "N" TO ACCEPT DEFAULT VALUES: [Default:N]: Y
需要创建几个保存数据的数据库空间,我们输入 5,回车继续:
# 提示:这点很重要,方便我们后面学习分片表。
ENTER THE NUMBER OF DATA DBSPACES [Default:1]: 5
需要创建几个保存临时数据的数据库空间,我们输入 3,回车继续:
ENTER THE NUMBER OF TEMP DBSPACES [Default:1]: 3
是否启用 GL_USEGLU(默认不启用),回车继续:
Enter "Y" TO ENABLE ENVIRONMENT GL_USEGLU, OR ENTER "N" TO DISABLE: [Default:N]:
安装前列出了创建实例的清单,输入 Y,回车继续:
INSTANCE SUMMARY:
Instance name: gbaseserver
GBase install directory: /opt/GBASE/gbase
IP address & port: 192.168.6.96:9088
Character set: zh_CN.utf8
Logical log space size: 200 MB
Physical log space size: 200 MB
Smart LOB space size: 100 MB
Temp DBSpace size: 100 MB
Data path: /opt/GBASE/gbase/gbaseserver_dbs
Data path free size: 87985 MB
The number of data DBSpace: 5
The number of temp DBSpace: 3
Environment GL_USEGLU: 0
Enter "Y" to Start database initializing, or Enter "N" to Edit Again: Y
开始创建实例:
Touching Chunks...OK
Create sqlhosts File: /opt/GBASE/gbase/etc/sqlhosts.gbaseserver ...OK
Setting Parameters in /opt/GBASE/gbase/etc/onconfig.gbaseserver :
ROOTPATH.ROOTSIZE.DBSERVERNAME.FULL_DISK_INIT.SBSPACENAME.SYSSBSPACENAME.DBSPACETEMP.LOGFILES.MULTIPROCESSOR.VPCLASS.NETTYPE.CLEANERS.DEF_TABLE_LOCKMODE.DIRECT_IO.LOCKS.TAPEDEV.LTAPEDEV.CKPTINTVL.DS_MAX_QUERIES.DS_TOTAL_MEMORY.DS_NONPDQ_QUERY_MEM.PHYSBUFF.LOGBUFF.AUTO_TUNE.MSGPATH.SERVERNUM.ALLOW_NEWLINE.TEMPTAB_NOLOG.DUMPSHMEM.USEOSTIME.STACKSIZE.ON_RECVRY_THREADS.OFF_RECVRY_THREADS.USELASTCOMMITTED.SHMVIRTSIZE.SHMADD.GBASEDBTCONTIME.BUFFERPOOL2K.BUFFERPOOL16K...AUTO_CKPTS.OK
Initializing Root DBSpace & Share Memory...OK
Creating system database.......OK
Creating logical log Dbspace...OK
Creating physical log Dbspace...OK
Creating smart LOB Dbspace...OK
Creating temp Dbspace.1.2.3...OK
Creating data Dbspace.1.2.3.4.5...OK
Setting dbscheduler...OK
Moving physical log...OK
Adding 20 logical logs: 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20...OK
Setting data chunks extendable...OK
Cleaning logical logs in rootdbs...Your evaluation license will expire on 2025-10-10 00:00:00
.Your evaluation license will expire on 2025-10-10 00:00:00
.Your evaluation license will expire on 2025-10-10 00:00:00
.Your evaluation license will expire on 2025-10-10 00:00:00
...OK
Database restarting.......Your evaluation license will expire on 2025-10-10 00:00:00
OK
Creating database: gbasedb...OK
Now you can use this URL to connect to gbasedb:
jdbc:gbasedbt-sqli://192.168.6.96:9088/gbasedb:GBASEDBTSERVER=gbaseserver;DB_LOCALE=zh_CN.utf8;CLIENT_LOCALE=zh_CN.utf8;NEWCODESET=UTF8,utf8,57372;
Version:
Your evaluation license will expire on 2025-10-10 00:00:00
On-Line (CKPT INP) -- Up 00:00:16 -- 4275148 Kbytes
Build Number: 3.5.1_3X1_3_28a3a6
GBase Initializing Finished!
Initialize log file : ./InitGBaseDB_202410101331.log
Press <ENTER> to Exit and Logout...
Killed
至此,数据库实例创建完成,初始化完成之后,数据库就是在线状态,无需再次启动数据库。
手工创建实例
如果不喜欢交互式的脚本初始化方式,可以按照如下步骤,手动创建实例并初始化。
创建一个实例,假设其实例名为 gbaseserver
。创建一个实例需要配置以下三个文件,使用用实例名作为文件的后缀:
环境变量文件: profile.gbaseserver
配置参数文件: onconfig.gbaseserver
sqlhosts 配置文件: sqlhosts.gbaseserver
具体步骤如下:
1、创建数据库的数据文件存储目录 /dbs
使用 root 用户创建数据目录:
## 创建数据目录 dbs 并授权
[root@gbase8s ~]# mkdir -p /opt/GBASE/gbase/dbs
[root@gbase8s ~]# chown gbasedbt:gbasedbt /opt/GBASE/gbase/dbs
[root@gbase8s ~]# chmod 775 /opt/GBASE/gbase/dbs
## 创建空文件 rootdbs 并授权
[root@gbase8s ~]# touch /opt/GBASE/gbase/dbs/rootdbs
[root@gbase8s ~]# chown gbasedbt:gbasedbt /opt/GBASE/gbase/dbs/rootdbs
[root@gbase8s ~]# chmod 660 /opt/GBASE/gbase/dbs/rootdbs
2、配置 profile.gbaseserver 环境变量文件
切换到 gbasedbt 用户,将默认环境变量 .bash_profile 文件复制一份,命名为 profile.gbaseserver:
[root@gbase8s ~]# su - gbasedbt
Last login: Thu Oct 10 15:22:55 CST 2024 on pts/0
[gbasedbt@gbase8s ~]$ cp ~/.bash_profile ~/profile.gbaseserver
## 配置环境变量文件 ~/profile.gbaseserver
[gbasedbt@gbase8s ~]$ cat<<-\EOF>>~/profile.gbaseserver
export GBASEDBTSERVER=gbaseserver ## 实例名
export GBASEDBTDIR=/opt/GBASE/gbase ## 安装路径
export ONCONFIG=onconfig.gbaseserver ## 配置参数文件名称
export GBASEDBTSQLHOSTS=$GBASEDBTDIR/etc/sqlhosts.gbaseserver ## sqlhosts 文件名称
export PATH=$GBASEDBTDIR/bin:$GBASEDBTDIR/sbin:/usr/bin:${PATH}:.
export GL_DATE="%iY-%m-%d"
export DATETIME="%iY-%m-%d %H:%M:%S"
export DB_LOCALE=zh_cn.GB18030-2000
export CLIENT_LOCALE=zh_cn.GB18030-2000
export LD_LIBRARY_PATH=${GBASEDBTDIR}/lib:${GBASEDBTDIR}/lib/esql:${GBASEDBTDIR}/lib/cli
export TERM=vt100
export TERMCAP=$GBASEDBTDIR/etc/termcap
export GBASEDBTTERM=termcap
export DBTEMP=$GBASEDBTDIR/tmp
EOF
## 生效环境变量
source ~/profile.gbaseserver
为了 gbasedbt 用户在登录后自动应用这些环境变量,可以在 .bash_profile 文件中添加:
cat<<-\EOF>>~/.bash_profile
source /home/gbasedbt/profile.gbaseserver
EOF
然后生效环境变量:
[gbasedbt@gbase8s ~]$ source ~/profile.gbaseserver
3、配置 onconfig.gbaseserver 参数文件
将 /opt/BASE/gbase/etc/ 目录中的 onconfig.std 文档复制一份,命名为 $ONCONFIG 变量指定的名称 onconfig.gbaseserver:
[gbasedbt@gbase8s ~]$ cd /opt/GBASE/gbase/etc/
[gbasedbt@gbase8s etc]$ cp onconfig.std onconfig.gbaseserver
## 查看需要修改的参数的默认配置
[gbasedbt@gbase8s etc]$ cat onconfig.gbaseserver | grep -E "ROOTPATH|SERVERNUM|DBSERVERNAME|TAPEDEV|LTAPEDEV" | grep -v "^\s*\(#\|$\)"
## 系统数据库文件存储空间路径
ROOTPATH $GBASEDBTDIR/tmp/demo_on.rootdbs
## 实例编号,多实例中每个实例编号要唯一
SERVERNUM 0
## 数据库服务器实例名称
DBSERVERNAME
## 用于存储空间备份的磁带设备
TAPEDEV /dev/tapedev
## 用于逻辑日志备份的磁带的设备路径
LTAPEDEV /dev/tapedev
编辑 onconfig.gbaseserver 文件,配置以下参数并保存:
ROOTPATH /opt/GBASE/gbase/dbs/rootdbs
SERVERNUM 1
DBSERVERNAME gbaseserver
TAPEDEV /dev/null
LTAPEDEV /dev/null
配置完成后查看参数值是否正确:
[gbasedbt@gbase8s etc]$ cat onconfig.gbaseserver | grep -E "ROOTPATH|SERVERNUM|DBSERVERNAME|TAPEDEV|LTAPEDEV" | grep -v "^\s*\(#\|$\)"
ROOTPATH /opt/GBASE/gbase/dbs/rootdbs
SERVERNUM 1
DBSERVERNAME gbaseserver
TAPEDEV /dev/null
LTAPEDEV /dev/null
4、配置 sqlhosts.gbaseserver 文件
GBase 8s 数据库使用的监听端口默认为 9088,多实例中每个实例的端口必须唯一。
将 /opt/GBASE/gbase/etc/ 目录中的 sqlhosts.std 文档复制一份,命名为环境变量 GBASEDBTSQLHOSTS 指定的名称 sqlhost.gbaseserver:
[gbasedbt@gbase8s ~]$ cd /opt/GBASE/gbase/etc/
[gbasedbt@gbase8s etc]$ cp sqlhosts.std sqlhosts.gbaseserver
[gbasedbt@gbase8s etc]$ grep -v "^\s*\(#\|$\)" sqlhosts.gbaseserver
# 实例名 # 网络连接方式 # IP # 端口
demo_on onipcshm on_hostname on_servername
编辑 sqlhosts.gbaseserver 文件,在文件末尾添加相关实例名、网络连接方式、IP 及端口号:
[gbasedbt@gbase8s etc]$ cat<<-EOF>>/opt/GBASE/gbase/etc/sqlhosts.gbaseserver
gbaseserver onsoctcp 192.168.6.96 9088
EOF
[gbasedbt@gbase8s etc]$ grep -v "^\s*\(#\|$\)" sqlhosts.gbaseserver
demo_on onipcshm on_hostname on_servername
gbaseserver onsoctcp 192.168.6.96 9088
5、初始化数据库
使用 gbasedbt 用户执行初始化命令:
[gbasedbt@gbase8s etc]$ oninit -ivy
Your evaluation license will expire on 2025-10-10 00:00:00
Reading configuration file '/opt/GBASE/gbase/etc/onconfig.gbaseserver'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 4310 kbytes...succeeded
Creating infos file "/opt/GBASE/gbase/etc/.infos.gbaseserver"...succeeded
Linking conf file "/opt/GBASE/gbase/etc/.conf.gbaseserver"...succeeded
Initializing rhead structure...rhlock_t 16384 (512K)... rlock_t (2656K)... Writing to infos file...succeeded
Initialization of Encryption...succeeded
Initializing ASF...succeeded
Initializing Dictionary Cache and SPL Routine Cache...succeeded
Bringing up ADM VP...succeeded
Creating VP classes...succeeded
Forking main_loop thread...succeeded
Initializing DR structures...succeeded
Forking 1 'soctcp' listener threads...succeeded
Starting tracing...succeeded
Initializing 8 flushers...succeeded
Initializing log/checkpoint information...succeeded
Initializing dbspaces...succeeded
Opening primary chunks...succeeded
Validating chunks...succeeded
Creating database partition...succeeded
Initialize Async Log Flusher...succeeded
Starting B-tree Scanner...succeeded
Init ReadAhead Daemon...succeeded
Init DB Util Daemon...succeeded
Initializing DBSPACETEMP list...succeeded
Init Auto Tuning Daemon...succeeded
Checking database partition index...succeeded
Initializing dataskip structure...succeeded
Checking for temporary tables to drop...succeeded
Updating Global Row Counter...succeeded
Forking onmode_mon thread...succeeded
Creating periodic thread...succeeded
Creating periodic thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
查看数据库实例状态:
[gbasedbt@gbase8s etc]$ onstat -
Your evaluation license will expire on 2025-10-10 00:00:00
On-Line -- Up 00:01:06 -- 173360 Kbytes
至此,手工创建数据库实例完成。
脚本一键安装
官方提供了 GBase 8s 的一键安装脚本,也就是的安装包中的 AutoInit_GBase8s.sh 脚本,这个我们在安装包下载有说过一个 readme 文件中有看到过:
2. root 用户上传 AutoInit_GBase8s.sh 和 GBase8sV8.8_TL_3.5.1_x86_64.tar 到服务器任意同一目录
3. root 用户执行 AutoInit_GBase8s.sh
执行示例:
bash AutoInit_GBase8s.sh
示例说明:所有配置使用默认值,具体配置参考安装成功后结果输出
bash AutoInit_GBase8s.sh -i /data/gbase351 -n gbase351 -c 8 -m 4000
示例说明:安装GBase 8s数据库到/data/gbase351目录,实例使用8个CPU逻辑核,使用4G内容
4. 安装最后结果输出如下表示数据库实例安装成功
--== GBase 8s Information for this install ==--
$GBASEDBTSERVER : gbase351
$GBASEDBTDIR : /data/gbase351
USER HOME : /home/gbase
DBSPACE DIR : /data/gbase
IP ADDRESS : 0.0.0.0
PORT NUMBER : 9088
$DB_LOCALE : zh_CN.utf8
$CLIENT_LOCALE : zh_CN.utf8
JDBC URL : jdbc:gbasedbt-sqli://IPADDR:9088/testdb:GBASEDBTSERVER=gbase351;DB_LOCALE=zh_CN.utf8;CLIENT_LOCALE=zh_CN.utf8;IFX_LOCK_MODE_WAIT=10
JDBC USERNAME : gbasedbt
JDBC PASSWORD : GBase123$%
INNER USERNAME : dbtuser
INNER PASSWORD : GBase123$%
没错,这就是官方提供的一键安装脚本,GBase 8s 一键安装只需要上传 AutoInit_GBase8s.sh 和 GBase8sV8.8_TL_3.5.1_x86_64.tar 到主机上即可。
这里简单演示一下一键安装脚本的使用:
## 安装目录只有 2 个文件
[root@gbase8s soft]# ll
-rwxr-xr-x. 1 root root 21797 Oct 10 12:52 AutoInit_GBase8s.sh
-rwxr-xr-x. 1 root root 346408960 Oct 10 12:52 GBase8sV8.8_TL_3.5.1_3X1.tar
注意:不能提前创建 gbasedbt 用户和安装目录,最好是安装好干净的操作系统,什么都不要修改,然后直接执行脚本一键安装,否则可能会报错:
[2024-10-10 16:46:00] The SYSDBA user is: gbasedbt
[2024-10-10 16:46:00] IPADDR: 0.0.0.0
[2024-10-10 16:46:00] Datadir: /data/gbase
User: gbasedbt exists, you must delete gbasedbt user and group !
最简单安装,不加任何参数:
[root@gbase8s soft]# sh AutoInit_GBase8s.sh
[2024-10-10 16:50:33] The SYSDBA user is: gbasedbt
[2024-10-10 16:50:33] IPADDR: 0.0.0.0
[2024-10-10 16:50:33] Datadir: /data/gbase
[2024-10-10 16:50:33] Creating group [gbasedbt] and user [gbasedbt] with HOME [/home/gbase].
[2024-10-10 16:50:33] Unziping [GBase8sV8.8_TL_3.5.1_3X1.tar].
[2024-10-10 16:50:34] Check path INSTALL_DIR(/opt/gbase) security.
[2024-10-10 16:50:34] Execute software install, this will take a moment.
[2024-10-10 16:51:48] Building ~gbasedbt/.bash_profile .
[2024-10-10 16:51:48] Building /opt/gbase/etc/sqlhosts .
[2024-10-10 16:51:48] Building /opt/gbase/etc/onconfig.gbase01 .
[2024-10-10 16:51:48] Creating DATADIR: /data/gbase .
[2024-10-10 16:51:48] Change permission for directory: /data/gbase .
[2024-10-10 16:51:48] Change permission for directory: /data .
[2024-10-10 16:51:49] Creating file $INSTALL_DIR/etc/upgraded .
[2024-10-10 16:51:49] Start run database init: oninit -ivy
Your evaluation license will expire on 2025-10-10 00:00:00
Reading configuration file '/opt/gbase/etc/onconfig.gbase01'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 4310 kbytes...succeeded
Creating infos file "/opt/gbase/etc/.infos.gbase01"...succeeded
Linking conf file "/opt/gbase/etc/.conf.gbase01"...succeeded
Initializing rhead structure...rhlock_t 16384 (512K)... rlock_t (2656K)... Writing to infos file...succeeded
Initialization of Encryption...succeeded
Initializing ASF...succeeded
Initializing Dictionary Cache and SPL Routine Cache...succeeded
Bringing up ADM VP...succeeded
Creating VP classes...succeeded
Forking main_loop thread...succeeded
Initializing DR structures...succeeded
Forking 1 'soctcp' listener threads...succeeded
Forking 1 'soctcp' listener threads...succeeded
Starting tracing...succeeded
Initializing 8 flushers...succeeded
Initializing log/checkpoint information...succeeded
Initializing dbspaces...succeeded
Opening primary chunks...succeeded
Validating chunks...succeeded
Creating database partition...succeeded
Initialize Async Log Flusher...succeeded
Starting B-tree Scanner...succeeded
Init ReadAhead Daemon...succeeded
Init DB Util Daemon...succeeded
Initializing DBSPACETEMP list...succeeded
Init Auto Tuning Daemon...succeeded
Checking database partition index...succeeded
Initializing dataskip structure...succeeded
Checking for temporary tables to drop...succeeded
Updating Global Row Counter...succeeded
Forking onmode_mon thread...succeeded
Creating periodic thread...succeeded
Creating periodic thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
OK
[2024-10-10 16:51:58] Creating system database.........
[2024-10-10 16:52:24] Creating dbspace plogdbs.
[2024-10-10 16:52:27] Creating dbspace llogdbs.
[2024-10-10 16:52:32] Creating smart blob space sbspace01
[2024-10-10 16:52:39] Creating dbspace tempdbs01
[2024-10-10 16:52:45] Creating dbspace datadbs01
[2024-10-10 16:52:59] Changing auto extend able on for chunk datadbs01
[2024-10-10 16:53:01] Creating default user for mapping user
[2024-10-10 16:53:02] Moving physical log to plogdbs.
[2024-10-10 16:53:09] Adding 10 logical log file in llogdbs.
[2024-10-10 16:53:20] Moving CURRENT logical log to new logical file.
Your evaluation license will expire on 2025-10-10 00:00:00
Your evaluation license will expire on 2025-10-10 00:00:00
Your evaluation license will expire on 2025-10-10 00:00:00
Your evaluation license will expire on 2025-10-10 00:00:00
Your evaluation license will expire on 2025-10-10 00:00:00
Your evaluation license will expire on 2025-10-10 00:00:00
[2024-10-10 16:53:25] Droping logical log file which in rootdbs.
[2024-10-10 16:53:26] Create database testdb.
[2024-10-10 16:53:28] Optimizing database config.
[2024-10-10 16:53:28] Restart GBase 8s Database Server.
Your evaluation license will expire on 2025-10-10 00:00:00
Your evaluation license will expire on 2025-10-10 00:00:00
Reading configuration file '/opt/gbase/etc/onconfig.gbase01'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 142722 kbytes...succeeded
Creating infos file "/opt/gbase/etc/.infos.gbase01"...succeeded
Linking conf file "/opt/gbase/etc/.conf.gbase01"...succeeded
Initializing rhead structure...rhlock_t 131072 (4096K)... rlock_t (132812K)... Writing to infos file...succeeded
Initialization of Encryption...succeeded
Initializing ASF...succeeded
Initializing Dictionary Cache and SPL Routine Cache...succeeded
Bringing up ADM VP...succeeded
Creating VP classes...succeeded
Forking main_loop thread...succeeded
Initializing DR structures...succeeded
Forking 1 'soctcp' listener threads...succeeded
Forking 1 'soctcp' listener threads...succeeded
Starting tracing...succeeded
Initializing 32 flushers...succeeded
Initializing SDS Server network connections...succeeded
Initializing log/checkpoint information...succeeded
Initializing dbspaces...succeeded
Opening primary chunks...succeeded
Validating chunks...succeeded
Initialize Async Log Flusher...succeeded
Starting B-tree Scanner...succeeded
Init ReadAhead Daemon...succeeded
Init DB Util Daemon...succeeded
Initializing DBSPACETEMP list...succeeded
Init Auto Tuning Daemon...succeeded
Checking database partition index...succeeded
Initializing dataskip structure...succeeded
Checking for temporary tables to drop...succeeded
Updating Global Row Counter...succeeded
Forking onmode_mon thread...succeeded
Creating periodic thread...succeeded
Creating periodic thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
[2024-10-10 16:53:49] Set audit mask.
[2024-10-10 16:53:49] Finish.
--== GBase 8s Information for this install ==--
$GBASEDBTSERVER : gbase01
$GBASEDBTDIR : /opt/gbase
USER HOME : /home/gbase
DBSPACE DIR : /data/gbase
IP ADDRESS : 0.0.0.0
PORT NUMBER : 9088
$DB_LOCALE : zh_CN.utf8
$CLIENT_LOCALE : zh_CN.utf8
JDBC URL : jdbc:gbasedbt-sqli://IPADDR:9088/testdb:GBASEDBTSERVER=gbase01;DB_LOCALE=zh_CN.utf8;CLIENT_LOCALE=zh_CN.utf8;IFX_LOCK_MODE_WAIT=10
JDBC USERNAME : gbasedbt
JDBC PASSWORD : GBase123$%
INNER USERNAME : dbtuser
INNER PASSWORD : GBase123$%
You have mail in /var/spool/mail/root
以上为完整安装过程,在安装日志的最后提供了数据库实例的相关信息,一键安装完成后,查看数据库状态:
[gbasedbt@gbase8s ~]$ onstat -
Your evaluation license will expire on 2025-10-10 00:00:00
On-Line -- Up 00:00:51 -- 3378128 Kbytes
数据库实例状态正常。
关于一键安装脚本的具体使用可以查看 help 帮助,了解每个参数的作用之后,进行自定义配置:
脚本参数说明
Usage:
AutoInit_GBase8s.sh [-d path] [-i path] [-p path] [-s y|n] [-l locale] [-u user] [-o y|n]
[-n servername] [-c num_of_cpu] [-m num_of_memory] [-t type_of_instance]
-d path The path of dbspace.
-i path The path of install software.
-p path The path of home path.
-s y|n Value of dbspace is 1GB? Yes/No, default is N.
-u user The user name for SYSDBA, gbasedbt, default is gbasedbt
-l locale DB_LOCALE/CLIENT_LOCALE/SERVER_LOCALE value.
-o y|n Only install software? Yes/No, default is N.
-n NAME Servername, default is gbase01.
-c NUM Number of CPU use.
-m NUM Number of MB Memory use.
-t TYPE Type of instance will install, [small], if use this, ignore -c and -m.
-a y|n Security need, default N.
-d 指定数据库空间目录,默认为/data/gbase(若该目录非空,则使用INSTALL_DIR/data)
-i 指定数据库软件安装目录INSTALL_DIR,默认为/opt/gbase
-p 指定数据库用户gbasedbt的HOME目录,默认为/home/gbase
-s 数据库空间是否均使用1GB,默认是n(所有数据库空间均使用1GB大小)
-u 指定数据库系统管理员的名称,仅限gbasedbt,可以不指定该参数
-l 指定数据库的DB_LOCALE/CLIENT_LOCALE参数值,默认为zh_CN.utf8
-o 指定仅安装数据库,而不进行初始化操作,默认是n(安装并初始化数据库)
-n 指定数据库服务名称
-c 指定使用的CPU数量
-m 指定使用的内存数量,单位为MB
-t 指定安装的实例类型,当前可接受small
-a 指定是否开启三权分立,默认是n
更多玩法自行模式,这个脚本内容也是开源的,可以自行查看,写的相对有些简陋,但是能看懂大概逻辑就行。
GBase 8s 使用
查看数据库状态
[gbasedbt@gbase8s ~]$ onstat -
Your evaluation license will expire on 2025-10-10 00:00:00
On-Line -- Up 00:12:45 -- 3378128 Kbytes
关闭数据库
[gbasedbt@gbase8s ~]$ onmode -ky
Your evaluation license will expire on 2025-10-10 00:00:00
开启数据库
[gbasedbt@gbase8s ~]$ oninit -vy
Your evaluation license will expire on 2025-10-10 00:00:00
12176
Reading configuration file '/opt/gbase/etc/onconfig.gbase01'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 142722 kbytes...succeeded
Creating infos file "/opt/gbase/etc/.infos.gbase01"...succeeded
Linking conf file "/opt/gbase/etc/.conf.gbase01"...succeeded
Initializing rhead structure...rhlock_t 131072 (4096K)... rlock_t (132812K)... Writing to infos file...succeeded
Initialization of Encryption...succeeded
Initializing ASF...succeeded
Initializing Dictionary Cache and SPL Routine Cache...succeeded
Bringing up ADM VP...succeeded
Creating VP classes...succeeded
Forking main_loop thread...succeeded
Initializing DR structures...succeeded
Forking 1 'soctcp' listener threads...succeeded
Forking 1 'soctcp' listener threads...succeeded
Starting tracing...succeeded
Initializing 32 flushers...succeeded
Initializing SDS Server network connections...succeeded
Initializing log/checkpoint information...succeeded
Initializing dbspaces...succeeded
Opening primary chunks...succeeded
Validating chunks...succeeded
Initialize Async Log Flusher...succeeded
Starting B-tree Scanner...succeeded
Init ReadAhead Daemon...succeeded
Init DB Util Daemon...succeeded
Initializing DBSPACETEMP list...succeeded
Init Auto Tuning Daemon...succeeded
Checking database partition index...succeeded
Initializing dataskip structure...succeeded
Checking for temporary tables to drop...succeeded
Updating Global Row Counter...succeeded
Forking onmode_mon thread...succeeded
Creating periodic thread...succeeded
Creating periodic thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
连接数据库
[gbasedbt@gbase8s ~]$ dbaccess - -
Your evaluation license will expire on 2025-10-10 00:00:00
> create database gbase8s;
Database created.
Elapsed time: 0.751 sec
> create database lucifer;
Database closed.
Database created.
Elapsed time: 0.593 sec
查看数据库 IP、端口
[gbasedbt@gbase8s ~]$ onstat -g ntt
Your evaluation license will expire on 2025-10-10 00:00:00
On-Line -- Up 00:01:13 -- 3378128 Kbytes
global network information:
#netscb connects read write q-free q-limits q-exceed alloc/max
4/ 5 1 13 13 1/ 1 380/ 10 0/ 0 1/ 1
Individual thread network information (times):
netscb thread name sid open read write address
5028fc90 soctcplst 5 17:07:49 0.0.0.0|9089|soctcp
4eb0ebe0 soctcplst 4 17:07:48 17:08:10 0.0.0.0|9088|soctcp
4eb0cbe0 soctcppoll 3 17:07:49
4eb0abe0 soctcppoll 2 17:08:10
数据库常用脚本:
## 查看数据库锁
dbaccess sysmaster - << EOF
select username,sid,waiter,dbsname,tabname,rowidlk,keynum,type
from sysmaster:syslocks a,sysmaster:syssessions b
where b.sid=a.owner and dbsname='lucifer';
EOF
## 查看表空间使用率
dbaccess sysmaster - << EOF
SELECT st.dbsname databasename, st.tabname,
MAX(dbinfo('UTC_TO_DATETIME',sin.ti_created)) createdtime,
SUM( sin.ti_nextns ) extents,
SUM( sin.ti_nrows ) nrows,
MAX( sin.ti_nkeys ) nkeys,
MAX( sin.ti_pagesize ) pagesize,
SUM( sin.ti_nptotal ) nptotal,
round(SUM( sin.ti_nptotal*sd.pagesize )/1024/1024,2)||'MB' total_size,
SUM( sin.ti_npused ) npused,
round(SUM( sin.ti_npused*sd.pagesize )/1024/1024,2)||'MB' used_size,
SUM( sin.ti_npdata ) npdata,
round(SUM( sin.ti_npdata*sd.pagesize )/1024/1024,2)||'MB' data_size
FROM
sysmaster:systabnames st,
sysmaster:sysdbspaces sd,
sysmaster:systabinfo sin
WHERE
sd.dbsnum = trunc(st.partnum / 1048576)
AND st.partnum = sin.ti_partnum
AND st.dbsname NOT IN ('sysmaster','sysuser','sysadmin','sysutils','sysha','syscdr','syscdcv1')
AND st.tabname[1,3] NOT IN ('sys','TBL')
GROUP BY 1, 2
ORDER BY 9 DESC;
EOF
## 查看 dbspace 使用率
dbaccess sysmaster - << EOF
SELECT A.dbsnum as No, trim(B.name) as name,
CASE WHEN (bitval(B.flags,'0x10')>0 AND bitval(B.flags,'0x2')>0)
THEN 'MirroredBlobspace'
WHEN bitval(B.flags,'0x10')>0 THEN 'Blobspace'
WHEN bitval(B.flags,'0x2000')>0 AND bitval(B.flags,'0x8000')>0
THEN 'TempSbspace'
WHEN bitval(B.flags,'0x2000')>0 THEN 'TempDbspace'
WHEN (bitval(B.flags,'0x8000')>0 AND bitval(B.flags,'0x2')>0)
THEN 'MirroredSbspace'
WHEN bitval(B.flags,'0x8000')>0 THEN 'SmartBlobspace'
WHEN bitval(B.flags,'0x2')>0 THEN 'MirroredDbspace'
ELSE 'Dbspace'
END as dbstype,
round(sum(chksize)*2/1024/1024,2)||'GB' as DBS_SIZE ,
round(sum(decode(mdsize,-1,nfree,udfree))*2/1024/1024,2)||'GB' as free_size,
case when sum(decode(mdsize,-1,nfree,udfree))*100/sum(decode(mdsize,-1,chksize,udsize))
>sum(decode(mdsize,-1,nfree,nfree))*100/sum(decode(mdsize,-1,chksize,mdsize))
then TRUNC(100-sum(decode(mdsize,-1,nfree,nfree))*100/sum(decode(mdsize,-1,chksize,mdsize)),2)||"%"
else TRUNC(100-sum(decode(mdsize,-1,nfree,udfree))*100/sum(decode(mdsize,-1,chksize,udsize)),2)||"%"
end as used,
TRUNC(MAX(A.pagesize/1024))||"KB" as pgsize,
MAX(B.nchunks) as nchunks
FROM syschktab A, sysdbstab B
WHERE A.dbsnum = B.dbsnum
GROUP BY A.dbsnum,name, 3
ORDER BY A.dbsnum;
EOF
## 查看数据库信息
dbaccess sysmaster - << EOF
SELECT trim(name) dbname,trim(owner) owner, created||' T' created_time,
TRIM(DBINFO('dbspace',partnum)) AS dbspace,
CASE WHEN is_logging+is_buff_log=1 THEN "Unbuffered logging"
WHEN is_logging+is_buff_log=2 THEN "Buffered logging"
WHEN is_logging+is_buff_log=0 THEN "No logging"
ELSE "" END Logging_mode
FROM sysdatabases
where trim(name) not like 'sys%';
EOF
## 查看实例信息
dbaccess sysmaster - << EOF
select
dbinfo('UTC_TO_DATETIME',sh_boottime)||' T' start_time,
(current year to second - dbinfo('UTC_TO_DATETIME',sh_boottime))||' T' run_time,
sh_maxchunks as maxchunks,
sh_maxdbspaces maxdbspaces,
sh_maxuserthreads maxuserthreads,
sh_maxtrans maxtrans,
sh_maxlocks locks,
sh_longtx longtxs,
dbinfo('UTC_TO_DATETIME',sh_pfclrtime)||' T' onstat_z_running_time
from sysshmvals;
EOF
## 查看字符集
dbaccess sysmaster - << EOF
select * from sysdbslocale where dbs_dbsname='lucifer';
EOF
dbs_dbsname lucifer
dbs_collate zh_CN.57372
GBase 8s 卸载
GBase 8s提供了一个卸载程序,用于卸载 GBase 8s 数据库组件与数据:
[root@gbase8s soft]# cd /opt/GBASE/gbase/uninstall/uninstall_ids/
[root@gbase8s uninstall_ids]# ll uninstallids
-rwxr-xr-x. 1 root root 74206 Oct 10 13:25 uninstallids
图形化卸载
启动卸载程序,开始卸载 GBase 8s:
[root@devsvr uninstall_ids]# ./uninstallids -i swing
选择移除 GBase 8s 数据库组件和全部的数据库:
等待卸载完成:
GBase 8s 数据库卸载成功。
命令行卸载
启动卸载程序,开始卸载 GBase 8s:
[root@gbase8s uninstall_ids]# ./uninstallids
Graphical installers are not supported by the VM. The console mode will be used instead...
Graphical installers are not supported by the VM. The console mode will be used instead...
===============================================================================
GBase Software Bundle (created with InstallAnywhere)
-------------------------------------------------------------------------------
Preparing CONSOLE Mode Uninstallation...
===============================================================================
Uninstall GBase Software Bundle
-------------------------------
About to uninstall GBase Software Bundle.
In this uninstall process, all GBase Software Bundle products in
/opt/GBASE/gbase will be uninstalled.
It is recommended that you first shutdown all database server instances related
to this installation prior to uninstalling the product.
PRESS <ENTER> TO CONTINUE:
===============================================================================
Server Uninstall Options
------------------------
Server action:
Important: Choosing to remove all databases will remove all database chunks,
environment files, registry entries, and message log files for all database
server instances associated with this installation.
->1- Retains all databases, but removes all server binaries
2- Removes server binaries and all databases associated with them
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:: 2
===============================================================================
Uninstalling...
---------------
...*
*
*************************
*************************
*************************
************************
...*
*
*************************
*************************
*************************
************************
...*
*
*************************
*************************
*************************
************************
...*
*
*************************
*************************
*************************
************************
...*
*
*************************
*************************
*************************
************************
...*
*
*************************
*************************
*************************
*************************
===============================================================================
Uninstall Complete
------------------
Uninstall is complete for GBase Software Bundle.
Product uninstall status:
GBase: Successful
GBase 8s数据库卸载成功。
清除残余目录
由于卸载程序在 GBase 8s 的安装目录中,因此卸载程序并没有完成清空安装目录,需要我们手动清除:
[root@gbase8s ~]# rm -rf /opt/GBASE
至此,GBase 8s 彻底卸载完成。
写在最后
安装部署虽简单,但是很多后期运维工作的很多问题,往往都是因为前期数据库部署创建工作没做好才导致,所以在学习一门数据库之前,熟练掌握数据库的安装部署,是一件非常重要的事情。毕竟夯实了地基,”数据库“才能稳固嘛。
参考资料
《安全可靠测评结果公告(2023年第1号)》: http://www.itsec.gov.cn/aqkkcp/cpgg/202312/t20231226_162074.html
[2]《安全可靠测评结果公告(2024年第2号)》: http://www.itsec.gov.cn/aqkkcp/cpgg/202409/t20240930_194299.html
[3]GBase 官网: https://www.gbase.cn/
[4]GBase8sV8.8_TL_3.5.1_3x_x86_64.zip: https://www.gbase.cn/download/gbase-8s-1?category=INSTALL_PACKAGE