GBase 8s 学习笔记
GBase 8s 学习笔记 001 —— GBase 8s 数据库产品介绍
熟悉 GBase 8s 产品功能与应用场景
GBase 8s 是什么
GBase 8s 是一款支持共享存储集群、两地三中心部署的、成熟稳定的、具有TB数据支撑能力的国产事务型案例数据库。
适用于金融、电信等行业核心交易系统和对信息案例性有较高要求的信息系统,能够在80%以上场景中替换 Oracle 及 Oracle RAC 集群。
- 重要特性
- 强一致性+高性能
- 面向事务密集型业务场景
- 有效支撑金融行业核心交易系统
- 健壮的高可用能力
- 支持本地共享存储集群(SSC)
- 完美支持两地三中心部署方案
- 完美的国产生态支持
- 支持全部国产处理器平台
- 支持国产操作系统和国产中间件
- 核心价值
- 金融级核心业务能力
- 满足严苛的事务ACID要求
- 99.999%可用性
- 海量数据、海量并发
- 可支撑200TB业务数据
- 可响应10000并发连接请求
- 计算与存储分离,弹性扩展
- 分钟级弹性扩展
- 支持读写分离和业务架构
- 混合业务性能线性扩展能力0.7
GBase 8s 功能
- 关系型数据库集群
- SQL标准:SQL92+
- 标准开发接口:JDBC、ODBC等
- 企业级的事务处理能力
- 刚性事务,ACID
- 数据完整性
- 复杂事务处理
- 国产平台支持
- 国产芯片:鲲鹏、海光、飞腾、龙芯、申威、兆芯
- 国产OS:麒麟、统信、中科方德、凝思等
- 高性能
- DSA动态可伸缩架构
- SMP对称多处理
- 支持高并发访问
- 高度并行计算
- 高可用性
- 完备的高可用方案
- 对标Oracle的RAC、DataGuard和GoldenGate
- 两地三中心最佳方案
- 99.99%可用性
掌握 GBase 8s 产品架构
GBase 8s 数据库架构概览(Architecture)
GBase 8s 数据库服务架构
GBase 8s 数据库服务组件
- 进程/线程管理
- 多线程技术,实现了数据库的高性能。
- DSA架构,实现了数据库的可扩展性。
- 虚拟处理器技术,保障了数据库版本的稳定性。
- 专有的线程库技术,完全不依赖操作系统的线程库,保障了数据库版本在不同平台上的可迁移性。
- 多进程架构
- 传统的多进程服务
- 每个连接(Session)需要启动新的进程为其提供服务每个进程的起始(Initialization)与终止(Termination)均耗费系统资源(CPU)。
- 进程间通信需执行上下文切换(Context Switch),该切换由操作系统调用CPU来处理,耗费系统资源。
- 基于虚拟处理器的多进程/多线程架构
- 虚拟处理器中的线程库
- 不依赖于操作系统的线程库。
- 用户态实现,定义了一系列的控制块和堆栈。
- 类协程技术,支持跨进程的线程调度线程间可高度、高效并发。
- 优势
- 更好移植性。
- 更高效的资源利用。
- 高并发场景下更稳定的性能表现。
- 虚拟处理器
- 共享内存管理
- 基于共享内存的进程间通讯
- 共享内存段管理
- 物理日志缓冲区
- 逻辑日志缓冲区
- 存储管理
- 物理存储
- 逻辑存储
- 存储管理(页:Page)
- 存储管理(段:Extent)
- 存储管理(块:Chunk)
- 存储管理(数据库空间:DBSpace)
- 存储管理(表:Table)
- 存储管理(数据库:Database)
- 存储管理(表空间:TableSpace)
- 物理日志
- 数据库服务器在修改数据页前,将这些数据页进行保存。保存的这些数据页(数据页的前映像)称为物理日志。
- 数据库服务器将物理日志记录在物理日志数据库空间中。
- 在系统异常时(如电源掉电,操作系统重启,进程宕机等),数据库服务器重新启动过程中,会先根据物理日志进行物理恢复,然后根据逻辑日志进行逻辑恢复。
- 逻辑日志
- 数据库服务器对数据的操作进行记录。这些记录称为逻辑日志。
- 数据库服务器将逻辑日志记录在逻辑日志数据库空间中。
- 在灾难发生时,数据库恢复程序会先根据历史备份数据中的L0/L1/L2备份,进行物理恢复,再根据历史备份中的逻辑日志备份,进行逻辑恢复。
- 临时数据库空间
- 临时数据库空间是专门为临时表的存储而保留的数据库空间。
- 数据库服务器在不正常关闭时不保留任何临时数据库空间内容。
- 数据库服务器不会为临时数据库空间执行逻辑或物理日志记录。
- 大对象数据库空间
- BLOB Space是由一个或多个只存储 TEXT 和 BYTE 数据的块组成的逻辑存储单元。
- BLOB Space的 Blobpage大小是在创建 BLOB Space时指定的,大小是页的整数倍。
- Blob Space 中的所有 Blobpage 的大小都是相同的,但是不同BLOB Space中的Blobpage 的大小可以不同。
- 存储在 BLOB Space中的数据直接写入磁盘,不会透过共享内存进行读写。
- 数据库服务器不会将TEXT或BYTE对象写入逻辑日志或物理日志。
- 智能大对象数据库空间
- 智能大对象数据库空间是由存储智能大对象的一个或多个块组成的逻辑存储单元。
- 智能大对象由 CLOB(字符大对象)和 BLOB(二进制大对象)数据类型组成。
- 用户定义的数据类型也可以使用智能大对象数据库空间。
- 智能大对象的页大小不可以定义,其与数据页大小相同。
- • 智能大对象的数据写入物理日志和逻辑日志,在故障发生时,智能大对象可恢复。
了解 GBase 8s 部署模式
共享存储集群:SSC
- 基于共享存储的高可用架构
- 由CM进行管理并自动维护
- 主节点写/辅节点读
- 主节点故障时,辅节点自动接管服务,升级为主节点
- 在有多个辅节点时,CM会根据辅节点负载情况选择把哪个节点升级为主节点
- 故障切换时间在 1 分钟以内
- 较好的可伸缩性
- 对应用透明
高可用集群:HAC
远程高可用集群:RHAC
两地三中心实现
GBase 8s 学习笔记 002 —— GBase 8s 安装与卸载
安装环境
检查服务器内存大小
1 2 3 4 | [root@192 ~]# free -m total used free shared buff/cache available Mem: 1819 787 103 20 927 855 Swap: 2047 4 2043 |
检查服务器磁盘空间大小
1 2 3 4 5 6 7 8 9 10 11 | [root@192 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 devtmpfs 894M 0 894M 0% /dev tmpfs 910M 0 910M 0% /dev/shm tmpfs 910M 11M 900M 2% /run tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/mapper/centos-root 50G 5.4G 45G 11% / /dev/sda1 1014M 185M 830M 19% /boot /dev/mapper/centos-home 27G 37M 27G 1% /home tmpfs 182M 48K 182M 1% /run/user/0 /dev/sr0 4.4G 4.4G 0 100% /run/media/root/CentOS 7 x86_64 |
检查服务器网络配置信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | [root@192 ~]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.254.134 netmask 255.255.255.0 broadcast 192.168.254.255 inet6 fe80::d8df:9e1b:e341:34dd prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6f:ac:d9 txqueuelen 1000 (Ethernet) RX packets 336065 bytes 502856578 (479.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 59073 bytes 3630904 (3.4 MiB) 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 1000 (Local Loopback) RX packets 1036 bytes 89096 (87.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1036 bytes 89096 (87.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:81:64:14 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 |
检查操作系统版本
1 2 | [root@192 ~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) |
安装前的准备工作
创建用户
GBase 8s数据库需要一个名字为gbasedbt的操作系统用户,做为数据库的超级用户。我们在安装前,需要创建好这个用户。
如果我们在安装时,没有提前创建这个用户,在安装过程中,会提示要创建这个用户,并输入密码。不过在安装过程中创建的用户,没有创建一个新的目录做为gbasedbt的Home,这可能导致在后续的创建数据库实例时,无法自动生成实例的环境变量。
为了减少后面的麻烦,记得提前创建gbasedbt用户,并设置好密码。
检查操作系统是否存在gbasedbt用户
1 2 | [root@192 ~]# cat /etc/passwd | grep gbasedbt [root@192 ~]# |
检查操作系统是否存在gbasedbt组
1 2 | [root@192 ~]# cat /etc/group | grep gbasedbt [root@192 ~]# |
创建gbasedbt组和用户,并设置用户密码
1 | [root@192 ~]# useradd gbasedbt |
创建gbasedbt后,再次查看
1 2 3 4 | [root@192 ~]# cat /etc/group | grep gbasedbt gbasedbt:x:1001: [root@192 ~]# cat /etc/passwd | grep gbasedbt gbasedbt:x:1001:1001::/home/gbasedbt:/bin/bash |
gbasedbt的组和用户已经创建成功。
准备软件安装包
上传GBase 8s安装包到服务器。
1 2 3 | [root@192 ~]# ll /root/setup/ 总用量 309272 -rw-r--r--. 1 root root 316692480 2月 7 20:46 GBase8s_ExpressEdition.tar |
创建一个目录,将安装包解压到该目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | [root@192 ~]# mkdir install [root@192 ~]# ll 总用量 8 -rw-------. 1 root root 1793 9月 2 06:28 anaconda-ks.cfg -rw-r--r--. 1 root root 1821 9月 1 22:30 initial-setup-ks.cfg drwxr-xr-x. 2 root root 6 2月 7 20:48 install drwxr-xr-x. 2 root root 40 2月 7 20:46 setup drwxr-xr-x. 2 root root 6 2月 7 19:38 公共 drwxr-xr-x. 2 root root 6 2月 7 19:38 模板 drwxr-xr-x. 2 root root 6 2月 7 19:38 视频 drwxr-xr-x. 2 root root 6 2月 7 19:38 图片 drwxr-xr-x. 2 root root 6 2月 7 19:38 文档 drwxr-xr-x. 2 root root 6 2月 7 19:38 下载 drwxr-xr-x. 2 root root 6 2月 7 19:38 音乐 drwxr-xr-x. 2 root root 6 2月 7 19:38 桌面 [root@192 ~]# cd install/ [root@192 install]# tar xf /root/setup/GBase8s_ExpressEdition.tar [root@192 install]# ll 总用量 309248 drwxr-xr-x. 2 nwh nwh 77 3月 23 2021 doc -rwxr-xr-x. 1 nwh nwh 316579352 3月 23 2021 ids_install -rw-r--r--. 1 nwh nwh 1864 3月 23 2021 ids.properties -rwxr-xr-x. 1 nwh nwh 82738 3月 23 2021 onsecurity |
至此,安装数据库需要的软件包和用户都准备好了。
安装GBase 8s
安装GBase 8s数据库组件
GBase 8s数据库安装,支持图形界面方式和控制台的命令行方式。默认的安装方式是控制台命令行方式。如果希望使用图形界面安装,只需要在启动安装程序时,后面加上参数./ids_install -i swing即可。
安装过程中,会显示产品的License,内容较长,在控制台的命令行方式中,可以连续按5次回车。在图形界面方式中,需要用鼠标拉动界面右侧的滚动条到底部,就可以点那个复选框,确认License了。
在root用户下,进入安装包目录,运行安装命令ids_install,启动安装程序。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | [root@192 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... =============================================================================== 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, 2023. All rights reserved. 1. Release Notes The Release Notes can be found in /root/install/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: |
回车继续
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | =============================================================================== License Agreement ----------------- Installation and Use of GBase Software Bundle Requires Acceptance of the Following License Agreement: Thank you for choosing GBase product! Please read carefully the following licencing agreement before installing any product: TIANJIN GENERAL DATA TECHNOLOGY CO. LTD. LICENSE AGREEMENT READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSETERMS (COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE OPENING THE SOFTWAREMEDIA PACKAGE. BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE TERMS OF THIS AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY, INDICATE YOUR ACCEPTANCE OF THESE TERMS. IF YOU DO NOT AGREE TO ALL THESE TERMS, PROMPTLY RETURN THE UNUSED SOFTWARE TO YOUR PLACE OF PURCHASE FOR A REFUND. 1. LICENSE TO USE. GeneralData grants you a non-exclusive and non-transferable license for the internal use only of the accompanying software and documentation and any error corrections provided by GeneralData(collectively "Software"), by the number of users and the class of computer hardware for which the corresponding fee has been paid. 2. RESTRICTIONS. Software is confidential and copyrighted. Title to Software PRESS <ENTER> TO CONTINUE: |
回车继续
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | and all associated intellectual property rights is retained by GeneralData and/or its licensors. Except as specifically authorized in any Supplemental License Terms, you may not make copies of Software, other than a single copy of Software for archival purposes. Unless enforcement is prohibited by applicable law, you may not modify, decompile, or reverse engineer Software. You acknowledge that Software is not designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility. GeneralData disclaims any express or implied warranty of fitness for such uses. No right, title or interest in or to any trademark, service mark, logo or trade name of GeneralData or its licensors is granted under this Agreement. 3. DISCLAIMER OF WARRANTY. Unless specified in this agreement, all express of implied conditions, representations and warranties, including any implied warranty of merchantability, fitness for aparticular purpose or non-infringement are disclaimed, except to theextent that these disclaimers are held to be legally invalid. 4. LIMITATION OF LIABILITY. To the extent not prohibited by law, in no event will GeneralData or its licensors be liable for any lost revenue, profit or data, or for special, indirect, consequential, incidental orpunitive damages, however caused regardless of the theory of liability, arising out of or related to the use of or inability to use software, even if GeneralData has PRESS <ENTER> TO CONTINUE: |
回车继续
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | been advised of the possibility of such damages. In no event will GeneralData's libility to you, whether incontract, tort(including negligence), or otherwise, exceed the amount paid by you for Software under this Agreement. The foregoing limitations will apply even if the above stated warranty fails of itsessential purpose. 5. TERMINATION. This Agreement is effective until terminated. You may terminate this Agreement at any time by destroying all copies of Software. This Agreement will terminate immediately without noticefrom GeneralData if you fail to comply with any provision of this Agreement. Upon Termination, you must destroy all copies of Software. 6. EXPORT REGULATIONS. All Software and technical data delivered under this Agreement are subject to US export control laws and may be subject to export or import regulations in other countries. You agree to comply strictly with all such laws and regulations and acknowledge that you have the responsibility to obtain such licenses to export, re-export, or import as may be required after delivery to you. 7. CHINESE GOVERNMENT RESTRICTED. If Software is being acquired by or on behalf PRESS <ENTER> TO CONTINUE: |
回车继续
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | of the Chinese Government, then the Government's rights in Software and accompanying documentation will be only as set forth in this Agreement. 8. GOVERNING LAW. Any action related to this Agreement will be governed by Chinese law: "COPYRIGHT LAW OF THE PEOPLE'S REPUBLIC OF CHINA", "PATENT LAW OF THE PEOPLE'S REPUBLIC OF CHINA", "TRADEMARK LAW OF THE PEOPLE'S REPUBLIC OF CHINA", "COMPUTER SOFTWARE PROTECTION REGULATIONS OF THE PEOPLE'S REPUBLIC OF CHINA". No choice of law rules of any jurisdiction will apply." 9. SEVERABILITY. If any provision of this Agreement is held to be unenforceable, this Agreement will remain in effect with the provision omitted, unless omission would frustrate the intent of the parties, in which case this Agreement will immediately terminate. 10. INTEGRATION. This Agreement is the entire agreement between you and GeneralData relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification of this Agreement will be binding, unless in writing and signed by an authorize depresentative of each party. When the translation document has the different PRESS <ENTER> TO CONTINUE: |
回车继续
1 2 3 4 5 6 7 8 | 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 |
接受License,输入y,按回车开始安装。
1 2 3 4 5 6 7 8 9 10 | =============================================================================== 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 8s的安装路径。我们输入/opt/gbase。
- 说明:
- /opt目录的默认用户和用户组是root:root,如果被修改成其它用户和用户组,可能会导致安装时,报权限错误。请检查指定的安装路径用户和用户组是否为root:root。
- 如果数据库安装在/opt下,可以不用手动创建后面的目录,安装程序会自动创建。
- 为了保障数据安全,GBase 8s的安装路径,不能允许其它用户有写权限,即安装路径不能设置为777。建议将安装路径的权限设置为755.
- 安装目录中,必须为空。
1 2 | INSTALL FOLDER IS: /opt/gbase IS THIS CORRECT? (Y/N): y |
输入y,确认安装路径。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | =============================================================================== 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:: 1 |
安装程序支持典型安装和自定义安装方式,我们选择典型安装,所以输入1。
1 2 3 4 5 6 7 8 9 10 | =============================================================================== 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 |
在安装过程中,可以自动创建一个数据库的实例。由于典型安装中创建的实例在配置上非常简单,不适合后期深入的学习GBase 8s,因此选择不创建实例,在安装后,可以手动执行一个脚本,方便了创建一个新的数据库实例。此处输入2。
重要说明:
这个选择很重要。选择不创建实例,不但可以减少你的整体安装时间,也会让你对这款数据库,有更深入地了解。
安装过程中,自动创建一个数据库实例,在个别情况下,可能出现安装后,不能创建数据库现象(执行create database卡住,一段时间后报错退出)。这个问题的原因是sqlhosts文件中使用了机器名,需要我们修改成服务器的IP地址,并重启数据库,就可以解决。也许有其它好的解决方法,不过这是目前知道的一个方法,而且好用。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | =============================================================================== 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: 496,188,997 Bytes Available: 46,859,845,632 Bytes PRESS <ENTER> TO CONTINUE: |
安装程序给出一个报告,列出了本次将要安装的数据库组件。按回车将继续安装。
1 2 3 4 5 6 7 8 9 10 | =============================================================================== 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: |
安装程序再次让用户确认安装程序的位置。按回车键,确认安装位置并继续安装。
开始安装…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | =============================================================================== Installing... ------------- [==================|==================|==================|==================] [------------------|------------------|------------------|------------------] =============================================================================== Installation Complete --------------------- Congratulations! GBase Software Bundle installation is complete. Product install status: GBase: Successful GBase Connect: Successful Main Version: GBase 8s 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: |
安装完成。按回车键退出安装程序。
至此,数据库的组件,全部安装完成。
再创建一个数据库实例,就可以工作了。
创建数据库实例
创建数据库实例,需要切换到gbasedbt用户。
1 | [root@192 install]# su - gbasedbt |
在数据库安装目录的etc目录有,有一个GBaseInit_gbasedbt.sh脚本,可以采用向导方式,让我们一步一步,方便地创建一个新的数据库实例。
GBase 8s不同于Oracle,MySQL和SQL Server等,支持在一台服务器上,部署多个实例,听说甚至可以部署不同版本的多个实例,对于那些服务器紧张的小伙伴,是个福利。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | [gbasedbt@192 ~]$ cd /opt/gbase/etc [gbasedbt@192 etc]$ ls ac_config.std boot1210.sql boot920b.sql cnv50t60.sql evidence.sh IIFfiles revboot1210XC4_CM.sql syscdcv1.sql alarmprogram.sh boot1210XC4_CM.sql boot920c.sql cnv50t92.sql gbasedbtdir-is-insecure IM_ic_16.png secswitch.std syscdr.sql allowed.surrogates.demo boot1210XC4.sql boot920.sql cnv94t100.sql GBaseInit_gbasedbt.sh IM_uninstall_16.png securityconfig.std syscdrview.sql blduser.sh boot901.sql boot930a.sql conv GBase_security.sh install securitylog.std sysmaster.sql bldutil.sh boot90.sql boot940.sql convTovNoSQL1210.sql GLS-cr jsonListener-example.properties server_instance_terminal.png sysuser.sql boot1000a.sql boot910b.sql bootdwa.sql convTovNoSQL1210XC3.sql Glsfiles log_full.sh smi_6to7 sysutils.sql boot1000.sql boot910.sql bootupgrade.sql cvtlongid7x.sql ids_16.png make-gbasedbtdir-secure smi_load termcap boot1110.sql boot911.sql brand cvtlongid914.sql idser.xsd Messagefiles smi_unld typetab boot1150.sql boot911u.sql buildsmi cvtviotab.sql ids_master_doc.xml MSG-cr sm_versions.std xpg4_is.sql boot1150XC6.sql boot912b.sql clone do_role_sep ifxdeploy.conf no_log.sh sqlhosts.ext.demo boot1170.sql boot912.sql cnv10to1110.sql dropcdr.sql ifx_failover_callback.sh onconfig.std sqlhosts.std boot1170XC3.sql boot920a.sql cnv1150to1170.sql dummyupds100.sql IIF-cr release_notes.png sysadmin [gbasedbt@192 etc]$ |
执行创建实例的脚本
1 | [gbasedbt@192 etc]$ sh GBaseInit_gbasedbt.sh |
开始创建数据库实例。
1 2 3 4 | Initializing Program...OK ENTER THE INSTANCE INFORMATION or PRESS <ENTER> TO ACCEPT THE DEFAULT. ENTER GBASE INSTANCE NAME (GBASEDBTSERVER) [Default:gbaseserver]: |
脚本默认的实例名称为gbaseserver,可以在冒号后面输入希望的名称,也可以直接回车,使用默认的实例名。
说明:实例的名称可以是字母,数字和下划线。
不要用减号,不要用减号,不要用减号。
1 2 3 4 | SEARCHING FOR GBASE INSTALL FOLDER, PLEASE WAIT FOR SECONDS... GBASE INSTALL FOLDER LIST: 1) /opt/gbase CHOOSE GBASE INSTALL FOLDER(GBASEDBTDIR) [Default:/opt/gbase]: |
安装脚本询问GBase 8s的程序安装在哪个路径下,默认是之前安装时指定的路径。直接回车继续。
1 2 3 4 5 | CHOOSE SERVICE IP ADDRESS FROM THE LIST: 1) 192.168.254.134 2) 127.0.0.1 3) 192.168.122.1 ENTER THE NUMBER FOR YOUR CHOICE [Default:192.168.254.134]: |
安装脚本询问服务器的IP地址,输入服务器的IP地址。如果默认的IP地址是希望的IP,直接回车继续。
1 | SPECIFY THE PORT NUMBER FOR GBASE [Default:9088]: |
安装脚本询问数据库监听使用的端口号,默认为9088。使用默认值,回车继续。
1 2 3 4 | 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 |
安装脚本询问初始化的类型,选择CUSTOM,输入2,回车继续。
1 2 3 4 5 | 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 |
安装脚本询问数据库使用哪种字符集,此处使用UTF8,输入3,回车继续。
1 | ENTER THE DATA SPACE PATH [Default:/opt/gbase/gbaseserver_dbs]: |
安装脚本询问数据保存在哪个目录中,使用默认值,回车继续。
1 | ENTER THE LOGICAL LOG DBSPACE SIZE(MB) [Default:4500]: 200 |
安装脚本询问,保存逻辑日志的数据库空间大小,输入200,回车继续。
说明:这个地方指定的值很大时,数据库会按该值分配磁盘空间,可能用时较长。
1 | ENTER THE PHYSICAL LOG DBSPACE SIZE(MB) [Default:4500]: 200 |
安装脚本询问,保存物理日志的数据库空间大小,输入200,回车继续。
说明:这个地方指定的值很大时,数据库会按该值分配磁盘空间,可能用时较长。
1 | ENTER THE SMART LOB DBSPACE SIZE(MB) [Default:930]: 100 |
安装脚本询问,保存智能大对象的数据库空间大小,输入100,回车继续。
说明:这个地方指定的值很大时,数据库会按该值分配磁盘空间,可能用时较长。
1 | ENTER THE TEMPORARY DBSPACE SIZE(MB) [Default:930]: 100 |
安装脚本询问,保存临时数据的数据库空间大小,输入100,回车继续。
说明:这个地方指定的值很大时,数据库会按该值分配磁盘空间,可能用时较长。
1 | ENTER "Y" TO START DATABASE ADVANCED SETTINGS, OR ENTER "N" TO ACCEPT DEFAULT VALUES: [Default:N]: y |
安装脚本询问我们,是否进行一些高级设置,我们输入y,回车继续。
1 | ENTER THE NUMBER OF DATA DBSPACES [Default:1]: 5 |
安装脚本询问我们,创建几个保存数据的数据库空间,输入5,回车继续。
提示:这点很重要,方便后面学习分片表。
1 | ENTER THE NUMBER OF TEMP DBSPACES [Default:1]: 3 |
安装脚本询问,创建几个保存临时数据的数据库空间,输入3,回车继续。
1 | Enter "Y" TO ENABLE ENVIRONMENT GL_USEGLU, OR ENTER "N" TO DISABLE: [Default:N]: |
安装脚本询问,是否启用GL_USEGLU,默认不启用,直接回车继续。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | INSTANCE SUMMARY: Instance name: gbaseserver GBase install directory: /opt/gbase IP address & port: 192.168.254.134: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/gbaseserver_dbs Data path free size: 44629 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 |
安装脚本列出创建实例的配置信息。输入y,回车继续。
安装脚本开始创建实例。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | Touching Chunks...OK Create sqlhosts File: /opt/gbase/etc/sqlhosts.gbaseserver ...OK Setting Parameters in /opt/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 2024-02-07 00:00:00 .Your evaluation license will expire on 2024-02-07 00:00:00 .Your evaluation license will expire on 2024-02-07 00:00:00 .Your evaluation license will expire on 2024-02-07 00:00:00 ...OK Database restarting.......Your evaluation license will expire on 2024-02-07 00:00:00 OK Creating database: gbasedb...OK Now you can use this URL to connect to gbasedb: jdbc:gbasedbt-sqli://192.168.254.134: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 2024-02-07 00:00:00 On-Line -- Up 00:00:13 -- 597864 Kbytes Build Number: 3.3.0_N303 GBase Initializing Finished! Initialize log file : ./InitGBaseDB_202302072126.log Press <ENTER> to Exit and Logout... |
至此,数据库实例创建完成。
1 2 | 已杀死 [root@192 install]# |
环境变量
安装脚本会在gbasedbt的Home路径下,自动生成一个名称为profile.gbaseserver的文件,记录了新创建数据库实例需要的环境变量。
1 2 | [gbasedbt@192 ~]$ ls profile.gbaseserver |
可以使用cat命令查看文件的内容。
1 2 3 4 5 6 7 8 9 | [gbasedbt@192 ~]$ cat profile.gbaseserver export GBASEDBTSERVER=gbaseserver export GBASEDBTDIR=/opt/gbase export GBASEDBTSQLHOSTS=/opt/gbase/etc/sqlhosts.gbaseserver export ONCONFIG=onconfig.gbaseserver export PATH=/opt/gbase/bin:$PATH export DB_LOCALE=zh_CN.utf8 export CLIENT_LOCALE=zh_CN.utf8 unset GL_USEGLU |
可以使用source命令,使环境变量生效。
1 | [gbasedbt@192 ~]$ source profile.gbaseserver |
可以使用env查看环境变量。