# Architecture

> Historical documentation restored from the Pigsty v1.5.1 tag.
---

> Pigsty consists of several [modules](#module) that can be combined according to different scenarios.



## Module

Pigsty currently offers four modules.

* [`INFRA`](/docs/c-infra/) is Pigsty's infrastructure module, including monitoring/alerting/visualization/logging/DNS/NTP components.
* [`NODES`](/docs/c-nodes/) is the node management module for configuring nodes, installing software, and collecting metrics and logs.
* [`PGSQL`](/docs/c-pgsql/) is a PostgreSQL deployment management module, including various PG cluster deployments and monitoring.
* [`REDIS`](/docs/c-redis/) is the Redis deployment management module, including Redis standalone/native cluster/sentinel [deployment](/docs/d-redis/) and monitoring.

| [Module](/docs/c-arch/#module) |   [Conecpt](/docs/c-concept/)    |     [Deploy](/docs/d-deploy/)     |    [Config](/docs/v-config/)    |   [Playbook](/docs/p-playbook/)   |
| :------------------------: | :--------------------------: | :---------------------------: | :-------------------------: | :---------------------------: |
|          `INFRA`           | [Concept: INFRA](/docs/c-infra/) | [Deploy: INFRA](/docs/d-deploy/)  | [Config: INFRA](/docs/v-infra/) | [Playbook: INFRA](/docs/p-infra/) |
|          `NODES`           | [Concept: NODES](/docs/c-nodes/) | [Deploy: NODES](/docs/d-prepare/) | [Config: NODES](/docs/v-nodes/) | [Playbook: NODES](/docs/p-nodes/) |
|          `PGSQL`           | [Concept: PGSQL](/docs/c-pgsql/) |  [Deploy: PGSQL](/docs/d-pgsql/)  | [Config: PGSQL](/docs/v-pgsql/) | [Playbook: PGSQL](/docs/p-pgsql/) |
|          `REDIS`           | [Concept: REDIS](/docs/c-redis/) |  [Deploy: REDIS](/docs/d-redis/)  | [Config: REDIS](/docs/v-redis/) | [Playbook: REDIS](/docs/p-redis/) |



## Usage

> You can choose which modules to enable on which nodes based on different requirements.

Pigsty will perform a singleton installation by default, initializing the node as a [meta node](/docs/c-nodes/#meta-node) with **INFRA**, **NODES**, & **PGSQL**.

You can join other [nodes](/docs/c-nodes/#node) and install different databases.

### Singleton Deploy

If you want to use Pigsty as a battery-included **singleton PostgreSQL distribution**, install the **INFRA**, **NODES**, & **PGSQL** modules sequentially on a node.

![](/img/history/v1.5/ARCH.gif)

Execute [`infra.yml`](/docs/p-infra/) playbook to install Pigsty on a singleton meta, deploy **infrastructure** on the node, and pull up a singleton PostgreSQL [database cluster](#database-cluster). The node with Pigsty fully installed is called a [meta node](/docs/c-nodes/#meta-node).

Pigsty is capable of more than that. It can monitor and manage more nodes and databases.

### Host Monitoring

If you want to create a large-scale **Host Monitoring System**, just install the **INFRA** module on one node and the **NODES** module on all the monitored nodes. All nodes will be configured with software sources, software packages, DNS, NTP, node monitoring, log collection, and DCS Agent components. Nodes that are included in Pigsty management will come with detailed metrics and can be deployed with various database modules.

![](/img/history/v1.5/NODES.gif)

Use [`nodes.yml`](/docs/p-nodes/#nodes) playbook to install the **NODES** module on meta nodes for more nodes to be included in Pigsty management.



### Database Cluster

After incorporating the nodes into Pigsty, these nodes can be further deployed with various **database clusters**.

If you want to **manage many PostgreSQL clusters**, install the PGSQL module again on those nodes included in Pigsty management. You can [deploy](/docs/d-pgsql/) various PGSQL clusters with one click: singleton, one primary & n replica HA cluster, sync standby cluster, quorum commit cluster, offline replica, standby cluster, delayed replica cluster, Citus cluster, TimescaleDB cluster, MatrixDB data warehouse.

![](/img/history/v1.5/SANDBOX.gif)

If you want to manage many Redis clusters, install the **REDIS** module on the included nodes in Pigsty management.

Use [`pgsql.yml`](/docs/p-pgsql/#pgsql) to create a HA PostgreSQL cluster, [`redis.yml`](/docs/p-redis/#redis) to develop standalone, native, sentinel Redis clusters, and [`pgsql-matrixdb.yml `](/docs/p-pgsql/#pgsql-matrixdb) to deploy the Greenplum/MatrixDB data warehouse.

Pigsty will subsequently add new types of database modules on demand: **KAFKA**, **MINIO**, **MONGO**, etc.





## Model

A complete Pigsty system can be called a **Deployment** or **Environment**.

> For example, production environment, test environment, pre-distribution environment, etc.

**A Pigsty deployment consists of two parts: an infra set & multiple clusters**, both described by an [Inventory](/docs/v-config/#config-file).

* [Infra](/docs/c-infra/): deployed on [meta nodes](/docs/c-nodes/), monitoring, DNS, NTP, DCS, Yum repos, etc.
* [Database Cluster](#database-cluster): autonomous (database) service unit deployed on [nodes](/docs/c-nodes/#node).

The cluster contains **nodes**, **instances**, and **services** three core resources: a cluster contains multiple instances deployed on multiple [nodes](/docs/c-nodes/#node), providing various [services](/docs/c-service/). Each database instance will have a more subdivided ER model.



![](/img/history/v1.5/ER-INFRA.gif)
