GBase 8s 安装与手动创建实例
安装环境说明
GBase 8s是一款典型的事务型数据库,类似于Oracle,MySQL等。这款数据库对安装环境要求不高,完全可以在虚拟机上安装和学习。
推荐学习GBase 8s的硬件安装配置要求:
硬件 | 指标 |
---|---|
CPU | 2核或以上 |
内存 | 2G或以上空闲内存 |
磁盘 | 10G或以上空闲磁盘空间 |
网卡 | 千兆 |
操作系统的安装
我安装的操作系统是CentOS 7.3。在安装时,选择的是开发和创新工作站,安装后,大概有1500多个rpm包。安装后,关闭了SELinux和防火墙。在使用这样的操作系统安装时,可以非常顺利的进行GBase 8s的安装。对于采用最小化安装操作系统的同学,可能需要手动安装jre环境和unzip命令:
安装jre环境和unzip命令,可以使用yum
yum install -y java-1.8.0-openjdk.x86_64
yum install -y unzip-6.0-16.el7.x86_64
使用yum安装软件包时,需要做一些基本的配置,具体方法可以自行在网上查看。
手动安装成功后,可以通过下面的命令确认。
[root@devsvr ~]# java -version
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)
[root@devsvr ~]# which unzip
/usr/bin/unzip
[root@devsvr ~]#
至此,我们就准备好了安装GBase 8s的软件环境。其实说这句话,我还是比较心虚的。GBase 8s 需要下面列出的rpm包,不过这些rpm在使用最小化安装操作系统时,已经全部安装过了。喜欢使用Docker的同学,需要认真检查一下,这些rpm包是不是真的已经安装成功。
audit-libs-2.6.5-3.el7.x86_64
elfutils-libelf-0.166-2.el7.x86_64
expat-2.1.0-8.el7.x86_64
fontconfig-2.10.95-10.el7.x86_64
freetype-2.4.11-12.el7.x86_64
glibc-2.17-157.el7.x86_64
libcap-ng-0.7.5-4.el7.x86_64
libgcc-4.8.5-11.el7.x86_64
libstdc++-4.8.5-11.el7.x86_64
libX11-1.6.3-3.el7.x86_64
libXau-1.0.8-2.1.el7.x86_64
libxcb-1.11-4.el7.x86_64
libXext-1.3.3-3.el7.x86_64
libXrender-0.9.8-2.1.el7.x86_64
ncurses-libs-5.9-13.20130511.el7.x86_64
nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64
pam-1.1.8-18.el7.x86_64
readline-6.2-9.el7.x86_64
zlib-1.2.7-17.el7.x86_64
unzip-6.0-16.el7.x86_64
java-1.8.0-openjdk.x86_64
GBase 8s安装程序需要的命令有很多,都是一些基础的Linux命令,如rm,grep,gzip,cut,md5sum,echo,awk,ls,tar,tr,eval,expr等,我还没有时间认真的统计一下。不过这些命令在操作系统安装时,多数已经安装成功(除了unzip),大家在安装时,基本不会因为这些命令不存在而导致安装失败。
硬件环境检查
GBase 8s的数据库组件安装完成后,大约有500M,但存储物理日志,逻辑日志,智能大对象,临时数据和业务数据都需要使用磁盘存储空间,建议至少有10G以上的磁盘空闲空间。当希望练习一些需要数据量较大的操作时,这一点尤为重要。
我练习用的安装环境,是一台全新安装的VMWare虚拟机,2核CPU,2G内存,千兆网卡,预分配了20G的磁盘空间。
- 查看服务器内存
[root@devsvr ~]# free -m
total used free shared buff/cache available
Mem: 1823 102 1577 8 143 1559
Swap: 2047 0 2047
[root@devsvr ~]#
- 查看可用磁盘空间
[root@devsvr ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 17G 2.7G 15G 16% /
devtmpfs 902M 0 902M 0% /dev
tmpfs 912M 0 912M 0% /dev/shm
tmpfs 912M 8.6M 904M 1% /run
tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14% /boot
tmpfs 183M 0 183M 0% /run/user/0
[root@devsvr ~]#
- 查看网络配置
[root@devsvr ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.3.5 netmask 255.255.255.0 broadcast 192.168.3.255
inet6 fe80::ef8e:8d65:abfc:ddb0 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:b2:06:b8 txqueuelen 1000 (Ethernet)
RX packets 118 bytes 12127 (11.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 107 bytes 15121 (14.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 68 bytes 5524 (5.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5524 (5.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@devsvr ~]#
- 查看操作系统版本
[root@devsvr ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@devsvr ~]#
安装前的准备
创建用户和组
GBase 8s安装,需要一个名称为gbasedbt的用户和组,做为数据库的超级管理员。
[root@devsvr ~]# groupadd gbasedbt
[root@devsvr ~]# useradd -g gbasedbt -d /home/gbasedbt -m -s /bin/bash gbasedbt
上传安装包和解压缩
可以通过ftp或其它第三方工具,将安装包上传到root用户下的一个目录中。
[root@devsvr ~]# ls ./setup
GBase_8s_Express_Edition.tar
[root@devsvr ~]#
创建一个名称为install的目录,将GBase 8s的安装包,解压到该目录中。
[root@devsvr ~]# mkdir install
[root@devsvr ~]# cd install/
[root@devsvr install]# tar xf /root/setup/GBase_8s_Express_Edition.tar
[root@devsvr install]# ll
total 334576
drwxr-xr-x 2 root root 77 Aug 12 21:50 doc
-rwxr-xr-x 1 root root 342515652 Aug 12 21:56 ids_install
-rw-r--r-- 1 root root 1864 Aug 12 21:56 ids.properties
-rwxr-xr-x 1 root root 82738 Aug 12 21:56 onsecurity
[root@devsvr install]#
至此,安装数据库需要的软件包和用户都准备好了。
安装GBase 8s
GBase 8s数据库安装,支持图形界面方式、控制台的命令行方式和静默方式。
我们在root用户下,进入安装包目录,运行安装命令ids_install,即可执行安装。
图形界面安装(需要图形环境支持):
[root@devsvr install]# ./ids_install -i swing
控制台命令行安装:
[root@devsvr install]# ./ids_install
静默安装:
[root@devsvr install]# ./ids_install -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=/opt/gbase
说明:
- 在控制台命令行安装过程中,会显示产品的License,内容较长,可以连续按5次回车。
- 在图形界面方式中,需要用鼠标拉动界面右侧的滚动条到底部,就可以点那个复选框,确认License了。
- 确保安装目录的权限不可以过大(777),建议设置为755。
- 确保安装目录为空。
- 推荐安装路径的最后一级目录由安装程序自己创建。如安装到/opt/gbase下时,可以没有gbase目录,该目录由安装程序创建。
- 在启动安装程序前,请确保gbasedbt用户已经创建。
安装GBase 8s数据库组件
下面通过控制台命令行的方式,演示GBase 8s的安装。
进入安装目录,执行ids_install
命令。
[root@devsvr install]# pwd
/root/install
[root@devsvr install]# ls
doc ids_install ids.properties onsecurity
[root@devsvr install]# ./ids_install
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...
......
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,可以通过连按5次回车键确认。
===============================================================================
License Agreement
-----------------
.....
meaning or has the conflicting views with Chinese original text conflict,
should take the laws and regulations promulgation unit as well as the
GeneralData issue Chinese original text as the standard.
All trademarks and registered trademarks mentioned herein are the property of
their respective owners.
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N):
输入y,按回车。
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): y
===============================================================================
Installation Location
---------------------
Choose location for software installation.
Default Install Folder: /opt/GBASE/gbase
ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
:
安装程序询问软件的安装路径,默认为/opt/GBASE/gbase
,我们需要指定自己的安装目录/opt/gbase
,并输入y,回车确认该目录。
ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
: /opt/gbase
INSTALL FOLDER IS: /opt/gbase
IS THIS CORRECT? (Y/N): y
安装程序提示,选择安装类型,默认为1-典型安装,我们这里使用典型安装,所以直接回车即可。
如果需要自定义安装,则输入2后,再回车。
===============================================================================
Installation or Distribution
----------------------------
Select the installation type.
......
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::
安装程序询问是否在安装时,创建一个数据库实例。安装时创建的实例,不满足我们的学习要求,且由于创建实例时,会根据服务器硬件,配置相关参数。这可能导致创建的实例分配并初始化较大的磁盘空间,耗时较长,因此我们一定要选择2- No - do not create an instance
,记住,一定要选择不创建实例。
===============================================================================
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,回车确认。
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:: 2
===============================================================================
Installation Summary
--------------------
Please review the following before continuing:
Product Name:
GBase Software Bundle
Install Folder:
/opt/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: 560,055,464 Bytes
Available: 14,938,177,536 Bytes
PRESS <ENTER> TO CONTINUE:
回车继续安装
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
PRESS <ENTER> TO INSTALL:
确认安装目录,回车继续安装
===============================================================================
Installing...
-------------
[==================|==================|==================|==================]
[------------------|------------------|------------------|------------------]
===============================================================================
Installation Complete
---------------------
Congratulations! GBase Software Bundle installation is complete.
Product install status:
GBase: Successful
GBase Connect: Successful
Main Version: Express Edition
For more information about using GBase products, see the GBase Information
Center at http://www.gbase.cn.
PRESS <ENTER> TO EXIT THE INSTALLER:
[root@devsvr install]#
安装程序开始安装工作。大概经过1分钟多一点时间,即可完成数据库程序的安装。
安装完成后,回车退出安装程序。记得在显示PRESS <ENTER> TO EXIT THE INSTALLER
时,再次回车。
至此,数据库程序安装完成。
创建数据库实例
之前写过一篇文章《GBase 8s 事务型数据库 安装与卸载》,该文章中采用了$GBASEDBTDIR/etc/GBaseInit_gbasedbt.sh
脚本,创建数据库实例($GBASEDBTDIR为GBase 8s安装目录)。采用该脚本可以极大的简化数据库实例的安装难度,使你可以快速部署一个数据库实例,并使用它。
如果你想更深入的了解GBase 8s数据库,可以学习如果手动安装一个数据库实例。采用这样的方式可能会让你暂时遇到一点点困难,但这项技能很重要,为了掌握这个方法付出努力是值得的。理解如何手动部署实例,让我们后面学习单机多实例部署,基于共享存储的高可用集群部署和多机的同城灾备集群部署更轻松。
手动创建数据库实例步骤:
- 配置环境变量
- 配置sqlhosts
- 配置onconfig
- 初始化数据库实例
- 创建数据库空间
- 将逻辑日志从根数据库空间,迁移到正式的逻辑日志空间。
- 将物理日志从根数据库空间,迁移到正式的物理日志空间。
- 根据创建的数据库空间,更新onconfig
规划数据库空间
在正式开始创建数据库实例前,我们先规划一下我们的数据库。
GBase 8s 中可以创建多种类型的数据库空间
数据库空间类型 | 用途 |
---|---|
根数据库空间 | 用于保存数据库最关键的信息 |
逻辑日志数据库空间 | 用于保存逻辑日志 |
物理日志数据库空间 | 用于保存物理日志 |
大对象数据库空间 | 用于保存二进制大对象 |
智能大对象数据库空间 | 用于保存智能大对象 |
临时数据库空间 | 用于保存临时数据 |
数据数据库空间 | 用于保存业务数据 |
我们规划需要创建的数据库空间如下:
数据库空间名称 | 文件大小(M) | 文件数量 | 页大小(k) | 用途 |
---|---|---|---|---|
rootdbs | 200 | 1 | 2 | 初始化数据库,保存重要信息 |
llogdbs | 500 | 1 | 2 | 保存逻辑日志文件, |
plogdbs | 200 | 1 | 保存物理日志 | |
binspaces | 100 | 2 | 16 | 保存二进制大对象数据 |
sbspaces | 100 | 2 | 保存智能大对象数据 | |
tempdbs1 | 500 | 1 | 16 | 保存临时数据 |
tempdbs2 | 500 | 1 | 16 | 保存临时数据 |
tempdbs3 | 500 | 1 | 16 | 保存临时数据 |
datadbs1 | 200 | 1 | 16 | 保存业务数据 |
datadbs2 | 200 | 1 | 16 | 保存业务数据 |
datadbs3 | 200 | 1 | 16 | 保存业务数据 |
datadbs4 | 200 | 1 | 16 | 保存业务数据 |
datadbs5 | 200 | 1 | 16 | 保存业务数据 |
配置环境变量
在gbasedbt用户的Home目录下,创建一个profile.gbase8s文件,内容如下:
export GBASEDBTSERVER=gbase8s
export GBASEDBTDIR=/opt/gbase
export GBASEDBTSQLHOSTS=/opt/gbase/etc/sqlhosts.gbase8s
export ONCONFIG=onconfig.gbase8s
export PATH=/opt/gbase/bin:$PATH
export DB_LOCALE=zh_CN.utf8
export CLIENT_LOCALE=zh_CN.utf8
unset GL_USEGLU
export PATH=$GBASEDBTDIR/bin:$GBASEDBTDIR/sbin:$PATH
其中GBASEDBTSQLHOSTS
指定的sqlhosts文件的路径和名称,GBASEDBTSERVER
指定了数据库实例的名称,ONCONFIG
指定了配置参数文件名称。
运行source命令,使环境变量生效。
[gbasedbt@devsvr ~]$ source profile.gbase8s
[gbasedbt@devsvr ~]$ env | grep GBASE
GBASEDBTSQLHOSTS=/opt/gbase/etc/sqlhosts.gbase8s
GBASEDBTSERVER=gbase8s
GBASEDBTDIR=/opt/gbase
[gbasedbt@devsvr ~]$
通过env命令查看,配置的环境变量已经生效。
配置sqlhosts
参考环境变量中设置的$GBASEDBTSERVER
与$GBASEDBTSQLHOSTS
,生成sqlhosts的配置文件。
[gbasedbt@devsvr ~]$ touch /opt/gbase/etc/sqlhosts.gbase8s
[gbasedbt@devsvr ~]$ vi /opt/gbase/etc/sqlhosts.gbase8s
[gbasedbt@devsvr ~]$ cat /opt/gbase/etc/sqlhosts.gbase8s
gbase8s onsoctcp 192.168.3.5 9088
[gbasedbt@devsvr ~]$
sqlhosts文件配置信息的第一部分,指定了数据库实例名称,第二部分指定了通讯协议,第三部分指定了服务器监听的IP地址,第四部分指定了服务器监听的端口号。
配置onconfig
onconfig文件的配置,是手动创建实例中比较关键的步骤。我们可以复制一个标准onconfig模板内容,经过适当的修改,做为我们的onconfig。
根据环境变量配置的$ONCONFIG
值,我们在$GBASEDBTDIR/etc
目录下,创建名称为$ONCONFIG
值的文件,即配置参数文件为/opt/gbase/etc/onconfig.gbase8s
。
通过标准配置文件,复制数据库实例的配置文件。
[gbasedbt@devsvr etc]$ pwd
/opt/gbase/etc
[gbasedbt@devsvr etc]$ ls onconfig.std
onconfig.std
[gbasedbt@devsvr etc]$ cp onconfig.std onconfig.gbase8s
[gbasedbt@devsvr etc]$ ls onconfig.*
onconfig.gbase8s onconfig.std
[gbasedbt@devsvr etc]$
数据库实例关键参数信息标准文件默认值
参数名称 | 参数值 |
---|---|
ROOTNAME | rootdbs |
ROOTPATH | $GBASEDBTDIR/tmp/demo_on.rootdbs |
ROOTOFFSET | 0 |
ROOTSIZE | 300000 |
PHYSFILE | 50000 |
PLOG_OVERFLOW_PATH | $GBASEDBTDIR/tmp |
PHYSBUFF | 128 |
LOGFILES | 6 |
LOGSIZE | 10000 |
DYNAMIC_LOGS | 2 |
LOGBUFF | 64 |
SERVERNUM | 0 |
DBSERVERNAME | |
MSGPATH | $GBASEDBTDIR/tmp/online.log |
TAPEDEV | /dev/tapedev |
TAPEBLK | 32 |
TAPESIZE | 0 |
LTAPEDEV | /dev/tapedev |
LTAPEBLK | 32 |
LTAPESIZE | 0 |
我们手动创建数据库实例,第一次初始化时,只有根数据库空间,因此物理日志,逻辑日志也全部在根数据库空间中。因此我们需要正确配置物理日志和逻辑日志的大小,保证 PHYSFILE + LOGFILES * LOGSIZE < ROOTSIZE
。
修改部分配置参数如下:
参数名称 | 参数值 |
---|---|
ROOTNAME | rootdbs |
ROOTPATH | $GBASEDBTDIR/gbase8s_dbs/rootdbs.dbf |
ROOTOFFSET | 0 |
ROOTSIZE | 204800 |
PHYSFILE | 50000 |
PLOG_OVERFLOW_PATH | $GBASEDBTDIR/tmp |
PHYSBUFF | 2048 |
LOGFILES | 3 |
LOGSIZE | 10000 |
DYNAMIC_LOGS | 2 |
LOGBUFF | 1024 |
SERVERNUM | 1 |
DBSERVERNAME | gbase8s |
MSGPATH | $GBASEDBTDIR/tmp/online.log |
TAPEDEV | /dev/null |
TAPEBLK | 32 |
TAPESIZE | 0 |
LTAPEDEV | /dev/null |
LTAPEBLK | 32 |
LTAPESIZE | 0 |
至此,我们有了一个基本的配置参数。
初始化实例
在初始化实例前,需要保证rootdbs对应的文件已经存在,并有正确的访问权限(一般为660)。我们首先创建一个空的root数据库空间文件。
[gbasedbt@devsvr ~]$ mkdir -p $GBASEDBTDIR/gbase8s_dbs
[gbasedbt@devsvr ~]$ touch $GBASEDBTDIR/gbase8s_dbs/rootdbs.dbf
[gbasedbt@devsvr ~]$ chmod 660 $GBASEDBTDIR/gbase8s_dbs/rootdbs.dbf
现在,我们可以通过gserver init
命令初始化数据库实例。
[gbasedbt@devsvr ~]$ gserver init
Your evaluation license will expire on 2022-10-14 00:00:00
Reading configuration file '/opt/gbase/etc/onconfig.gbase8s'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 11030 kbytes...succeeded
Creating infos file "/opt/gbase/etc/.infos.gbase8s"...succeeded
Linking conf file "/opt/gbase/etc/.conf.gbase8s"...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@devsvr ~]$
可以通过gstat
查看数据库实例当前状态。
[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:05:40 -- 179452 Kbytes
[gbasedbt@devsvr ~]$
当前的数据库实例显示为On-Line
,至此,一个简单的数据库实例已经创建成功。
添加表空间
只有root数据库空间的实例,无法应用于生产环境的部署。我们可以根据生产环境实际要求,创建适合自己需要的多个数据库空间。GBase 8s提供了gspaces
命令,用于数据库空间的创建。
语法格式:
[gbasedbt@devsvr ~]$ gspaces
Usage:
gspaces { -a <spacename> -p <path> -o <offset> -s <size> [-m <path> <offset>]
{ { [-Mo <mdoffset>] [-Ms <mdsize>] } | -U }
} |
{ -c { -d <DBspace> [-k <pagesize>] [-t]
-p <path> -o <offset> -s <size> [-m <path> <offset>] } |
{ -d <DBspace> [-k <pagesize>]
-p <path> -o <offset> -s <size> [-m <path> <offset>]
[-ef <first_extent_size>] [-en <next_extent_size>] } |
{ -P <PLOGspace>
-p <path> -o <offset> -s <size> [-m <path> <offset>] } |
{ -b <BLOBspace> -g <pagesize>
-p <path> -o <offset> -s <size> [-m <path> <offset>] } |
{ -S <SBLOBspace> [-t]
-p <path> -o <offset> -s <size> [-m <path> <offset>]
[-Mo <mdoffset>] [-Ms <mdsize>] [-Df <default-list>] } |
{ -x <Extspace> -l <Location> } } |
{ -d <spacename> [-p <path> -o <offset>] [-f] [-y] } |
{ -f[y] off [<DBspace-list>] | on [<DBspace-list>] } |
{ -m <spacename> {-p <path> -o <offset> -m <path> <offset> [-y] |
-f <filename>} } |
{ -r <spacename> [-y] } |
{ -s <spacename> -p <path> -o <offset> {-O | -D} [-y] } |
{ -ch <sbspacename> -Df <default-list> } |
{ -cl <sbspacename> } |
{ -ren <spacename> -n <newname> }
-a - Add a chunk to a DBspace, BLOBspace or SBLOBspace
-c - Create a DBspace, PLOGspace, BLOBspace, SBLOBspace, or Extspace
-d - Drop an empty DBspace, PLOGspace, BLOBspace, SBLOBspace, Extspace,
or chunk
-f - Change dataskip default for specified DBspaces
-m - Add mirroring to an existing DBspace, PLOGspace, BLOBspace or
SBLOBspace
-r - Turn mirroring off for a DBspace, PLOGspace, BLOBspace or SBLOBspace
-s - Change the status of a chunk
-ch - Change default list for smart large object space
-cl - garbage collect smart large objects that are not referenced
default-list = {[LOGGING = {ON|OFF}] [,ACCESSTIME = {ON|OFF}]
[,AVG_LO_SIZE = {1 - 2097152}] }
-ren - Rename a DBspace, BLOBspace, SBLOBspace or Extspace
[gbasedbt@devsvr ~]$
说明:
在使用gspaces
创建数据库空间前,需要先创建一个空文件,并设置好对应的权限(660)。
创建逻辑日志数据库空间
创建数据库空间语法
touch /opt/gbase/gbase8s_dbs/llogdbs.dbf
chmod 660 /opt/gbase/gbase8s_dbs/llogdbs.dbf
gspaces -c -d llogdbs -p /opt/gbase/gbase8s_dbs/llogdbs.dbf -o 0 -s 512000
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/llogdbs.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/llogdbs.dbf
[gbasedbt@devsvr ~]$ gspaces -c -d llogdbs -p /opt/gbase/gbase8s_dbs/llogdbs.dbf -o 0 -s 512000
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@devsvr ~]$
创建物理日志数据库空间
创建物理日志数据库空间语法(注意使用-P指定数据库空间名称)
touch /opt/gbase/gbase8s_dbs/plogdbs.dbf
chmod 660 /opt/gbase/gbase8s_dbs/plogdbs.dbf
gspaces -c -P plogdbs -p /opt/gbase/gbase8s_dbs/plogdbs.dbf -o 0 -s 204800
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/plogdbs.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/plogdbs.dbf
[gbasedbt@devsvr ~]$ gspaces -c -P plogdbs -p /opt/gbase/gbase8s_dbs/plogdbs.dbf -o 0 -s 204800
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@devsvr ~]$
创建临时数据库空间
创建临时数据库空间语法(注意创建临时数据库空间需要指定参数-t,使用-k参数指定页大小)
touch /opt/gbase/gbase8s_dbs/tempdbs1.dbf
touch /opt/gbase/gbase8s_dbs/tempdbs2.dbf
touch /opt/gbase/gbase8s_dbs/tempdbs3.dbf
chmod 660 /opt/gbase/gbase8s_dbs/tempdbs*.dbf
gspaces -c -d tempdbs1 -k 16 -t -p /opt/gbase/gbase8s_dbs/tempdbs1.dbf -o 0 -s 512000
gspaces -c -d tempdbs2 -k 16 -t -p /opt/gbase/gbase8s_dbs/tempdbs2.dbf -o 0 -s 512000
gspaces -c -d tempdbs3 -k 16 -t -p /opt/gbase/gbase8s_dbs/tempdbs3.dbf -o 0 -s 512000
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/tempdbs1.dbf
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/tempdbs2.dbf
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/tempdbs3.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/tempdbs*.dbf
[gbasedbt@devsvr ~]$ gspaces -c -d tempdbs1 -k 16 -t -p /opt/gbase/gbase8s_dbs/tempdbs1.dbf -o 0 -s 512000
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
[gbasedbt@devsvr ~]$ gspaces -c -d tempdbs2 -k 16 -t -p /opt/gbase/gbase8s_dbs/tempdbs2.dbf -o 0 -s 512000
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
[gbasedbt@devsvr ~]$ gspaces -c -d tempdbs3 -k 16 -t -p /opt/gbase/gbase8s_dbs/tempdbs3.dbf -o 0 -s 512000
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
[gbasedbt@devsvr ~]$
创建二进制大对象数据库空间
创建二进制大对象数据库空间语法(注意使用-g参数指定页大小)
touch /opt/gbase/gbase8s_dbs/binspaces_1.dbf
chmod 660 /opt/gbase/gbase8s_dbs/binspaces_1.dbf
gspaces -c -b binspaces -g 16 -p /opt/gbase/gbase8s_dbs/binspaces_1.dbf -o 0 -s 102400
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/binspaces_1.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/binspaces_1.dbf
[gbasedbt@devsvr ~]$ gspaces -c -b binspaces -g 16 -p /opt/gbase/gbase8s_dbs/binspaces_1.dbf -o 0 -s 102400
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@devsvr ~]$
为二进制大对象数据库空间添加新的存储文件语法。
touch /opt/gbase/gbase8s_dbs/binspaces_2.dbf
chmod 660 /opt/gbase/gbase8s_dbs/binspaces_2.dbf
gspaces -a binspaces -p /opt/gbase/gbase8s_dbs/binspaces_2.dbf -o 0 -s 102400
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/binspaces_2.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/binspaces_2.dbf
[gbasedbt@devsvr ~]$ gspaces -a binspaces -p /opt/gbase/gbase8s_dbs/binspaces_2.dbf -o 0 -s 102400
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Chunk successfully added.
[gbasedbt@devsvr ~]$
查看已经添加的数据库空间信息。
[gbasedbt@devsvr ~]$ gstat -d
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:39:46 -- 341912 Kbytes
Dbspaces
address number flags fchunk nchunks pgsize flags owner name
45641028 1 0x70001 1 1 2048 N BA gbasedbt rootdbs
4e2b9028 2 0x60001 2 1 2048 N BA gbasedbt llogdbs
4def45b0 3 0x1070001 3 1 2048 N PBA gbasedbt plogdbs
46a80dd0 4 0x42001 4 1 16384 N TBA gbasedbt tempdbs1
4d896570 5 0x42001 5 1 16384 N TBA gbasedbt tempdbs2
4d80ddd0 6 0x42001 6 1 16384 N TBA gbasedbt tempdbs3
4da275b0 7 0x60011 7 2 32768 N BBA gbasedbt binspaces
7 active, 2047 maximum
Note: For BLOB chunks, the number of free pages shown is out of date.
Run 'onstat -d update' for current stats.
Chunks
address chunk/dbs offset size free bpages flags pathname
45641258 1 1 0 102400 76508 PO-B-- /opt/gbase/gbase8s_dbs/rootdbs.dbf
4e2b9258 2 2 0 256000 255947 PO-B-- /opt/gbase/gbase8s_dbs/llogdbs.dbf
4df1e028 3 3 0 102400 0 PO-BE- /opt/gbase/gbase8s_dbs/plogdbs.dbf
4deeb028 4 4 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs1.dbf
4d76e028 5 5 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs2.dbf
4dad2028 6 6 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs3.dbf
4de69028 7 7 0 51200 ~3200 3200 POBB-- /opt/gbase/gbase8s_dbs/binspaces_1.dbf
4d8c9028 8 7 0 51200 ~3200 3200 POBB-- /opt/gbase/gbase8s_dbs/binspaces_2.dbf
8 active, 32766 maximum
NOTE: The values in the "size" and "free" columns for DBspace chunks are
displayed in terms of "pgsize" of the DBspace to which they belong.
Expanded chunk capacity mode: always
[gbasedbt@devsvr ~]$
创建智能大对象数据库空间
创建智能大对象数据库空间语法
touch /opt/gbase/gbase8s_dbs/sbspaces_1.dbf
chmod 660 /opt/gbase/gbase8s_dbs/sbspaces_1.dbf
gspaces -c -S sbspaces -p /opt/gbase/gbase8s_dbs/sbspaces_1.dbf -o 0 -s 102400
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/sbspaces_1.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/sbspaces_1.dbf
[gbasedbt@devsvr ~]$ gspaces -c -S sbspaces -p /opt/gbase/gbase8s_dbs/sbspaces_1.dbf -o 0 -s 102400
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
为智能大对象添加新的存储文件语法
touch /opt/gbase/gbase8s_dbs/sbspaces_2.dbf
chmod 660 /opt/gbase/gbase8s_dbs/sbspaces_2.dbf
gspaces -a sbspaces -p /opt/gbase/gbase8s_dbs/sbspaces_2.dbf -o 0 -s 102400
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/sbspaces_2.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/sbspaces_2.dbf
[gbasedbt@devsvr ~]$ gspaces -a sbspaces -p /opt/gbase/gbase8s_dbs/sbspaces_2.dbf -o 0 -s 102400
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Chunk successfully added.
[gbasedbt@devsvr ~]$
查看已经添加的数据库空间信息。
[gbasedbt@devsvr ~]$ gstat -d
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 13:11:58 -- 341912 Kbytes
Dbspaces
address number flags fchunk nchunks pgsize flags owner name
45641028 1 0x70001 1 1 2048 N BA gbasedbt rootdbs
4e2b9028 2 0x60001 2 1 2048 N BA gbasedbt llogdbs
4def45b0 3 0x1070001 3 1 2048 N PBA gbasedbt plogdbs
46a80dd0 4 0x42001 4 1 16384 N TBA gbasedbt tempdbs1
4d896570 5 0x42001 5 1 16384 N TBA gbasedbt tempdbs2
4d80ddd0 6 0x42001 6 1 16384 N TBA gbasedbt tempdbs3
4da275b0 7 0x60011 7 2 32768 N BBA gbasedbt binspaces
4d9efdd0 8 0x68001 9 2 2048 N SBA gbasedbt sbspaces
8 active, 2047 maximum
Note: For BLOB chunks, the number of free pages shown is out of date.
Run 'onstat -d update' for current stats.
Chunks
address chunk/dbs offset size free bpages flags pathname
45641258 1 1 0 102400 76494 PO-B-- /opt/gbase/gbase8s_dbs/rootdbs.dbf
4e2b9258 2 2 0 256000 255947 PO-B-- /opt/gbase/gbase8s_dbs/llogdbs.dbf
4df1e028 3 3 0 102400 0 PO-BE- /opt/gbase/gbase8s_dbs/plogdbs.dbf
4deeb028 4 4 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs1.dbf
4d76e028 5 5 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs2.dbf
4dad2028 6 6 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs3.dbf
4de69028 7 7 0 51200 ~3199 3200 POBB-- /opt/gbase/gbase8s_dbs/binspaces_1.dbf
4d8c9028 8 7 0 51200 ~3199 3200 POBB-- /opt/gbase/gbase8s_dbs/binspaces_2.dbf
4e251028 9 8 0 51200 47678 47678 POSB-- /opt/gbase/gbase8s_dbs/sbspaces_1.dbf
Metadata 3469 1700 3469
4e2f1028 10 8 0 51200 47725 47725 POSB-- /opt/gbase/gbase8s_dbs/sbspaces_2.dbf
Metadata 3472 3472 3472
10 active, 32766 maximum
NOTE: The values in the "size" and "free" columns for DBspace chunks are
displayed in terms of "pgsize" of the DBspace to which they belong.
Expanded chunk capacity mode: always
[gbasedbt@devsvr ~]$
创建业务数据数据库空间
创建业务数据的数据库空间语法
touch /opt/gbase/gbase8s_dbs/datadbs1_1.dbf
chmod 660 /opt/gbase/gbase8s_dbs/datadbs1_1.dbf
gspaces -c -d datadbs1 -p /opt/gbase/gbase8s_dbs/datadbs1_1.dbf -o 0 -s 204800
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/datadbs1_1.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/datadbs1_1.dbf
[gbasedbt@devsvr ~]$ gspaces -c -d datadbs1 -p /opt/gbase/gbase8s_dbs/datadbs1_1.dbf -o 0 -s 204800
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@devsvr ~]$
创建业务数据的数据库空间语法
touch /opt/gbase/gbase8s_dbs/datadbs2_1.dbf
chmod 660 /opt/gbase/gbase8s_dbs/datadbs2_1.dbf
gspaces -c -d datadbs2 -p /opt/gbase/gbase8s_dbs/datadbs2_1.dbf -o 0 -s 204800
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/datadbs2_1.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/datadbs2_1.dbf
[gbasedbt@devsvr ~]$ gspaces -c -d datadbs2 -p /opt/gbase/gbase8s_dbs/datadbs2_1.dbf -o 0 -s 204800
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@devsvr ~]$
创建业务数据的数据库空间语法
touch /opt/gbase/gbase8s_dbs/datadbs3_1.dbf
chmod 660 /opt/gbase/gbase8s_dbs/datadbs3_1.dbf
gspaces -c -d datadbs3 -p /opt/gbase/gbase8s_dbs/datadbs3_1.dbf -o 0 -s 204800
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/datadbs3_1.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/datadbs3_1.dbf
[gbasedbt@devsvr ~]$ gspaces -c -d datadbs3 -p /opt/gbase/gbase8s_dbs/datadbs3_1.dbf -o 0 -s 204800
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@devsvr ~]$
创建业务数据的数据库空间语法
touch /opt/gbase/gbase8s_dbs/datadbs4_1.dbf
chmod 660 /opt/gbase/gbase8s_dbs/datadbs4_1.dbf
gspaces -c -d datadbs4 -p /opt/gbase/gbase8s_dbs/datadbs4_1.dbf -o 0 -s 204800
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/datadbs4_1.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/datadbs4_1.dbf
[gbasedbt@devsvr ~]$ gspaces -c -d datadbs4 -p /opt/gbase/gbase8s_dbs/datadbs4_1.dbf -o 0 -s 204800
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@devsvr ~]$
创建业务数据的数据库空间语法
touch /opt/gbase/gbase8s_dbs/datadbs5_1.dbf
chmod 660 /opt/gbase/gbase8s_dbs/datadbs5_1.dbf
gspaces -c -d datadbs5 -p /opt/gbase/gbase8s_dbs/datadbs5_1.dbf -o 0 -s 204800
创建演示
[gbasedbt@devsvr ~]$ touch /opt/gbase/gbase8s_dbs/datadbs5_1.dbf
[gbasedbt@devsvr ~]$ chmod 660 /opt/gbase/gbase8s_dbs/datadbs5_1.dbf
[gbasedbt@devsvr ~]$ gspaces -c -d datadbs5 -p /opt/gbase/gbase8s_dbs/datadbs5_1.dbf -o 0 -s 204800
Your evaluation license will expire on 2022-10-14 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
[gbasedbt@devsvr ~]$
查看已经添加的数据库空间信息。
[gbasedbt@devsvr ~]$ gstat -d
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 13:23:02 -- 341912 Kbytes
Dbspaces
address number flags fchunk nchunks pgsize flags owner name
45641028 1 0x70001 1 1 2048 N BA gbasedbt rootdbs
4e2b9028 2 0x60001 2 1 2048 N BA gbasedbt llogdbs
4def45b0 3 0x1070001 3 1 2048 N PBA gbasedbt plogdbs
46a80dd0 4 0x42001 4 1 16384 N TBA gbasedbt tempdbs1
4d896570 5 0x42001 5 1 16384 N TBA gbasedbt tempdbs2
4d80ddd0 6 0x42001 6 1 16384 N TBA gbasedbt tempdbs3
4da275b0 7 0x60011 7 2 32768 N BBA gbasedbt binspaces
4d9efdd0 8 0x68001 9 2 2048 N SBA gbasedbt sbspaces
4e2b9dc0 9 0x60001 11 1 2048 N BA gbasedbt datadbs1
4e61c560 10 0x60001 12 1 2048 N BA gbasedbt datadbs2
4d88ada0 11 0x60001 13 1 2048 N BA gbasedbt datadbs3
4e16b570 12 0x60001 14 1 2048 N BA gbasedbt datadbs4
4d989d78 13 0x60001 15 1 2048 N BA gbasedbt datadbs5
13 active, 2047 maximum
Note: For BLOB chunks, the number of free pages shown is out of date.
Run 'onstat -d update' for current stats.
Chunks
address chunk/dbs offset size free bpages flags pathname
45641258 1 1 0 102400 76490 PO-B-- /opt/gbase/gbase8s_dbs/rootdbs.dbf
4e2b9258 2 2 0 256000 255947 PO-B-- /opt/gbase/gbase8s_dbs/llogdbs.dbf
4df1e028 3 3 0 102400 0 PO-BE- /opt/gbase/gbase8s_dbs/plogdbs.dbf
4deeb028 4 4 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs1.dbf
4d76e028 5 5 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs2.dbf
4dad2028 6 6 0 32000 31947 PO-B-- /opt/gbase/gbase8s_dbs/tempdbs3.dbf
4de69028 7 7 0 51200 ~3199 3200 POBB-- /opt/gbase/gbase8s_dbs/binspaces_1.dbf
4d8c9028 8 7 0 51200 ~3199 3200 POBB-- /opt/gbase/gbase8s_dbs/binspaces_2.dbf
4e251028 9 8 0 51200 47678 47678 POSB-- /opt/gbase/gbase8s_dbs/sbspaces_1.dbf
Metadata 3469 1700 3469
4e2f1028 10 8 0 51200 47725 47725 POSB-- /opt/gbase/gbase8s_dbs/sbspaces_2.dbf
Metadata 3472 3472 3472
4e50d028 11 9 0 102400 102347 PO-B-- /opt/gbase/gbase8s_dbs/datadbs1_1.dbf
4df73028 12 10 0 102400 102347 PO-B-- /opt/gbase/gbase8s_dbs/datadbs2_1.dbf
4e33e028 13 11 0 102400 102347 PO-B-- /opt/gbase/gbase8s_dbs/datadbs3_1.dbf
4df65028 14 12 0 102400 102347 PO-B-- /opt/gbase/gbase8s_dbs/datadbs4_1.dbf
4e56b028 15 13 0 102400 102347 PO-B-- /opt/gbase/gbase8s_dbs/datadbs5_1.dbf
15 active, 32766 maximum
NOTE: The values in the "size" and "free" columns for DBspace chunks are
displayed in terms of "pgsize" of the DBspace to which they belong.
Expanded chunk capacity mode: always
[gbasedbt@devsvr ~]$
迁移逻辑日志
数据库在第一次初始化时,将逻辑日志和物理日志全部保存在根数据库空间中。我们需要将逻辑日志和物理日志迁移到对应的数据库空间中。
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 14:21:55 -- 341912 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 0 1024 930 43 21.63
phybegin physize phypos phyused %used
3:53 102347 360 12 0.01
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-2 0 512 185602 15407 3697 12.0 4.2
Subsystem numrecs Log Space used
OLDRSAM 185260 26490240
SBLOB 10 504
HA 41 1804
DDL 291 101268
address number flags uniqid begin size used %used
45572f30 1 U---C-L 4 1:25263 5000 407 8.14
45572f98 2 U-B---- 2 1:30263 5000 5000 100.00
45641f30 3 U-B---- 3 1:35263 5000 5000 100.00
3 active, 3 total
[gbasedbt@devsvr ~]$
我们可以使用glogadmin
命令,将逻辑日志和物理日志进行迁移,该命令的语法如下:
[gbasedbt@devsvr ~]$ glogadmin
Usage: glogadmin { -a -d <DBspace> [-s <size>] [-i] } |
{ -b -g <pagesize> [-n <number of buffers>]
[-r <number of LRUs>] [-x <maxdirty>] [-m <mindirty>] } |
{ -d -l <log file number> [-y] } |
{ -p -s <size> [-d <DBspace>] [-y] }
-a - Add a logical log file
-b - Add a buffer pool
-i - Insert after current log
-d - Drop a logical log file
-p - Change physical log size and location
-y - Automatically responds "yes" to all prompts
[gbasedbt@devsvr ~]$
在前面的操作中,我们创建了逻辑日志的数据库空间,我们需要在逻辑日志的数据库空间中创建对应的多个逻辑日志文件,来保存逻辑日志。使用下面的命令创建一个新的逻辑日志文件。
glogadmin -a -d llogdbs -s 51200
下面的演示,创建9个新的逻辑日志文件。在创建第10个逻辑日志文件时,因数据库空间不足而失败。
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[gbasedbt@devsvr ~]$ glogadmin -a -d llogdbs -s 51200
Your evaluation license will expire on 2022-10-14 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Cannot add a logical log.
ISAM error: DBSpace is full.
查看已经创建的逻辑日志文件。
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 14:30:30 -- 341912 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 16 1024 1000 53 18.87
phybegin physize phypos phyused %used
3:53 102347 430 16 0.02
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-3 0 512 185718 15444 3734 12.0 4.1
Subsystem numrecs Log Space used
OLDRSAM 185366 26499812
SBLOB 10 504
HA 51 2244
DDL 291 101268
address number flags uniqid begin size used %used
45572f30 1 U---C-L 4 1:25263 5000 444 8.88
45572f98 2 U-B---- 2 1:30263 5000 5000 100.00
45641f30 3 U-B---- 3 1:35263 5000 5000 100.00
4e1cd628 4 A------ 0 2:53 25600 0 0.00
4e1cd6f0 5 A------ 0 2:25653 25600 0 0.00
4e1cd7b0 6 A------ 0 2:51253 25600 0 0.00
4e1cd878 7 A------ 0 2:76853 25600 0 0.00
4e1cd948 8 A------ 0 2:102453 25600 0 0.00
4e1cd8e0 9 A------ 0 2:128053 25600 0 0.00
4e1cd9b0 10 A------ 0 2:153653 25600 0 0.00
4e1cda20 11 A------ 0 2:179253 25600 0 0.00
4e1cda98 12 A------ 0 2:204853 25600 0 0.00
12 active, 12 total
[gbasedbt@devsvr ~]$
由于数据库实例在初始化时,默认创建了3个逻辑日志文件。这3个逻辑日志文件较小,且保存在根数据库空间中,我们需要弃用这3个逻辑日志文件。
由于当前的逻辑日志文件刚好在第一个逻辑日志文件中,我们需要将当前逻辑日志文件移动到新逻辑日志数据库空间中的逻辑日志文件中。我们执行gadmin -l
,进行逻辑日志切换。执行3次逻辑日志切换后,观察当前的逻辑日志文件。
[gbasedbt@devsvr ~]$ gadmin -l
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$ gadmin -l
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$ gadmin -l
Your evaluation license will expire on 2022-10-14 00:00:00
^[[A[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 14:34:06 -- 341912 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 15 1024 1028 55 18.69
phybegin physize phypos phyused %used
3:53 102347 458 27 0.03
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-2 0 512 185784 15461 3751 12.0 4.1
Subsystem numrecs Log Space used
OLDRSAM 185431 26506640
SBLOB 10 504
HA 52 2288
DDL 291 101268
address number flags uniqid begin size used %used
45572f30 1 U-B---- 4 1:25263 5000 445 8.90
45572f98 2 U-B---L 5 1:30263 5000 7 0.14
45641f30 3 U-B---- 6 1:35263 5000 5 0.10
4e1cd628 4 U---C-- 7 2:53 25600 4 0.02
4e1cd6f0 5 A------ 0 2:25653 25600 0 0.00
4e1cd7b0 6 A------ 0 2:51253 25600 0 0.00
4e1cd878 7 A------ 0 2:76853 25600 0 0.00
4e1cd948 8 A------ 0 2:102453 25600 0 0.00
4e1cd8e0 9 A------ 0 2:128053 25600 0 0.00
4e1cd9b0 10 A------ 0 2:153653 25600 0 0.00
4e1cda20 11 A------ 0 2:179253 25600 0 0.00
4e1cda98 12 A------ 0 2:204853 25600 0 0.00
12 active, 12 total
[gbasedbt@devsvr ~]$
对于保存在根数据库空间中的逻辑日志文件,不是我们希望使用的,我们需要删除这3个逻辑日志文件。可以使用glogadmin -d -l <n>
删除对应的逻辑日志文件。
[gbasedbt@devsvr ~]$ glogadmin -d -l 1
Your evaluation license will expire on 2022-10-14 00:00:00
WARNING: Dropping a logical log file.
Do you really want to continue? (y/n)y
Logical log 1 successfully dropped.
[gbasedbt@devsvr ~]$ glogadmin -d -l 2
Your evaluation license will expire on 2022-10-14 00:00:00
WARNING: Dropping a logical log file.
Do you really want to continue? (y/n)y
Logical log 2 successfully dropped.
[gbasedbt@devsvr ~]$ glogadmin -d -l 3
Your evaluation license will expire on 2022-10-14 00:00:00
WARNING: Dropping a logical log file.
Do you really want to continue? (y/n)y
Logical log 3 successfully dropped.
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 14:35:43 -- 341912 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 16 1024 1070 59 18.14
phybegin physize phypos phyused %used
3:53 102347 500 16 0.02
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-1 0 512 185826 15475 3765 12.0 4.1
Subsystem numrecs Log Space used
OLDRSAM 185470 26510268
SBLOB 10 504
HA 55 2420
DDL 291 101268
address number flags uniqid begin size used %used
4e1cd628 4 U---C-- 7 2:53 25600 4 0.02
4e1cd6f0 5 A------ 0 2:25653 25600 0 0.00
4e1cd7b0 6 A------ 0 2:51253 25600 0 0.00
4e1cd878 7 A------ 0 2:76853 25600 0 0.00
4e1cd948 8 A------ 0 2:102453 25600 0 0.00
4e1cd8e0 9 A------ 0 2:128053 25600 0 0.00
4e1cd9b0 10 A------ 0 2:153653 25600 0 0.00
4e1cda20 11 A------ 0 2:179253 25600 0 0.00
4e1cda98 12 A------ 0 2:204853 25600 0 0.00
9 active, 9 total
[gbasedbt@devsvr ~]$
至此,逻辑日志迁移成功。
迁移物理日志
使用下面的语法,进行物理日志的迁移。
glogadmin -p -s 204800 -d plogdbs
物理日志迁移演示
[gbasedbt@devsvr ~]$ glogadmin -p -s 204800 -d plogdbs
Your evaluation license will expire on 2022-10-14 00:00:00
Do you really want to change the physical log? (y/n)y
Log operation started. To monitor progress, use the onstat -l command.
** WARNING ** Because the physical log has been modified, a level 0 archive
must be taken of the following space before an incremental archive will be
permitted for it: plogdbs
(see Database Server Administrator's manual)
[gbasedbt@devsvr ~]$
查看物理日志状态信息
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 14:50:33 -- 341912 Kbytes
Physical Logging
Buffer bufused bufsize numpages numwrits pages/io
P-2 8 1024 1138 65 17.51
phybegin physize phypos phyused %used
3:102400 102400 0 8 0.01
Logical Logging
Buffer bufused bufsize numrecs numpages numwrits recs/pages pages/io
L-2 0 512 185884 15493 3781 12.0 4.1
Subsystem numrecs Log Space used
OLDRSAM 185523 26519816
SBLOB 10 504
HA 60 2640
DDL 291 101268
address number flags uniqid begin size used %used
4e1cd628 4 U-B---- 7 2:53 25600 14 0.05
4e1cd6f0 5 U---C-L 8 2:25653 25600 22 0.09
4e1cd7b0 6 A------ 0 2:51253 25600 0 0.00
4e1cd878 7 A------ 0 2:76853 25600 0 0.00
4e1cd948 8 A------ 0 2:102453 25600 0 0.00
4e1cd8e0 9 A------ 0 2:128053 25600 0 0.00
4e1cd9b0 10 A------ 0 2:153653 25600 0 0.00
4e1cda20 11 A------ 0 2:179253 25600 0 0.00
4e1cda98 12 A------ 0 2:204853 25600 0 0.00
9 active, 9 total
[gbasedbt@devsvr ~]$
至此,物理日志迁移完成。
更新onconfig
由于添加了临时数据库空间,迁移了物理日志和逻辑日志,需要更新配置文件中对应的参数值。
查看逻辑日志文件数量,该参数已经更新。
[gbasedbt@devsvr ~]$ gstat -c | grep LOGFILES
Your evaluation license will expire on 2022-10-14 00:00:00
# LOGFILES - The number of logical log files
LOGFILES 9
[gbasedbt@devsvr ~]$ gstat -g cfg | grep LOGFILES
Your evaluation license will expire on 2022-10-14 00:00:00
LOGFILES 9
[gbasedbt@devsvr ~]$
查看逻辑日志大小,发现还是以前的配置值,需要更新逻辑日志文件大小。
[gbasedbt@devsvr ~]$ gstat -g cfg | grep LOGSIZE
Your evaluation license will expire on 2022-10-14 00:00:00
LOGSIZE 10000
[gbasedbt@devsvr ~]$ gadmin -wf LOGSIZE=51200
Your evaluation license will expire on 2022-10-14 00:00:00
Value of LOGSIZE has been changed to 51200 kilobytes.
[gbasedbt@devsvr ~]$ gstat -g cfg | grep LOGSIZE
Your evaluation license will expire on 2022-10-14 00:00:00
LOGSIZE 51200
[gbasedbt@devsvr ~]$ gstat -c | grep LOGSIZE
Your evaluation license will expire on 2022-10-14 00:00:00
# LOGSIZE - The size of each logical log, in KB
LOGSIZE 51200
[gbasedbt@devsvr ~]$
由于创建了三个临时数据库空间,需要配置数据库实例可用的临时数据库空间
[gbasedbt@devsvr ~]$ gstat -c | grep DBSPACETEMP
Your evaluation license will expire on 2022-10-14 00:00:00
# DBSPACETEMP - The list of dbspaces used to store temporary
DBSPACETEMP
[gbasedbt@devsvr ~]$ gadmin -wf DBSPACETEMP=tempdbs1,tempdbs2,tempdbs3
Your evaluation license will expire on 2022-10-14 00:00:00
Value of DBSPACETEMP has been changed to tempdbs1,tempdbs2,tempdbs3.
[gbasedbt@devsvr ~]$ gstat -c | grep DBSPACETEMP
Your evaluation license will expire on 2022-10-14 00:00:00
# DBSPACETEMP - The list of dbspaces used to store temporary
DBSPACETEMP tempdbs1,tempdbs2,tempdbs3
[gbasedbt@devsvr ~]$ gstat -g cfg | grep DBSPACETEMP
Your evaluation license will expire on 2022-10-14 00:00:00
DBSPACETEMP tempdbs1,tempdbs2,tempdbs3
[gbasedbt@devsvr ~]$
至此,数据库空间全部创建完成。
验证
创建数据库
create database mydb in datadbs1 with log;
[gbasedbt@devsvr ~]$ echo "create database mydb in datadbs1 with log;" | dbaccess
Your evaluation license will expire on 2022-10-14 00:00:00
Database created.
Database closed.
[gbasedbt@devsvr ~]$
创建表
create table t_user(f_userid int, f_username varchar(20));
[gbasedbt@devsvr ~]$ echo "create table t_user(f_userid int, f_username varchar(20));" | dbaccess mydb
Your evaluation license will expire on 2022-10-14 00:00:00
Database selected.
Table created.
Database closed.
[gbasedbt@devsvr ~]$
操作数据
insert into t_user values(1, 'gbasedbt');
[gbasedbt@devsvr ~]$ echo "insert into t_user values(1, 'gbasedbt');" | dbaccess mydb
Your evaluation license will expire on 2022-10-14 00:00:00
Database selected.
1 row(s) inserted.
Database closed.
[gbasedbt@devsvr ~]$
查询数据
select * from t_user;
[gbasedbt@devsvr ~]$ echo "select * from t_user;" | dbaccess mydb
Your evaluation license will expire on 2022-10-14 00:00:00
Database selected.
f_userid f_username
1 gbasedbt
1 row(s) retrieved.
Database closed.
[gbasedbt@devsvr ~]$
常见问题与处理
安装GBase 8s时,操作系统没有可用的JRE
由于安装程序采用Java开发,当操作系统环境中没有可用的JRE时,会报如下错误:
[root@devsvr install]# ./ids_install
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...
No Java virtual machine could be found from your PATH
environment variable. You must install a VM prior to
running this program.
[root@devsvr install]#
CentOS 7.3操作系统的安装盘中有JRE软件包,可以使用yum进行安装
yum install -y java-1.8.0-openjdk.x86_64
安装后,可以使用java -version命令查看是否成功。
[root@devsvr install]# java -version
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)
安装GBase 8s时,报“The version file is not exist”
当使用最小化方式安装操作系统时,可能出现找不到版本文件的错误。
PRESS <ENTER> TO CONTINUE:
===============================================================================
The version file is not exist.
------------------------------
The version file is not exist.
PRESS <ENTER> TO ACCEPT THE FOLLOWING (OK):
出现这个问题的原因是操作系统没有unzip命令。
yum install -y unzip-6.0-16.el7.x86_64