From 40e5149602e1d306c55fcf404a364396eafae44e Mon Sep 17 00:00:00 2001 From: taoying <2474671424@qq.com> Date: Thu, 6 Mar 2025 16:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0openGauss=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E9=83=A8=E7=BD=B2=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\345\203\217\345\256\211\350\243\205.md" | 127 ++++++++++++++++++ content/zh/menu/index.md | 1 + .../InstallationGuide/InstallationGuide.rst | 1 + 3 files changed, 129 insertions(+) create mode 100644 "content/zh/docs/InstallationGuide/\345\256\271\345\231\250\351\225\234\345\203\217\345\256\211\350\243\205.md" diff --git "a/content/zh/docs/InstallationGuide/\345\256\271\345\231\250\351\225\234\345\203\217\345\256\211\350\243\205.md" "b/content/zh/docs/InstallationGuide/\345\256\271\345\231\250\351\225\234\345\203\217\345\256\211\350\243\205.md" new file mode 100644 index 000000000..39dce3210 --- /dev/null +++ "b/content/zh/docs/InstallationGuide/\345\256\271\345\231\250\351\225\234\345\203\217\345\256\211\350\243\205.md" @@ -0,0 +1,127 @@ +# 容器镜像安装 +本章节主要介绍如何获取openGauss镜像,并通过Docker安装openGauss,以便用户能快速开启数据库之旅。 + +## 1. 获取镜像 +openGauss镜像主要有两种获取方式,分别可以通过`docker pull`和`docker load`拉取对应镜像,下面将详细介绍这两种获取路径。 +### 拉取dockerhub镜像 +opengauss 镜像支持x86-64、ARM64架构和openEuler 20.03 LTS操作系统版本,拉取镜像时无需指定架构和版本。 + +```bash +$ docker pull opengauss/opengauss:latest +``` +- 验证镜像状态 +```bash +$ docker images + +REPOSITORY TAG IMAGE ID CREATED SIZE +opengauss/opengauss latest 9aa832ba6684 2 hours ago 1.44GB +``` + +### 下载镜像包并加载 +- 下载镜像包(以openGauss7.0.0-RC1.B020/openEuler20.03/arm下的包为例) +``` bash +$ wget https://download-opengauss.osinfra.cn/archive_test/7.0.0-RC1/openGauss7.0.0-RC1.B020/openEuler20.03/arm/openGauss-Docker-7.0.0-RC1.tar +``` +- 加载镜像 +``` bash +$ docker load -i openGauss-Docker-7.0.0-RC1.tar +``` +- 验证镜像状态 +```bash +$ docker images + +REPOSITORY TAG IMAGE ID CREATED SIZE +opengauss latest 9aa832ba6684 2 hours ago 1.44GB +``` +>![](public_sys-resources/icon-note.png) **说明:** +> +> 以上镜像包会周期性更新,可以根据自身需求修改路径获取最新镜像包。
+> 镜像支持的操作系统暂时仅限于`openEuler 20.03` + + +## 2. 运行容器 +以`opengauss/opengauss:latest` 版本为例,以下命令将启动数据库并映射宿主机的端口到容器: +```bash +$ docker run --name opengauss --privileged=true -d -e GS_PASSWORD=YourPassoword -p 8888:5432 opengauss/opengauss:latest +``` + +### 启动参数 +- `--name opengauss`:为容器命名为`opengauss` +- `--privileged=true`: 授予容器特权模式 +- `-d`: 以后台模式运行容器 +- `-p 8888:5432`: 将容器的5432端口映射到宿主机的8888端口 + +##### 必选容器内环境变量 +- `-e GS_PASSWORD=YourPassoword`:设置数据库超级用户`omm`密码 + +使用 openGauss 镜像的时候,必须设置该参数,且不能为空或未定义。该参数用于设置 openGauss 数据库的超级用户`omm`。安装过程中将默认创建omm超级用户,该用户名目前无法更改。 + +openGauss 镜像配置了本地信任机制,因此在容器内连接数据库时无需密码,但若从容器外部(其它主机或者容器)连接,则必须要输入密码。 + +###### **密码要求** + +- 密码长度必须至少为8个字符。 +- 必须同时包含大写字母、小写字母、数字、以及特殊符号。 +- 支持的特殊符号仅包含`\#?!@$%^&\*-`(其中`!$&`需使用转义符号”\“)。 + +##### 可选容器内环境变量 +- `-e GS_NODENAME=YourNodeName`:指定数据库节点名称,默认为`gaussdb` +- `-e GS_USERNAME=YourUserName`:指定数据库连接用户名,默认为测试用户`gaussdb` +- `-e GS_USER_PASSWORD=YourUserPassword`:指定用户`$GS_USERNAME`密码,默认为`$GS_PASSWORD` +- `-e GS_PORT=YourPort`:指定容器内数据库端口,默认为`5432` +- `-e GS_DB=YourDbName`:在容器内创建数据库,默认为`postgres` + + + +## 3. 容器运行测试 +### 验证容器运行状态 +```bash +$ docker ps +``` +输出示例: +``` +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +7abc538f242a opengauss/opengauss:latest "entrypoint.sh gauss…" About a minute ago Up About a minute 0.0.0.0:8888->5432/tcp opengauss +``` + +### 容器内部连接数据库 + +进入容器: +``` +$ docker exec -it bash +``` + +登录`omm`超级用户: +``` +$ su omm +$ gsql -d postgres -p 5432 +``` + +### 从宿主机连接数据库 + +宿主机可以通过以下命令连接数据库(需安装`gsql`客户端): +```shell +$ gsql -d postgres -U gaussdb -W YourPassoword -h your-host-ip -p 8888 +``` + +## 4. 其他配置 +### 数据持久化 + +通过以下命令,将宿主机的`/opengauss`目录挂载到容器的`/var/lib/opengauss`目录,实现数据的持久化存储: +```bash +$ docker run --name opengauss --privileged=true -d -e GS_PASSWORD=YourPassoword -v /opengauss:/var/lib/opengauss opengauss/opengauss:latest +``` + +### 参数配置 +容器内的配置文件路径: +``` +/var/lib/opengauss/data/postgresql.conf +``` + +修改完配置文件后,请使用以下命令重启容器以使更改生效: +```bash +docker restart +``` +若在容器外配置参数,需要挂载宿主机路径到容器内部的`/var/lib/opengauss`目录。 + +有关具体参数的修改,请参考 **[GUC参数说明](../DatabaseReference/GUC参数说明.md)** \ No newline at end of file diff --git a/content/zh/menu/index.md b/content/zh/menu/index.md index e332a8f39..8f623ceb4 100644 --- a/content/zh/menu/index.md +++ b/content/zh/menu/index.md @@ -203,6 +203,7 @@ headless: true - [使用openGauss]({{< relref "./docs/GettingStarted/使用openGauss.md" >}}) - [安装指南]({{< relref "./docs/InstallationGuide/InstallationGuide.md" >}}) - [安装概述]({{< relref "./docs/InstallationGuide/安装概述.md" >}}) + - [容器镜像安装]({{< relref "./docs/InstallationGuide/容器镜像安装.md" >}}) - [极简版安装]({{< relref "./docs/InstallationGuide/极简版安装.md" >}}) - [安装准备]({{< relref "./docs/InstallationGuide/安装准备.md" >}}) - [获取安装包]({{< relref "./docs/InstallationGuide/获取安装包.md" >}}) diff --git a/sphinx/source/InstallationGuide/InstallationGuide.rst b/sphinx/source/InstallationGuide/InstallationGuide.rst index 128a43dc3..7581b7f71 100644 --- a/sphinx/source/InstallationGuide/InstallationGuide.rst +++ b/sphinx/source/InstallationGuide/InstallationGuide.rst @@ -2,6 +2,7 @@ .. toctree:: ../content/zh/docs/InstallationGuide/安装概述 + ../content/zh/docs/InstallationGuide/容器镜像安装 极简版安装 企业版安装 ../content/zh/docs/InstallationGuide/卸载openGauss -- Gitee