Skip to content

Commit

Permalink
Merge branch 'POLARDB_11_DEV' into POLARDB_11_STABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdrivingduck committed Aug 26, 2024
2 parents ffa2fa5 + 37be626 commit 2b4dc1e
Show file tree
Hide file tree
Showing 34 changed files with 584 additions and 129 deletions.
9 changes: 4 additions & 5 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ PolarDB for PostgreSQL 采用了基于 Shared-Storage 的存储计算分离架

## 快速部署

如果您已安装 Docker,那么可以从 DockerHub 上拉取 PolarDB for PostgreSQL 的 本地存储实例镜像,创建、运行并进入容器,然后直接使用 PolarDB 实例:
如果您已安装 Docker,那么拉取 PolarDB-PG 的单机实例镜像,创建、运行并进入容器,然后直接使用 PolarDB-PG 实例:

```bash
# 拉取单节点 PolarDB 镜像
docker pull polardb/polardb_pg_local_instance
# 创建运行并进入容器
docker run -it --rm polardb/polardb_pg_local_instance psql
# 拉取镜像并运行容器
docker pull polardb/polardb_pg_local_instance:11
docker run -it --rm polardb/polardb_pg_local_instance:11 psql
# 测试实例可用性
postgres=# SELECT version();
version
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ For more information, see [Architecture](https://apsaradb.github.io/PolarDB-for-

## Quick Start with PolarDB

If you have Docker installed already,then you can pull the instance image of PolarDB for PostgreSQL based on local storage. Create, run and enter the container, and use PolarDB instance directly:
If you have Docker installed already,then you can pull the instance image of PolarDB-PG based on local storage. Create, run and enter the container, and use PolarDB-PG instance directly:

```bash
# pull the instance image from DockerHub
docker pull polardb/polardb_pg_local_instance
# create, run and enter the container
docker run -it --rm polardb/polardb_pg_local_instance psql
# pull the instance image and run the container
docker pull polardb/polardb_pg_local_instance:11
docker run -it --rm polardb/polardb_pg_local_instance:11 psql
# check
postgres=# SELECT version();
version
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/configs/navbar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const zh: NavbarConfig = [
],
},
{
text: "部署 PolarDB 数据库",
text: "部署 PolarDB-PG 数据库",
children: [
"/zh/deploying/db-localfs.html",
"/zh/deploying/db-pfs.html",
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/configs/sidebar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const zh: SidebarConfig = {
],
},
{
text: "部署 PolarDB 数据库",
text: "部署 PolarDB-PG 数据库",
children: [
"/zh/deploying/db-localfs.md",
"/zh/deploying/db-pfs.md",
Expand Down
28 changes: 24 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,28 @@ footer: Apache 2.0 Licensed | Copyright © Alibaba Group, Inc.

Pull the [local instance image](https://hub.docker.com/r/polardb/polardb_pg_local_instance/tags) of PolarDB for PostgreSQL based on local storage. Create and run the container, and try PolarDB-PG instance directly:

:::: code-group
::: code-group-item DockerHub

```bash:no-line-numbers
# pull the instance image and run the container
docker pull polardb/polardb_pg_local_instance:11
docker run -it --rm polardb/polardb_pg_local_instance:11 psql
# check
postgres=# SELECT version();
version
--------------------------------
PostgreSQL 11.9 (POLARDB 11.9)
(1 row)
```

:::
::: code-group-item Alibaba Cloud ACR

```bash:no-line-numbers
# pull the instance image from DockerHub
docker pull polardb/polardb_pg_local_instance
# create and run the container
docker run -it --rm polardb/polardb_pg_local_instance psql
# pull the instance image and run the container
docker pull registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:11
docker run -it --rm registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:11 psql
# check
postgres=# SELECT version();
version
Expand All @@ -24,6 +41,9 @@ postgres=# SELECT version();
(1 row)
```

:::
::::

<div class="features">

<div class="feature">
Expand Down
74 changes: 69 additions & 5 deletions docs/deploying/db-localfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ minute: 15

## 拉取镜像

我们在 DockerHub 上提供了 PolarDB-PG 的 [本地实例镜像](https://hub.docker.com/r/polardb/polardb_pg_local_instance/tags),里面已包含启动 PolarDB-PG 本地存储实例的入口脚本。镜像目前支持 `linux/amd64``linux/arm64` 两种 CPU 架构。
我们已提供 PolarDB-PG 的 [单机实例镜像](https://hub.docker.com/r/polardb/polardb_pg_local_instance/tags),里面已包含启动 PolarDB-PG 单机实例的入口脚本。镜像目前支持 `linux/amd64``linux/arm64` 两种 CPU 架构。

:::: code-group
::: code-group-item DockerHub

```bash:no-line-numbers
docker pull polardb/polardb_pg_local_instance:11
```

:::
::: code-group-item 阿里云 ACR

```bash:no-line-numbers
docker pull polardb/polardb_pg_local_instance
docker pull registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:11
```

:::
::::

## 初始化数据库

新建一个空白目录 `${your_data_dir}` 作为 PolarDB-PG 实例的数据目录。启动容器时,将该目录作为 VOLUME 挂载到容器内,对数据目录进行初始化。在初始化的过程中,可以传入环境变量覆盖默认值:
Expand All @@ -30,32 +43,83 @@ docker pull polardb/polardb_pg_local_instance

使用如下命令初始化数据库:

:::: code-group
::: code-group-item DockerHub

```bash:no-line-numbers
docker run -it --rm \
--env POLARDB_PORT=5432 \
--env POLARDB_USER=u1 \
--env POLARDB_PASSWORD=your_password \
-v ${your_data_dir}:/var/polardb \
polardb/polardb_pg_local_instance:11 \
echo 'done'
```

:::
::: code-group-item 阿里云 ACR

```bash:no-line-numbers
docker run -it --rm \
--env POLARDB_PORT=5432 \
--env POLARDB_USER=u1 \
--env POLARDB_PASSWORD=your_password \
-v ${your_data_dir}:/var/polardb \
polardb/polardb_pg_local_instance \
registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:11 \
echo 'done'
```

:::
::::

## 启动 PolarDB-PG 服务

数据库初始化完毕后,使用 `-d` 参数以后台模式创建容器,启动 PolarDB-PG 服务。通常 PolarDB-PG 的端口需要暴露给外界使用,使用 `-p` 参数将容器内的端口范围暴露到容器外。比如,初始化数据库时使用的是 `5432-5434` 端口,如下命令将会把这三个端口映射到容器外的 `54320-54322` 端口:

:::: code-group
::: code-group-item DockerHub

```bash:no-line-numbers
docker run -d \
-p 54320-54322:5432-5434 \
-v ${your_data_dir}:/var/polardb \
polardb/polardb_pg_local_instance
polardb/polardb_pg_local_instance:11
```

:::
::: code-group-item 阿里云 ACR

```bash:no-line-numbers
docker run -d \
-p 54320-54322:5432-5434 \
-v ${your_data_dir}:/var/polardb \
registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:11
```

:::
::::

或者也可以直接让容器与宿主机共享网络:

:::: code-group
::: code-group-item DockerHub

```bash:no-line-numbers
docker run -d \
--network=host \
-v ${your_data_dir}:/var/polardb \
polardb/polardb_pg_local_instance
polardb/polardb_pg_local_instance:11
```

:::
::: code-group-item 阿里云 ACR

```bash:no-line-numbers
docker run -d \
--network=host \
-v ${your_data_dir}:/var/polardb \
registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:11
```

:::
::::
8 changes: 4 additions & 4 deletions docs/deploying/db-pfs-curve.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ minute: 15

## 源码下载

在前置文档中,我们已经从 DockerHub 上拉取了 PolarDB 开发镜像,并且进入到了容器中。进入容器后,从 [GitHub](https://github.com/ApsaraDB/PolarDB-for-PostgreSQL) 上下载 PolarDB for PostgreSQL 的源代码,稳定分支为 `POLARDB_11_STABLE`。如果因网络原因不能稳定访问 GitHub,则可以访问 [Gitee 国内镜像](https://gitee.com/mirrors/PolarDB-for-PostgreSQL)
在前置文档中,我们已经从 DockerHub 上拉取了 PolarDB 开发镜像,并且进入到了容器中。进入容器后,从 [GitHub](https://github.com/ApsaraDB/PolarDB-for-PostgreSQL) 上下载 PolarDB for PostgreSQL 的源代码,稳定分支为 `POLARDB_11_STABLE`。如果因网络原因不能稳定访问 GitHub,则可以访问 [Gitee](https://gitee.com/mirrors/PolarDB-for-PostgreSQL)

:::: code-group
::: code-group-item GitHub
Expand All @@ -24,7 +24,7 @@ git clone -b POLARDB_11_STABLE https://github.com/ApsaraDB/PolarDB-for-PostgreSQ
```

:::
::: code-group-item Gitee 国内镜像
::: code-group-item Gitee

```bash:no-line-numbers
git clone -b POLARDB_11_STABLE https://gitee.com/mirrors/PolarDB-for-PostgreSQL
Expand All @@ -50,7 +50,7 @@ cd PolarDB-for-PostgreSQL/
```

::: warning
上述脚本在编译完成后,会自动部署一个基于 **本地文件系统** 的实例,运行于 `5432` 端口上。
上述脚本在编译完成后,会自动部署一个基于 **单机文件系统** 的实例,运行于 `5432` 端口上。

手动键入以下命令停止这个实例,以便 **在 PFS 和共享存储上重新部署实例**

Expand Down Expand Up @@ -146,7 +146,7 @@ $HOME/tmp_basedir_polardb_pg_1100_bld/bin/psql \
```

::: warning
上述脚本在编译完成后,会自动部署一个基于 **本地文件系统** 的实例,运行于 `5432` 端口上。
上述脚本在编译完成后,会自动部署一个基于 **单机文件系统** 的实例,运行于 `5432` 端口上。

手动键入以下命令停止这个实例,以便 **在 PFS 和共享存储上重新部署实例**

Expand Down
2 changes: 1 addition & 1 deletion docs/deploying/db-pfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ minute: 15

<ArticleInfo :frontmatter=$frontmatter></ArticleInfo>

本文将指导您在分布式文件系统 PolarDB File System(PFS)上编译部署 PolarDB,适用于已经在共享存储上格式化并挂载 PFS 文件系统的计算节点。
本文将指导您在分布式文件系统 PolarDB File System(PFS)上编译部署 PolarDB-PG,适用于已经在共享存储上格式化并挂载 PFS 文件系统的计算节点。

[[toc]]

Expand Down
10 changes: 2 additions & 8 deletions docs/deploying/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ minute: 10
2. **文件系统层**:由于 PostgreSQL 将数据存储在文件中,因此需要在块存储设备上架设文件系统。根据底层块存储设备的不同,可以选用单机文件系统(如 ext4)或分布式文件系统 [PolarDB File System(PFS)](https://github.com/ApsaraDB/PolarDB-FileSystem)
3. **数据库层**:PolarDB for PostgreSQL 的编译和部署环境。

以下表格给出了三个层次排列组合出的的不同实践方式,其中的步骤包含:

- 存储层:块存储设备的准备
- 文件系统:PolarDB File System 的编译、挂载
- 数据库层:PolarDB for PostgreSQL 各集群形态的编译部署

我们强烈推荐使用发布在 DockerHub 上的 [PolarDB 开发镜像](https://hub.docker.com/r/polardb/polardb_pg_devel/tags) 来完成实践!开发镜像中已经包含了文件系统层和数据库层所需要安装的所有依赖,无需手动安装。
以下表格给出了三个层次排列组合出的的不同实践方式:

| | 块存储 | 文件系统 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | ---------------------------------------------------------------- |
| [实践 1(极简本地部署)](./db-localfs.md) | 本地 SSD | 本地文件系统(如 ext4) |
| [实践 1(极简本地部署)](./db-localfs.md) | 本地 SSD | 单机文件系统(如 ext4) |
| [实践 2(生产环境最佳实践)](./storage-aliyun-essd.md) <a href="https://developer.aliyun.com/live/249628"><Badge type="tip" text="视频" vertical="top" /></a> | 阿里云 ECS + ESSD 云盘 | PFS |
| [实践 3(生产环境最佳实践)](./storage-curvebs.md) <a href="https://developer.aliyun.com/live/250218"><Badge type="tip" text="视频" vertical="top" /></a> | [CurveBS](https://opencurve.io/Curve/HOME) 共享存储 | [PFS for Curve](https://github.com/opencurve/PolarDB-FileSystem) |
| [实践 4](./storage-ceph.md) | Ceph 共享存储 | PFS |
Expand Down
26 changes: 23 additions & 3 deletions docs/deploying/fs-pfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,39 @@ PolarDB File System,简称 PFS 或 PolarFS,是由阿里云自主研发的高

## PFS 编译安装

推荐使用 [DockerHub](https://hub.docker.com/u/polardb) 上的 PolarDB for PostgreSQL [可执行文件镜像](https://hub.docker.com/r/polardb/polardb_pg_binary/tags),目前支持 `linux/amd64``linux/arm64` 两种架构,其中已经包含了编译完毕的 PFS 工具,无需手动编译安装。通过以下命令进入容器即可:
推荐使用 PolarDB-PG 的 [可执行文件镜像](https://hub.docker.com/r/polardb/polardb_pg_binary/tags),目前支持 `linux/amd64``linux/arm64` 两种架构,其中已经包含了编译完毕的 PFS 工具,无需手动编译安装。通过以下命令进入容器即可:

:::: code-group
::: code-group-item DockerHub

```shell:no-line-numbers
docker pull polardb/polardb_pg_binary:11
docker run -it \
--cap-add=SYS_PTRACE \
--privileged=true \
--name polardb_pg \
--shm-size=512m \
polardb/polardb_pg_binary:11 \
bash
```

:::
::: code-group-item 阿里云 ACR

```shell:no-line-numbers
docker pull polardb/polardb_pg_binary
docker pull registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_binary:11
docker run -it \
--cap-add=SYS_PTRACE \
--privileged=true \
--name polardb_pg \
--shm-size=512m \
polardb/polardb_pg_binary \
registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_binary:11 \
bash
```

:::
::::

PFS 的手动编译安装方式请参考 PFS 的 [README](https://github.com/ApsaraDB/polardb-file-system/blob/master/Readme-CN.md),此处不再赘述。

## 块设备重命名
Expand Down
2 changes: 1 addition & 1 deletion docs/deploying/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PolarDB for PostgreSQL 采用了基于 Shared-Storage 的存储计算分离架

![software-level](../imgs/software-level.png)

为保证所有计算节点能够以相同的可见性视角访问分布式块存储设备,PolarDB 需要使用分布式文件系统 [PolarDB File System(PFS)](https://github.com/ApsaraDB/PolarDB-FileSystem) 来访问块设备,其实现原理可参考发表在 2018 年 VLDB 上的论文[^polarfs-paper];如果所有计算节点都可以本地访问同一个块存储设备,那么也可以不使用 PFS,直接使用本地的单机文件系统(如 ext4)。这是与 PostgreSQL 的不同点之一。
为保证所有计算节点能够以相同的可见性视角访问分布式块存储设备,PolarDB-PG 需要使用分布式文件系统 [PolarDB File System(PFS)](https://github.com/ApsaraDB/PolarDB-FileSystem) 来访问块设备,其实现原理可参考发表在 2018 年 VLDB 上的论文[^polarfs-paper];如果所有计算节点都可以本地访问同一个块存储设备,那么也可以不使用 PFS,直接使用本地的单机文件系统(如 ext4)。这是与 PostgreSQL 的不同点之一。

[^polarfs-paper]: [PolarFS: an ultra-low latency and failure resilient distributed file system for shared storage cloud database](https://www.vldb.org/pvldb/vol11/p1849-cao.pdf)
32 changes: 26 additions & 6 deletions docs/deploying/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,40 @@ minute: 5
- CentOS:[在 CentOS 上安装 Docker Engine](https://docs.docker.com/engine/install/centos/)
- RHEL:[在 RHEL 上安装 Docker Engine](https://docs.docker.com/engine/install/rhel/)
- Fedora:[在 Fedora 上安装 Docker Engine](https://docs.docker.com/engine/install/fedora/)
- macOS(支持 M1 芯片)[在 Mac 上安装 Docker Desktop](https://docs.docker.com/desktop/mac/install/),并建议将内存调整为 4GB 以上
- macOS:[在 Mac 上安装 Docker Desktop](https://docs.docker.com/desktop/mac/install/),并建议将内存调整为 4GB 以上
- Windows:[在 Windows 上安装 Docker Desktop](https://docs.docker.com/desktop/windows/install/),并建议将内存调整为 4GB 以上

从 DockerHub 上拉取 PolarDB for PostgreSQL 的 [本地存储实例镜像](https://hub.docker.com/r/polardb/polardb_pg_local_instance/tags),创建并运行容器,然后直接试用 PolarDB-PG:
拉取 PolarDB for PostgreSQL 的 [单机实例镜像](https://hub.docker.com/r/polardb/polardb_pg_local_instance/tags),运行容器并试用 PolarDB-PG:

:::: code-group
::: code-group-item DockerHub

```bash:no-line-numbers
# 拉取镜像并运行容器
docker pull polardb/polardb_pg_local_instance:11
docker run -it --rm polardb/polardb_pg_local_instance:11 psql
# 测试可用性
postgres=# SELECT version();
version
--------------------------------
PostgreSQL 11.9 (POLARDB 11.9)
(1 row)
```

:::
::: code-group-item 阿里云 ACR

```bash:no-line-numbers
# 拉取 PolarDB-PG 镜像
docker pull polardb/polardb_pg_local_instance
# 创建并运行容器
docker run -it --rm polardb/polardb_pg_local_instance psql
# 拉取镜像并运行容器
docker pull registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:11
docker run -it --rm registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:11 psql
# 测试可用性
postgres=# SELECT version();
version
--------------------------------
PostgreSQL 11.9 (POLARDB 11.9)
(1 row)
```

:::
::::
4 changes: 2 additions & 2 deletions docs/development/customize-dev-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ cd ~

在 PolarDB for PostgreSQL 源码库根目录的 `deps/` 子目录下,放置了在各个 Linux 发行版上编译安装 PolarDB 和 PFS 需要运行的所有依赖。因此,首先需要克隆 PolarDB 的源码库。

PolarDB for PostgreSQL 的代码托管于 [GitHub](https://github.com/ApsaraDB/PolarDB-for-PostgreSQL) 上,稳定分支为 `POLARDB_11_STABLE`。如果因网络原因不能稳定访问 GitHub,则可以访问 [Gitee 国内镜像](https://gitee.com/mirrors/PolarDB-for-PostgreSQL)
PolarDB for PostgreSQL 的代码托管于 [GitHub](https://github.com/ApsaraDB/PolarDB-for-PostgreSQL) 上,稳定分支为 `POLARDB_11_STABLE`。如果因网络原因不能稳定访问 GitHub,则可以访问 [Gitee](https://gitee.com/mirrors/PolarDB-for-PostgreSQL)

:::: code-group
::: code-group-item GitHub
Expand All @@ -210,7 +210,7 @@ git clone -b POLARDB_11_STABLE https://github.com/ApsaraDB/PolarDB-for-PostgreSQ
```

:::
::: code-group-item Gitee 国内镜像
::: code-group-item Gitee

```bash:no-line-numbers
sudo yum install -y git
Expand Down
Loading

0 comments on commit 2b4dc1e

Please sign in to comment.