下载镜像
bash
[root@iZ2ze3qc9ouxm10ykn3cvdZ ~]# docker pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/enmotech/opengauss:5.0.2
5.0.2: Pulling from ddn-k8s/docker.io/enmotech/opengauss
2ec76a50fe7c: Pull complete
e48b50219b49: Pull complete
512e203af48f: Pull complete
90e70327448f: Pull complete
00142ce06a26: Pull complete
Digest: sha256:6599f26e0eb1a4c56ecb5db49c386015de0544313504a0a49e1e8041b71afd07
Status: Downloaded newer image for swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/enmotech/opengauss:5.0.2
swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/enmotech/opengauss:5.0.2
[root@iZ2ze3qc9ouxm10ykn3cvdZ ~]# docker tag swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/enmotech/opengauss:5.0.2 opengauss:5.0.2
[root@iZ2ze3qc9ouxm10ykn3cvdZ ~]#
运行容器
以下命令配置了名称、密码、端口映射(宿主机9000)、数据卷持久化
bash
root@iZ2ze3qc9ouxm10ykn3cvdZ ~]# docker run --name opengauss502 --privileged=true -d -e GS_PASSWORD=Test@123 -p9000:5432 -v /data/dockervol:/var/lib/opengauss opengauss:5.0.2
7df8844665ff0f384bc6561c329ac4bd7004f57f8812daa0a2d517b56f21b602
[root@iZ2ze3qc9ouxm10ykn3cvdZ ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7df8844665ff opengauss:5.0.2 "entrypoint.sh gauss..." 7 seconds ago Up 6 seconds 0.0.0.0:9000->5432/tcp, :::9000->5432/tcp opengauss502
[root@iZ2ze3qc9ouxm10ykn3cvdZ ~]#
开启防火墙
bash
[root@localhost ~]# firewall-cmd --add-port=9000/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
为高斯数据库增加管理员
以下命令的作用:进入容器、切换omm用户、进入数据库、创建my_root用户、为新建用户赋权限、退出。
bash
[root@iZ2ze3qc9ouxm10ykn3cvdZ ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7df8844665ff opengauss:5.0.2 "entrypoint.sh gauss..." 2 minutes ago Up 2 minutes 0.0.0.0:9000->5432/tcp, :::9000->5432/tcp opengauss502
[root@iZ2ze3qc9ouxm10ykn3cvdZ ~]# docker exec -ti 7df8844665ff /bin/bash
root@7df8844665ff:/# su - omm
omm@7df8844665ff:~$ gsql -d postgres -r
gsql ((openGauss 5.0.2 build 48a25b11) compiled at 2024-05-14 10:26:01 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=# create user my_root identified by 'Test@123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
openGauss=# alter user my_root sysadmin;
ALTER ROLE
openGauss=# \q
omm@7df8844665ff:~$
logout
root@7df8844665ff:/#
exit
配置Navicat连接
新增PostgreSQL类型的连接,配置ip、端口,及新建的用户、密码。进行登录测试。