docker-compose启动opengauss数据库——华为“自研”数据库

在这里插入图片描述



1. 启动数据库

  • yml文件
    创建opengauss目录,里边创建docker-compose.yml文件内容如下:

华为开源数据库,默认5432端口,是不是很熟悉,疑似又是个套壳子的事件。果断用postgres的docker-compose.yml稍作修改

version: "3.1"
services:
  opengauss:
    image: enmotech/opengauss:latest
    environment:
      GS_PASSWORD: liubei@161
      TZ: Asia/Shanghai
    ports:
      - 5432:5432
    privileged: true
    volumes:
      - ./opengauss:/var/lib/opengauss/data
    restart: always

对,你没看错
postgres的变量POSTGRES_PASSWORD改成GS_PASSWORD就是openGauss的变量了。
之后试了postgres创建默认库的变量 POSTGRES_DB,改成GS_DB就是openGauss的变量。

  • 启动服务
[root@localhost opengauss]# docker-compose up -d
Creating network "opengauss_default" with the default driver
Creating opengauss_opengauss_1 ... done
[root@localhost opengauss]# docker-compose ps
        Name                   Command          State           Ports
------------------------------------------------------------------------------
opengauss_opengauss_1   entrypoint.sh gaussdb   Up      0.0.0.0:5432->5432/tcp

2. 登录

2.1 本地登录

  • 进入opengauss的容器
[root@localhost opengauss]# docker ps
CONTAINER ID        IMAGE                                         COMMAND                  CREATED             STATUS              PORTS                    NAMES
3267dbb97d2f        harbocto.boe.com.cn/public/opengauss:latest   "entrypoint.sh gauss…"   11 minutes ago      Up 11 minutes       0.0.0.0:5432->5432/tcp   opengauss_opengauss_1
[root@localhost opengauss]# docker exec -it 32 bash
  • 切换到omm用户登录
root@3267dbb97d2f:/# su - omm
  • 登录数据库
omm@3267dbb97d2f:~$ gsql
gsql ((openGauss 2.1.0 build 590b0f8e) compiled at 2021-09-30 14:29:04 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
  • 测试sql

大胆用postgres的命令试吧,肯定没毛病

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=# select datname from pg_database;
  datname
-----------
 template1
 omm
 template0
 postgres
(4 rows)

果然命令都没改,甚至连postgres库都没改。

2.2 远程登录

直接上postgres的客户端,就不信会错

在这里插入图片描述
是不是感觉被骗了,哈哈哈
在这里插入图片描述


在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/xingzuo_1840/article/details/131291708