前言

openGauss是一款支持SQL2003标准语法,支持主备部署的高可用关系型数据库。

  • 多种存储模式支持复合业务场景,新引入提供原地更新存储引擎。
  • NUMA化数据结构支持高性能。
  • Paxos一致性日志复制协议,主备模式,CRC校验支持高可用。
  • 支持全密态计算、账本数据库等安全特性,提供全方位端到端的数据安全保护。
  • 通过Table Access Method接口层支持多存储引擎。

openGauss是一款提供面向多核的极致性能、全链路的业务和数据安全,基于AI的调优和高效运维的能力,全面友好开放,携手伙伴共同打造全球领先的企业级开源关系型数据库,采用木兰宽松许可证v2发行。openGauss深度融合华为在数据库领域多年的研发经验,结合企业级场景需求,持续构建竞争力特性。

环境准备

系统版本

DOCKER版本

openGauss版本

Centos7.8

19.03.12

3

部署

  1. 下载images镜像(因提前下载过)
[root@k8s-node2 ~]# docker pull techerwang/dbhub:opengauss3
opengauss3: Pulling from techerwang/dbhub
Digest: sha256:b7acc0630be6356394ec33de26f9f2ba6061bed1bd735473db51160d4fce8764
Status: Image is up to date for techerwang/dbhub:opengauss3
docker.io/techerwang/dbhub:opengauss3
  1. 运行openGauss镜像
[root@k8s-node2 ~]# docker run -itd --name opengauss --privileged=true -e GS_PASSWORD='Enmo@123' -v /home/opengauss:/var/lib/opengauss -p 5432:5432  techerwang/dbhub:opengauss3
f3b7fe610ba9a3e18edbc437dccf3e1b5f06c58fcaae3580ea7835690c5847f1
#参数解读
#GS_PASSWORD  设置密码,有强度校验至少8位,大小写字母数字
#/home/opengauss:/var/lib/opengauss  挂载配置
#5432:5432		默认的端口是5432,这里映射为5432,实际情况个人修改
  1. 查看镜像
[root@k8s-node2 ~]# docker ps -a | grep opengauss
60d3b3c34559        techerwang/dbhub:opengauss3   "entrypoint.sh gauss…"   22 seconds ago      Up 21 seconds             0.0.0.0:5432->5432/tcp   opengauss

验证

因默认用户不允许远程登录,先需要创建一个用户。

  1. 修改第一个配置文件 pg_hba.conf(查看上文的挂载地址)
[root@k8s-node2 data]# cd /home/opengauss/data/
[root@k8s-node2 data]# ls
asp_data         gs_profile          pg_csnlog      pg_llog       pg_notify     pg_stat_tmp  postgresql.conf       sql_monitor
base             gswlm_userinfo.cfg  pg_ctl.lock    pg_location   pg_perf       pg_tblspc    postgresql.conf.lock  undo
gaussdb.state    mot.conf            pg_errorinfo   pg_log        pg_replslot   pg_twophase  postmaster.opts
global           pg_audit            pg_hba.conf    pg_logical    pg_serial     PG_VERSION   postmaster.pid
gs_gazelle.conf  pg_clog             pg_ident.conf  pg_multixact  pg_snapshots  pg_xlog      postmaster.pid.lock
[root@k8s-node2 data]# cat pg_hba.conf | grep all
# This file controls: which hosts are allowed to connect, how clients
# DATABASE can be "all", "sameuser", "samerole", "replication", a
# database name, or a comma-separated list thereof. The "all"
# USER can be "all", a user name, a group name prefixed with "+", or a
# "all", "sameuser", "samerole" or "replication" makes the name lose
# If you want to allow non-local connections, you need to add more
# allows any local user to connect as any PostgreSQL user, including
# the database sysadmin.  If you do not trust all your local users,
local   all             all                                     trust
host    all             all             127.0.0.1/32            trust
host    all             all             ::1/128                 trust
host all all 0.0.0.0/0 md5
###前面上必须为trust,不然登录不上(默认是这样就不需要改)
###MD5的意思是用MD5方式去校验密码
  1. 修改第二个配置文件postgresql.conf,并添加以下三行
[root@k8s-node2 data]# vi postgresql.conf
listen_addresses = '*'
local_bind_address = '0.0.0.0'
password_encryption_type = 0
###默认这三行配置已经注释,需要把这三行加进去,或者取消注释修改也可以
  1. 重启opengauss
[root@k8s-node2 data]# docker restart opengauss
opengauss
[root@k8s-node2 data]# docker ps -a | grep opengauss
60d3b3c34559        techerwang/dbhub:opengauss3   "entrypoint.sh gauss…"   16 minutes ago      Up 11 seconds             0.0.0.0:5432->5432/tcp   opengauss
  1. 创建可以外界连接用户
[root@k8s-node2 data]# docker exec -it opengauss /bin/bash
root@60d3b3c34559:/# su - omm   #需要切换到omm
omm@60d3b3c34559:~$ gsql -d postgres #使用postgres为基础数据库
gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:34 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=# CREATE USER zzzz PASSWORD 'Qwer@1234';  #因为使用MD5创建的所以下面会提醒MD5 
NOTICE:  The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
openGauss=# ALTER ROLE zzzz SYSADMIN;               #授予sysadmin权限
ALTER ROLE
#

5. 使用工具登录验证

1. 官方自带工具下载(下载页面:https://opengauss.org/zh/download/

容器部署单节点openGauss_docker

2. 连接opengauss 启动Data Studio.exe程序

启动若显示以下图片,请使用管理员身份运行,因为没有配置SSL。请不要使用SSL连接

容器部署单节点openGauss_opengauss_02

容器部署单节点openGauss_postgresql_03

3. 登录成功

容器部署单节点openGauss_opengauss_04

6. 使用Navicat登录(这里使用的16版本,)新建PostgreSQL连接

容器部署单节点openGauss_postgresql_05