Article Directory
1. Start the database
- yml file
Createopengauss
a directory, and create a docker-compose.yml file inside as follows:
Huawei's open source database, the default port is 5432, is it very familiar to you, it seems to be another cover-up incident. Decisively use postgres with
docker-compose.yml
a slight modification
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
Yes, you read that right,
the variable of postgres isPOSTGRES_PASSWORD
changedGS_PASSWORD
to the variable of openGauss.
After that, I tried postgres to create the variables of the default libraryPOSTGRES_DB
, and changed themGS_DB
to openGauss variables.
- start service
[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. Login
2.1 Local login
- Enter the opengauss container
[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
- Switch to omm user login
root@3267dbb97d2f:/# su - omm
- login database
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.
- test sql
Boldly try it with the postgres command, there must be nothing wrong with it
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)
Sure enough, the command hasn't been changed, not even
postgres
the library.
2.2 Remote login
Go directly to the postgres client, don’t believe it will be wrong
Do you feel cheated, hahaha