华为提供了一个基于 CentOS 的企业级 Linux 发行版 EulerOS

openEuler下载及文档

openEuler
openEuler Docs

1. 安装Docker

yum install -y docker

安装完成检查

docker -v

2. 启动Docker

设置为开机自启,并检查启动状态

systemctl start docker
systemctl enable docker
systemctl status docker.service

3. Docker 的常用命令

操作 命令 说明
检索 docker search xxx docker hub上检索镜像的详细信息,如镜像的TAG
拉取 docker pull 镜像名:tag :tag是可选的,tag表示标签,多为软件的版本,默认是latest
列表 docker images 查看所有本地镜像
删除 docker rmi image-id 删除指定的本地镜像

前往dockerhub官网查询对应的镜像
Docker/opengauss

在这里插入图片描述
*上述不同镜像选用其一即可

4. 拉取 openGauss 镜像

docker pull enmotech/opengauss:latest

详细也可参考官方文档
enmotech/opengauss

[root@localhost ~]# docker pull aff123/opengauss:latest
latest: Pulling from aff123/opengauss
ac9208207ada: Pull complete 
1dabaac5cb40: Pull complete 
08a189450071: Pull complete 
503c2df67860: Pull complete 
1194ca45dcd1: Pull complete 
62d3fb34f266: Pull complete 
890b5fc9ee1d: Pull complete 
b0723d5e97ee: Pull complete 
cc21737ac089: Pull complete 
Digest: sha256:6ff688bb531170ccd1c9f49b0468a762da1d63403a8086d5d51a64beefbc4283
Status: Downloaded newer image for aff123/opengauss:latest

5. 创建openGuass容器并启动

启动openGuass实例

docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Admin@123 enmotech/opengauss:latest

// 密码可自行修改

openGauss的默认监听启动在容器内的5432端口上,如果想要从容器外部访问数据库,则需要在docker run的时候指定-p参数。比如以下命令将允许使用15432端口访问容器数据库。

docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Admin@123 -p 15432:5432 enmotech/opengauss:latest

在上述命令正常启动容器数据库之后,可以通过外部进行数据库访问

查看容器是否开启

[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                     NAMES
42dbb89a2e80        enmotech/opengauss:latest   "entrypoint.sh gauss…"   24 hours ago        Up 6 minutes        0.0.0.0:15432->5432/tcp   opengauss

如果容器实例status状态为Exited,start启动下即可

docker start [容器ID or 容器名]

6. 连接数据库

docker exec -it opengauss sh
//or
docker exec -it [容器id] sh

注意要切换到 omm用户,使用 gsql命令连接数据库

[root@localhost ~]# docker exec -it 6c234a5f615d sh
sh-4.2# su - omm
Last login: Wed Jul  8 06:36:43 UTC 2020 on pts/1
[omm@6c234a5f615d ~]$ gsql
gsql ((openGauss 3.0.0 build 38a9312a) compiled at 2020-05-27 14:58:08 commit 472 last mr 549 )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

omm=# 

至此,就可以使用了

可以使用DataGrip、Data Studio等数据库管理软件连接数据库
在这里插入图片描述

=================================
如果要退出Docker

[omm@6c234a5f615d /]$ gsql
gsql ((openGauss 1.0.0 build 38a9312a) compiled at 2020-05-27 14:58:08 commit 472 last mr 549 )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

omm=# exit
[omm@6c234a5f615d home]$ exit
sh-4.2# su root
[root@6c234a5f615d /]# exit
exit
sh-4.2# 
sh-4.2# exit
exit
[root@localhost ~]# 

停止 Docker

systemctl stop docker
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐