File Hierarchy

How files are organized in Pigsty.

Pigsty FHS

  1. #------------------------------------------------------------------------------
  2. # pigsty
  3. # ^-----@app # extra demo application resources
  4. # ^-----@bin # bin scripts
  5. # ^-----@docs # document (can be docsified)
  6. # ^-----@files # ansible file resources
  7. # ^-----@pigsty # pigsty config template files
  8. # ^-----@prometheus # prometheus rules definition
  9. # ^-----@grafana # grafana dashboards
  10. # ^-----@postgres # /pg/bin/ scripts
  11. # ^-----@migration # pgsql migration task definition
  12. # ^-----@pki # self-signed CA & certs
  13. # ^-----@roles # ansible business logic
  14. # ^-----@templates # ansible templates
  15. # ^-----@vagrant # sandbox resources
  16. # ^-----configure # configure wizard script
  17. # ^-----ansible.cfg # default ansible config file
  18. # ^-----pigsty.yml # default config file
  19. # ^-----*.yml # ansible playbooks
  20. #------------------------------------------------------------------------------
  21. # /etc/pigsty/
  22. # ^-----@targets # file based service discovery targets definition
  23. # ^-----@dashboards # static grafana dashboards
  24. # ^-----@datasources # static grafana datasource
  25. # ^-----@playbooks # extra ansible playbooks
  26. #------------------------------------------------------------------------------

CA FHS

Pigsty’s self-signed CA is located on files/pki/ directory under pigsty home.

YOU HAVE TO SECURE THE CA KEY PROPERLY: files/pki/ca/ca.key, which is generated by the ca role during install.yml or infra.yml.

  1. # pigsty/files/pki
  2. # ^-----@ca # self-signed CA key & cert
  3. # ^-----@ca.key # VERY IMPORTANT: keep it secret
  4. # ^-----@ca.crt # VERY IMPORTANT: trusted everywhere
  5. # ^-----@csr # signing request csr
  6. # ^-----@misc # misc certs, issued certs
  7. # ^-----@etcd # etcd server certs
  8. # ^-----@minio # minio server certs
  9. # ^-----@nginx # nginx SSL certs
  10. # ^-----@infra # infra client certs
  11. # ^-----@pgsql # pgsql server certs

Prometheus FHS

The prometheus bin / rules are located on files/prometheus/ directory under pigsty home.

While the main config file is located on roles/infra/templates/prometheus/prometheus.yml.j2 and rendered to /etc/prometheus/prometheus.yml on infra nodes.

  1. #------------------------------------------------------------------------------
  2. # Config FHS
  3. #------------------------------------------------------------------------------
  4. # /etc/prometheus/
  5. # ^-----prometheus.yml # prometheus main config file
  6. # ^-----@bin # util scripts: check,reload,status,new
  7. # ^-----@rules # record & alerting rules definition
  8. # ^-----infra.yml # infra rules & alert
  9. # ^-----node.yml # node rules & alert
  10. # ^-----pgsql.yml # pgsql rules & alert
  11. # ^-----redis.yml # redis rules & alert
  12. # ^-----minio.yml # minio rules & alert
  13. # ^-----etcd.yml # etcd rules & alert
  14. # ^-----@targets # file based service discovery targets definition
  15. # ^-----@infra # infra static targets definition
  16. # ^-----@node # nodes static targets definition
  17. # ^-----@etcd # etcd static targets definition
  18. # ^-----@minio # minio static targets definition
  19. # ^-----@ping # blackbox ping targets definition
  20. # ^-----@pgsql # pgsql static targets definition
  21. # ^-----@redis # redis static targets definition
  22. # ^-----@..... # other targets
  23. # /etc/alertmanager.yml # alertmanager main config file
  24. # /etc/blackbox.yml # blackbox exporter main config file
  25. #------------------------------------------------------------------------------

Postgres FHS

The following parameters are related to the PostgreSQL database dir:

  • pg_dbsu_home: Postgres default user’s home dir, default is /var/lib/pgsql.
  • pg_bin_dir: Postgres binary dir, defaults to /usr/pgsql/bin/.
  • pg_data: Postgres database dir, default is /pg/data.
  • pg_fs_main: Postgres main data disk mount point, default is /data.
  • pg_fs_bkup: Postgres backup disk mount point, default is /data/backups (used when using local backup repo).
  1. #--------------------------------------------------------------#
  2. # Create Directory
  3. #--------------------------------------------------------------#
  4. # assumption:
  5. # {{ pg_fs_main }} for main data , default: `/data` [fast ssd]
  6. # {{ pg_fs_bkup }} for backup data , default: `/data/backups` [cheap hdd]
  7. #--------------------------------------------------------------#
  8. # default variable:
  9. # pg_fs_main = /data fast ssd
  10. # pg_fs_bkup = /data/backups cheap hdd (optional)
  11. #
  12. # /pg -> /data/postgres/pg-test-15 (soft link)
  13. # /pg/data -> /data/postgres/pg-test-15/data
  14. #--------------------------------------------------------------#
  15. - name: create postgresql directories
  16. tags: pg_dir
  17. become: yes
  18. block:
  19. - name: make main and backup data dir
  20. file: path={{ item }} state=directory owner=root mode=0777
  21. with_items:
  22. - "{{ pg_fs_main }}"
  23. - "{{ pg_fs_bkup }}"
  24. # pg_cluster_dir: "{{ pg_fs_main }}/postgres/{{ pg_cluster }}-{{ pg_version }}"
  25. - name: create postgres directories
  26. file: path={{ item }} state=directory owner={{ pg_dbsu }} group=postgres mode=0700
  27. with_items:
  28. - "{{ pg_fs_main }}/postgres"
  29. - "{{ pg_cluster_dir }}"
  30. - "{{ pg_cluster_dir }}/bin"
  31. - "{{ pg_cluster_dir }}/log"
  32. - "{{ pg_cluster_dir }}/tmp"
  33. - "{{ pg_cluster_dir }}/cert"
  34. - "{{ pg_cluster_dir }}/conf"
  35. - "{{ pg_cluster_dir }}/data"
  36. - "{{ pg_cluster_dir }}/meta"
  37. - "{{ pg_cluster_dir }}/stat"
  38. - "{{ pg_cluster_dir }}/change"
  39. - "{{ pg_backup_dir }}/backup"

Data FHS

  1. # basic
  2. {{ pg_fs_main }} /data # top level data directory, usually a SSD mountpoint
  3. {{ pg_dir_main }} /data/postgres # contains postgres data
  4. {{ pg_cluster_dir }} /data/postgres/pg-test-15 # contains cluster `pg-test` data (of version 13)
  5. /data/postgres/pg-test-15/bin # bin scripts
  6. /data/postgres/pg-test-15/log # logs: postgres/pgbouncer/patroni/pgbackrest
  7. /data/postgres/pg-test-15/tmp # tmp, sql files, rendered results
  8. /data/postgres/pg-test-15/cert # postgres server certificates
  9. /data/postgres/pg-test-15/conf # patroni config, links to related config
  10. /data/postgres/pg-test-15/data # main data directory
  11. /data/postgres/pg-test-15/meta # identity information
  12. /data/postgres/pg-test-15/stat # stats information, summary, log report
  13. /data/postgres/pg-test-15/change # changing records
  14. /data/postgres/pg-test-15/backup # soft link to backup dir
  15. {{ pg_fs_bkup }} /data/backups # could be a cheap & large HDD mountpoint
  16. /var/backups/postgres/pg-test-15/backup # local backup repo path
  17. # links
  18. /pg -> /data/postgres/pg-test-15 # pg root link
  19. /pg/data -> /data/postgres/pg-test-15/data # real data dir
  20. /pg/backup -> /var/backups/postgres/pg-test-15/backup # base backup

Binary FHS

On EL releases, the default path for PostgreSQL bin is:

  1. /usr/pgsql-${pg_version}/

Pigsty will create a softlink /usr/pgsql to the currently installed version specified by pg_version.

  1. /usr/pgsql -> /usr/pgsql-15

Therefore, the default pg_bin_dir will be /usr/pgsql/bin/, and this path is added to the PATH environment via /etc/profile.d/pgsql.sh.

  1. export PATH="/usr/pgsql/bin:/pg/bin:$PATH"
  2. export PGHOME=/usr/pgsql
  3. export PGDATA=/pg/data

Pgbouncer FHS

Pgbouncer is run using the Postgres user, and the config file is located in /etc/pgbouncer. The config file includes.

  • pgbouncer.ini: pgbouncer main config
  • database.txt: pgbouncer database list
  • userlist.txt: pgbouncer user list
  • useropts.txt: pgbouncer user options (user-level parameter overrides)
  • pgb_hba.conf: lists the access privileges of the connection pool users

Redis FHS

Pigsty provides essential support for Redis deployment and monitoring.

Redis binaries are installed in /bin/ using RPM-packages or copied binaries, including:

  1. redis-server
  2. redis-server
  3. redis-cli
  4. redis-sentinel
  5. redis-check-rdb
  6. redis-check-aof
  7. redis-benchmark
  8. /usr/libexec/redis-shutdown

For a Redis instance named redis-test-1-6379, the resources associated with it are shown below:

  1. /usr/lib/systemd/system/redis-test-1-6379.service # Services
  2. /etc/redis/redis-test-1-6379.conf # Config
  3. /data/redis/redis-test-1-6379 # Database Catalog
  4. /data/redis/redis-test-1-6379/redis-test-1-6379.rdb # RDB File
  5. /data/redis/redis-test-1-6379/redis-test-1-6379.aof # AOF file
  6. /var/log/redis/redis-test-1-6379.log # Log
  7. /var/run/redis/redis-test-1-6379.pid # PID

Last modified 2023-02-27: refresh en docs to v2.0 (e82b371)