Skip to content

Commit f7c0221

Browse files
xuchen-plusmaosendmetasoul01
committed
[Docs] Add deployment docs (#437)
* add postgres cluster doc Signed-off-by: maosen <sunmaosen@dmetasoul.com> * fix cn sidebar name Signed-off-by: chenxu <chenxu@dmetasoul.com> --------- Signed-off-by: maosen <sunmaosen@dmetasoul.com> Signed-off-by: chenxu <chenxu@dmetasoul.com> Co-authored-by: maosen <sunmaosen@dmetasoul.com> Co-authored-by: chenxu <chenxu@dmetasoul.com>
1 parent fca0b22 commit f7c0221

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Deploy HA PostgreSQL Cluster
2+
3+
<!--
4+
SPDX-FileCopyrightText: 2023 LakeSoul Contributors
5+
6+
SPDX-License-Identifier: Apache-2.0
7+
-->
8+
9+
## Pigsty
10+
11+
We recommend using automation tools such as Pigsty to deploy a production PostgreSQL cluster with HA.
12+
13+
Pigsty Introduction : https://doc.pigsty.cc/
14+
15+
### Download
16+
```ini
17+
curl -L https://get.pigsty.cc/v2.5.1/pigsty-v2.5.1.tgz -o ~/pigsty.tgz
18+
curl -L https://get.pigsty.cc/v2.5.1/pigsty-pkg-v2.5.1.el7.x86_64.tgz -o /tmp/pkg.tgz
19+
```
20+
### Install and Deploy
21+
22+
1、set up password-less login for all nodes including self
23+
```ini
24+
ssh-keygen -t rsa
25+
ssh-copy-id root@hosts
26+
```
27+
28+
2、initialize in all nodes
29+
30+
```ini
31+
bash -c "$(curl -fsSL https://get.pigsty.cc/latest)"
32+
cd ~/pigsty
33+
./bootstrap
34+
```
35+
36+
3、modify ~/pigsty/pigsty.yml in the primary node as below
37+
38+
```yaml
39+
all:
40+
children:
41+
# infra cluster for proxy, monitor, alert, etc..
42+
infra: { hosts: { 192.168.17.91: { infra_seq: 1 } } }
43+
# etcd cluster for ha postgres
44+
etcd: { hosts: { 192.168.17.91: { etcd_seq: 1 } }, vars: { etcd_cluster: etcd } }
45+
# minio cluster, optional backup repo for pgbackrest
46+
#minio: { hosts: { 192.168.17.91: { minio_seq: 1 } }, vars: { minio_cluster: minio } }
47+
# postgres cluster 'pg-meta' with single primary instance
48+
pg-test:
49+
hosts:
50+
192.168.17.91: { pg_seq: 1, pg_role: primary } # primary instance, leader of cluster
51+
192.168.25.215: { pg_seq: 2, pg_role: replica } # replica instance, follower of leader
52+
192.168.28.137: { pg_seq: 3, pg_role: replica, pg_offline_query: true } # replica with offline access
53+
vars:
54+
pg_cluster: pg-test # define pgsql cluster name
55+
pg_users: [{ name: test , password: test , pgbouncer: true , roles: [ dbrole_admin ] }]
56+
pg_databases: [{ name: test }]
57+
pg_vip_enabled: true
58+
pg_vip_address: 192.168.17.92/24
59+
pg_vip_interface: eth0
60+
node_tune: tiny
61+
pg_conf: tiny.yml
62+
node_crontab: # make a full backup on monday 1am, and an incremental backup during weekdays
63+
- '00 01 * * 1 postgres /pg/bin/pg-backup full'
64+
- '00 01 * * 2,3,4,5,6,7 postgres /pg/bin/pg-backup'
65+
vars: # global parameters
66+
version: v2.5.1 # pigsty version string
67+
admin_ip: 192.168.17.91 # admin node ip address
68+
region: china # upstream mirror region: default,china,europe
69+
```
70+
:::tip
71+
pg_vip_address is needed
72+
:::
73+
74+
4、install
75+
```ini
76+
./install.yml
77+
```
78+
79+
### Check
80+
```ini
81+
patronictl -c /etc/patroni/patroni.yml list
82+
```
83+
:::tip
84+
Switch Command:patronictl -c /etc/patroni/patroni.yml switchover
85+
86+
Data Backup Command:/pg/bin/pg-backup full; Full and incremental backup tasks are configured in /etc/crontab
87+
:::
88+
89+
### Monitor
90+
Grafana
91+
```ini
92+
http://192.168.17.91:3000
93+
```
94+
:::tip
95+
use your ip address
96+
:::

website/i18n/zh-Hans/docusaurus-plugin-content-docs/current.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
"sidebar.tutorialSidebar.category.Usage Docs": {
1515
"message": "使用文档",
1616
"description": "The label for category Usage Docs in sidebar tutorialSidebar"
17+
},
18+
"sidebar.tutorialSidebar.category.Deployment": {
19+
"message": "生产部署",
20+
"description": "The label for category Deployment in sidebar tutorialSidebar"
1721
}
1822
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# 部署 PostgreSQL 高可用集群
2+
3+
<!--
4+
SPDX-FileCopyrightText: 2023 LakeSoul Contributors
5+
6+
SPDX-License-Identifier: Apache-2.0
7+
-->
8+
9+
## 使用Pigsty安装部署
10+
11+
我们推荐使用自动化工具部署 PostgreSQL 高可用集群,例如 Pigsty。
12+
13+
Pigsty 官方介绍: https://doc.pigsty.cc/#/zh/README
14+
15+
### 下载Pigsty安装包
16+
```ini
17+
curl -L https://get.pigsty.cc/v2.5.1/pigsty-v2.5.1.tgz -o ~/pigsty.tgz
18+
curl -L https://get.pigsty.cc/v2.5.1/pigsty-pkg-v2.5.1.el7.x86_64.tgz -o /tmp/pkg.tgz
19+
```
20+
### 安装部署
21+
22+
1、各节点ssh免密登陆
23+
```ini
24+
ssh-keygen -t rsa
25+
ssh-copy-id root@hosts
26+
```
27+
:::tip
28+
hosts 为包含自己在内的所有节点,都要免密
29+
:::
30+
31+
2、各节点初始化
32+
33+
```ini
34+
bash -c "$(curl -fsSL https://get.pigsty.cc/latest)"
35+
cd ~/pigsty
36+
./bootstrap
37+
```
38+
39+
3、主节点配置集群信息,修改~/pigsty/pigsty.yml,参考如下:
40+
41+
```yaml
42+
all:
43+
children:
44+
# infra cluster for proxy, monitor, alert, etc..
45+
infra: { hosts: { 192.168.17.91: { infra_seq: 1 } } }
46+
# etcd cluster for ha postgres
47+
etcd: { hosts: { 192.168.17.91: { etcd_seq: 1 } }, vars: { etcd_cluster: etcd } }
48+
# minio cluster, optional backup repo for pgbackrest
49+
#minio: { hosts: { 192.168.17.91: { minio_seq: 1 } }, vars: { minio_cluster: minio } }
50+
# postgres cluster 'pg-meta' with single primary instance
51+
pg-test:
52+
hosts:
53+
192.168.17.91: { pg_seq: 1, pg_role: primary } # primary instance, leader of cluster
54+
192.168.25.215: { pg_seq: 2, pg_role: replica } # replica instance, follower of leader
55+
192.168.28.137: { pg_seq: 3, pg_role: replica, pg_offline_query: true } # replica with offline access
56+
vars:
57+
pg_cluster: pg-test # define pgsql cluster name
58+
pg_users: [{ name: test , password: test , pgbouncer: true , roles: [ dbrole_admin ] }]
59+
pg_databases: [{ name: test }]
60+
pg_vip_enabled: true
61+
pg_vip_address: 192.168.17.92/24
62+
pg_vip_interface: eth0
63+
node_tune: tiny
64+
pg_conf: tiny.yml
65+
node_crontab: # make a full backup on monday 1am, and an incremental backup during weekdays
66+
- '00 01 * * 1 postgres /pg/bin/pg-backup full'
67+
- '00 01 * * 2,3,4,5,6,7 postgres /pg/bin/pg-backup'
68+
vars: # global parameters
69+
version: v2.5.1 # pigsty version string
70+
admin_ip: 192.168.17.91 # admin node ip address
71+
region: china # upstream mirror region: default,china,europe
72+
```
73+
:::tip
74+
pg_vip_address需要配置
75+
:::
76+
77+
4、主节点执行安装脚本
78+
```ini
79+
./install.yml
80+
```
81+
82+
### 验证
83+
```ini
84+
patronictl -c /etc/patroni/patroni.yml list
85+
```
86+
:::tip
87+
手工切换:patronictl -c /etc/patroni/patroni.yml switchover
88+
89+
数据备份:/pg/bin/pg-backup full;在/etc/crontab中存在全量和增量备份定时任务
90+
:::
91+
92+
### 监控
93+
Grafana
94+
```ini
95+
http://192.168.17.91:3000
96+
```
97+
:::tip
98+
使用正确的ip地址
99+
:::

0 commit comments

Comments
 (0)