PostgreSQL-HA 高可用集群在 Rainbond 上的部署方案
version: '3'
services:
proxy:
image: goodrain/proxy:latest
environment:
- PRIVATE_IP=127.0.0.1
- PUBLIC_IP=127.0.0.1
- SERVICE_PORT=5234
- PROXY_MODE=http
networks:
- overlay-net
restart: always
labels:
- "rainbond.app-env=enable"
- "rainbond.proxy=gr-proxy"
node1:
image: goodrain.me/pgsql-ha:v1.0.0
environment:
- PG_MODE=master
- CLUSTER_NAME=rainbond-pg
- PG_DATABASE=rainbond
- PG_USER=rainbond
- PG_PASSWORD=rainbond
- PG_ROOT_PASSWORD=rainbond
- PG_PRIMARY_HOST=node2
- PG_REPLICATION_USER=replica
- PG_REPLICATION_PASSWORD=replica
networks:
- overlay-net
restart: always
labels:
- "rainbond.app-env=enable"
- "rainbond.node=gr-node"
- "rainbond.cluster-init=true"
node2:
image: goodrain.me/pgsql-ha:v1.0.0
environment:
- PG_MODE=replica
- CLUSTER_NAME=rainbond-pg
- PG_DATABASE=rainbond
- PG_USER=rainbond
- PG_PASSWORD=rainbond
- PG_ROOT_PASSWORD=rainbond
- PG_PRIMARY_HOST=node1
- PG_REPLICATION_USER=replica
- PG_REPLICATION_PASSWORD=replica
networks:
- overlay-net
restart: always
labels:
- "rainbond.app-env=enable"
- "rainbond.node=gr-node"
networks:
overlay-net:
driver: overlay
这个YAML文件定义了一个基于Rainbond的PostgreSQL-HA集群的Docker Compose模板。它包括一个代理服务(proxy)和两个数据库节点(node1和node2),这两个节点配置为主从关系,从而形成一个高可用集群。环境变量被用来配置数据库的各种参数,确保集群的正常运行。这个模板展示了如何在Rainbond平台上部署一个高可用的PostgreSQL集群。
评论已关闭