File Hierarchy
Pigsty FHS
Pigsty’s home directory is located at ~/pigsty by default. The file structure within this directory is as follows:
#------------------------------------------------------------------------------
# pigsty
# ^-----@app # Extra application resources and examples
# ^-----@bin # Utility scripts
# ^-----@docs # Documentation (docsify-compatible)
# ^-----@files # Ansible file resources
# ^-----@victoria # VictoriaMetrics rule definitions
# ^-----@grafana # Grafana dashboards
# ^-----@postgres # /pg/bin/ scripts
# ^-----@migration # PGSQL migration task definitions
# ^-----@pki # Self-signed CA and certificates
# ^-----@roles # Ansible role implementations
# ^-----@templates # Ansible template files
# ^-----@vagrant # Vagrant sandbox VM templates
# ^-----@terraform # Terraform cloud VM provisioning templates
# ^-----configure # Configuration wizard script
# ^-----ansible.cfg # Ansible default configuration
# ^-----pigsty.yml # Pigsty default configuration file
# ^-----*.yml # Ansible playbooks
#------------------------------------------------------------------------------
# /etc/pigsty/
# ^-----@targets # File-based service discovery targets
# ^-----@dashboards # Grafana monitoring dashboards
# ^-----@datasources # Grafana data sources
# ^-----@playbooks # Ansible playbooks
#------------------------------------------------------------------------------
CA FHS
Pigsty’s self-signed CA is located in files/pki/ under the Pigsty home directory.
You must keep the CA key file secure: files/pki/ca/ca.key. This key is generated by the ca role during deploy.yml or infra.yml execution.
# pigsty/files/pki
# ^-----@ca # Self-signed CA key and certificate
# ^[email protected] # CRITICAL: Keep this secret
# ^[email protected] # CRITICAL: Trusted everywhere
# ^-----@csr # Certificate signing requests
# ^-----@misc # Miscellaneous certificates, issued certs
# ^-----@etcd # ETCD server certificates
# ^-----@minio # MinIO server certificates
# ^-----@nginx # Nginx SSL certificates
# ^-----@infra # Infra client certificates
# ^-----@pgsql # PostgreSQL server certificates
# ^-----@mongo # MongoDB/FerretDB server certificates
# ^-----@mysql # MySQL server certificates (placeholder)
Nodes managed by Pigsty will have the following certificate files installed:
/etc/pki/ca.crt # Root certificate added to all nodes
/etc/pki/ca-trust/source/anchors/ca.crt # Symlink to system trust anchors
All infra nodes will have the following certificates:
/etc/pki/infra.crt # Infra node certificate
/etc/pki/infra.key # Infra node private key
When your admin node fails, the files/pki directory and pigsty.yml file should be available on the backup admin node. You can use rsync to achieve this:
# run on meta-1, rsync to meta2
cd ~/pigsty;
rsync -avz ./ meta-2:~/pigsty
NODE FHS
The node data directory is specified by the node_data parameter, defaulting to /data, owned by root with permissions 0777.
Each component’s default data directory is located under this data directory:
/data
# ^-----@postgres # PostgreSQL database directory
# ^-----@backups # PostgreSQL backup directory (when no dedicated backup disk)
# ^-----@redis # Redis data directory (shared by multiple instances)
# ^-----@minio # MinIO data directory (single-node single-disk mode)
# ^-----@etcd # ETCD main data directory
# ^-----@infra # Infra module data directory
# ^-----@docker # Docker data directory
# ^-----@... # Other component data directories
Prometheus FHS
Prometheus main configuration file is located at roles/infra/templates/prometheus/prometheus.yml.j2 and is rendered to /etc/prometheus/prometheus.yml on all infrastructure nodes.
VictoriaMetrics-related scripts and rule definitions are placed in the files/victoria/ directory under the Pigsty home directory, and are copied to /etc/prometheus/ on all infrastructure nodes.
# /etc/prometheus/
# ^-----prometheus.yml # Prometheus main configuration file
# ^-----@bin # Utility scripts: check config, show status, reload, rebuild
# ^-----@rules # Recording and alerting rule definitions
# ^-----infra.yml # Infra rules and alerts
# ^-----etcd.yml # ETCD rules and alerts
# ^-----node.yml # Node rules and alerts
# ^-----pgsql.yml # PGSQL rules and alerts
# ^-----redis.yml # Redis rules and alerts
# ^-----minio.yml # MinIO rules and alerts
# ^-----kafka.yml # Kafka rules and alerts
# ^-----mysql.yml # MySQL rules and alerts
# ^-----@targets # File-based service discovery target definitions
# ^-----@infra # Infra static target definitions
# ^-----@node # Node static target definitions
# ^-----@pgsql # PGSQL static target definitions
# ^-----@pgrds # PGSQL remote RDS targets
# ^-----@redis # Redis static target definitions
# ^-----@minio # MinIO static target definitions
# ^-----@mongo # MongoDB static target definitions
# ^-----@mysql # MySQL static target definitions
# ^-----@etcd # ETCD static target definitions
# ^-----@ping # Ping static target definitions
# ^-----@patroni # Patroni static targets (used when Patroni SSL is enabled)
# ^-----@..... # Other monitoring target definitions
# /etc/alertmanager.yml # Alertmanager main configuration file
# /etc/blackbox.yml # Blackbox exporter main configuration file
PostgreSQL FHS
The following parameters are related to PostgreSQL database directory structure:
- pg_dbsu_home: Postgres default user home directory, defaults to
/var/lib/pgsql - pg_bin_dir: Postgres binary directory, defaults to
/usr/pgsql/bin/ - pg_data: Postgres database directory, defaults to
/pg/data - pg_fs_main: Postgres main data disk mount point, defaults to
/data - pg_fs_backup: Postgres backup disk mount point, defaults to
/data/backups(optional, can also backup to a subdirectory on the main data disk)
# Working assumptions:
# {{ pg_fs_main }} main data directory, default location: `/data` [fast SSD]
# {{ pg_fs_backup }} backup data disk, default location: `/data/backups` [cheap HDD]
#--------------------------------------------------------------#
# Default configuration:
# pg_fs_main = /data High-speed SSD
# pg_fs_backup = /data/backups Cheap HDD (optional)
#
# /pg -> /data/postgres/pg-test-15 (symlink)
# /pg/data -> /data/postgres/pg-test-15/data
#--------------------------------------------------------------#
- name: create postgresql directories
tags: pg_dir
become: yes
block:
- name: make main and backup data dir
file: path={{ item }} state=directory owner=root mode=0777
with_items:
- "{{ pg_fs_main }}"
- "{{ pg_fs_backup }}"
# pg_cluster_dir: "{{ pg_fs_main }}/postgres/{{ pg_cluster }}-{{ pg_version }}"
- name: create postgres directories
file: path={{ item }} state=directory owner={{ pg_dbsu }} group=postgres mode=0700
with_items:
- "{{ pg_fs_main }}/postgres"
- "{{ pg_cluster_dir }}"
- "{{ pg_cluster_dir }}/bin"
- "{{ pg_cluster_dir }}/log"
- "{{ pg_cluster_dir }}/tmp"
- "{{ pg_cluster_dir }}/cert"
- "{{ pg_cluster_dir }}/conf"
- "{{ pg_cluster_dir }}/data"
- "{{ pg_cluster_dir }}/meta"
- "{{ pg_cluster_dir }}/stat"
- "{{ pg_cluster_dir }}/change"
- "{{ pg_backup_dir }}/backup"
Data File Structure
# Physical directories
{{ pg_fs_main }} /data # Top-level data directory, typically fast SSD mount point
{{ pg_dir_main }} /data/postgres # Contains all Postgres instance data (may have multiple instances/versions)
{{ pg_cluster_dir }} /data/postgres/pg-test-15 # Contains `pg-test` cluster data (major version 15)
/data/postgres/pg-test-15/bin # PostgreSQL utility scripts
/data/postgres/pg-test-15/log # Logs: postgres/pgbouncer/patroni/pgbackrest
/data/postgres/pg-test-15/tmp # Temporary files, e.g., rendered SQL files
/data/postgres/pg-test-15/cert # PostgreSQL server certificates
/data/postgres/pg-test-15/conf # PostgreSQL configuration file index
/data/postgres/pg-test-15/data # PostgreSQL main data directory
/data/postgres/pg-test-15/meta # PostgreSQL identity information
/data/postgres/pg-test-15/stat # Statistics, log reports, summary digests
/data/postgres/pg-test-15/change # Change records
{{ pg_fs_backup }} /data/backups # Optional backup disk directory/mount point
/data/backups/postgres/pg-test-15/backup # Actual storage location for cluster backups
# Symlinks
/pg -> /data/postgres/pg-test-15 # pg root symlink
/pg/data -> /data/postgres/pg-test-15/data # pg data directory
/pg/backup -> /var/backups/postgres/pg-test-15/backup # pg backup directory
Binary File Structure
On EL-compatible distributions (using yum), PostgreSQL default installation location is:
/usr/pgsql-${pg_version}/
Pigsty creates a symlink named /usr/pgsql pointing to the actual version specified by the pg_version parameter, for example:
/usr/pgsql -> /usr/pgsql-15
Therefore, the default pg_bin_dir is /usr/pgsql/bin/, and this path is added to the system PATH environment variable, defined in: /etc/profile.d/pgsql.sh.
export PATH="/usr/pgsql/bin:/pg/bin:$PATH"
export PGHOME=/usr/pgsql
export PGDATA=/pg/data
On Ubuntu/Debian, the default PostgreSQL Deb package installation location is:
/usr/lib/postgresql/${pg_version}/bin
Pgbouncer FHS
Pgbouncer runs under the same user as {{ pg_dbsu }} (defaults to postgres), with configuration files located in /etc/pgbouncer.
pgbouncer.ini: Connection pool main configuration filedatabase.txt: Defines databases in the connection pooluserlist.txt: Defines users in the connection poolpgb_hba.conf: Defines access permissions for the connection pool
Redis FHS
Pigsty provides basic support for Redis deployment and monitoring.
Redis binaries are installed in /bin/ via RPM packages or binary copy, including:
redis-server
redis-server
redis-cli
redis-sentinel
redis-check-rdb
redis-check-aof
redis-benchmark
/usr/libexec/redis-shutdown
For a Redis instance named redis-test-1-6379, the related resources are as follows:
/usr/lib/systemd/system/redis-test-1-6379.service # Service (on Debian: /lib/systemd)
/etc/redis/redis-test-1-6379.conf # Configuration
/data/redis/redis-test-1-6379 # Database directory
/data/redis/redis-test-1-6379/redis-test-1-6379.rdb # RDB file
/data/redis/redis-test-1-6379/redis-test-1-6379.aof # AOF file
/var/log/redis/redis-test-1-6379.log # Log
/var/run/redis/redis-test-1-6379.pid # PID
For Ubuntu/Debian, the default systemd service directory is /lib/systemd/system/ instead of /usr/lib/systemd/system/.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.