一、华为openGauss高斯数据库介绍

openGauss是一款华为开源的关系型数据库管理系统,它具有多核高性能、全链路安全性、智能运维等企业级特性。

openGauss内核早期源自开源数据库PostgreSQL,融合了华为在数据库领域多年的内核经验,在架构、事务、存储引擎、优化器及ARM架构上进行了适配与优化。作为一个开源数据库,期望与广泛的开发者共同构建一个多元化技术的开源数据库社区。

下面是openGauss数据库的架构图:

二、华为openGauss高斯数据库安装

1、传统安装:

openGauss传统的安装步骤,具体操作比较繁琐,需要设置配置文件、准备安装环境等等,不适合想快速入手高斯数据库的同学。当然如果有同学想了解传统的安装步骤,我后续会出一个文章专门详细说明这个传统安装步骤。

2、Docker安装:

Docker是一个基于轻量级虚拟化技术的容器,整个项目基于Go语言开发,并采用了Apache 2.0协议。Docker可以将我们的应用程序打包封装到一个容器中,该容器包含了应用程序的代码、运行环境、依赖库、配置文件等必需的资源,通过容器就可以实现方便快速并且与平台解耦的自动化部署方式,无论你部署时的环境如何,容器中的应用程序都会运行在同一种环境下。

使用Docker安装openGauss数据库可以免去繁琐的配置,简化安装步骤,下面主要给同学们介绍使用Docker安装openGauss数据库的过程。

操作系统建议同学们选择一个Linux系统,因为Docker和Linux的兼容性比较好,Docker容器化技术就起源于Linux系统。windows下安装Docker也比较麻烦。

我们这次使用的华为开源的openEuler操作系统。可以使用虚拟机软件先安装好openEuler操作系统,安装过程参看我的另一篇博文:

3、Docker安装过程:

安装Docker:

[root@openEuler ~]# yum install -y docker


拉取镜像:


[root@openEuler ~]# docker pull enmotech/opengauss:latest
latest: Pulling from enmotech/opengauss
ca1778b69356: Pull complete
6bc68ebf221c: Pull complete
62149130862a: Pull complete
a578cee72a33: Pull complete
e63b015b79f9: Pull complete
Digest: sha256:97a8f2e24ca408fe9485af6e4b98accabca49c2b102e9247b188c62eadb7a73c
Status: Downloaded newer image for enmotech/opengauss:latest

运行容器:

[root@openEuler ~]#  docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Enmo@123 -p 8090:5432 enmotech/opengauss:latest
d577c549c60217b159e3cfc52f0e5261b0222422cf93d7c6f115cbef9d40e8fe

容器启动中的参数讲解:

  • GS_PASSWORD

在你使用openGauss镜像的时候,必须设置该参数。该参数值不能为空或者不定义。该参数设置了openGauss数据库的超级用户omm以及测试用户gaussdb的密码。openGauss安装时默认会创建omm超级用户,该用户名暂时无法修改。测试用户gaussdb是在docker-entrypoint.sh中自定义创建的用户。
openGauss镜像配置了本地信任机制,因此在容器内连接数据库无需密码,但是如果要从容器外部(其它主机或者其它容器)连接则必须要输入密码。
openGauss的密码有复杂度要求,需要:密码长度8个字符以上,必须同时包含英文字母,数字,以及特殊符号

  • GS_NODENAME

指定数据库节点名称 默认为gaussdb

  • GS_USERNAME

指定数据库连接用户名 默认为gaussdb

  • GS_PORT

指定数据库端口,默认为5432。

查看容器:

[root@openEuler ~]# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                      PORTS               NAMES
d577c549c602        enmotech/opengauss:latest   "entrypoint.sh gauss…"   32 seconds ago      Exited (1) 31 seconds ago                       opengauss

三、华为openGauss高斯数据库使用


进入容器,并切换omm用户,使用gsql连接高斯数据库


[root@openEuler ~]# docker exec -it opengauss sh
# su - omm

omm@fd8714c57ef7:~$ gsql
gsql ((openGauss 5.0.0 build a07d57c3) compiled at 2023-03-29 03:09:38 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

omm=#

对高斯数据库进行一些基本的测试: 

omm=# select version();
ERROR:  invalid byte sequence for encoding "UTF8": 0xef 0x3b
omm=# select version();
                                                                       version

---------------------------------------------------------------------------------------------------------------------------------
---------------------
 (openGauss 2.1.0 build 590b0f8e) compiled at 2021-09-30 14:29:04 commit 0 last mr   on x86_64-unknown-linux-gnu, compiled by g++
 (GCC) 7.3.0, 64-bit
(1 row)

omm=#  \copyright
GaussDB Kernel Database Management System
Copyright (c) Huawei Technologies Co., Ltd. 2018. All rights reserved.

omm=# \l
                              List of databases
   Name    | Owner | Encoding |   Collate   |    Ctype    | Access privileges
-----------+-------+----------+-------------+-------------+-------------------
 omm       | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres  | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +
           |       |          |             |             | omm=CTc/omm
 template1 | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +
           |       |          |             |             | omm=CTc/omm
(4 rows)

omm=# \du
                                                              List of roles
 Role name |                                                    Attributes                                                    | M
ember of
-----------+------------------------------------------------------------------------------------------------------------------+--
---------
 gaussdb   | Sysadmin                                                                                                         | {
}
 omm       | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {
}

omm=# \db
      List of tablespaces
    Name    | Owner | Location
------------+-------+----------
 pg_default | omm   |
 pg_global  | omm   |
(2 rows)

omm=# \dn
    List of schemas
      Name      | Owner
----------------+-------
 blockchain     | omm
 cstore         | omm
 db4ai          | omm
 dbe_perf       | omm
 dbe_pldebugger | omm
 pkg_service    | omm
 public         | omm
 snapshot       | omm
 sqladvisor     | omm
(9 rows)

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐