H.3. pg_diag_setup#
H.3. pg_diag_setup #
pg_diag_setup — configuration manage tool for Tantor SE
H.3.1. Introduction #
A tool for managing Tantor SE configuration with profile support and rollback capability.
H.3.2. System Requirements #
Python 3.x
Tantor SE accessible via Unix Domain Socket
psqlutility available in PATH
H.3.3. Installation #
Copy the
pg_diag_setup.pyfile to the server.Create a
profilesdirectory and place profile files inside (e.g.,default.yaml).Make the script executable:
chmod +x pg_diag_setup.py
H.3.4. Usage #
H.3.4.1. Basic run (configuration check) #
sudo ./pg_diag_setup.py --port 5432 --unix-socket-dir /tmp
H.3.4.2. Apply a configuration profile #
sudo ./pg_diag_setup.py --port 5432 --unix-socket-dir /tmp --profile default.yaml --bin-dir /opt/path_to_binaries
H.3.4.3. View available backups #
sudo ./pg_diag_setup.py --port 5432 --unix-socket-dir /tmp --list-backups
H.3.4.4. Roll back changes #
sudo ./pg_diag_setup.py --port 5432 --unix-socket-dir /tmp --undo 20240529_143022 --bin-dir /opt/path_to_binaries
H.3.5. Command Line Options #
--port- Tantor SE port (default: 5432)--unix-socket-dir- Unix socket directory (default: /tmp)--profile- YAML profile file to apply--undo- timestamp for rollback--list-backups- show available backup list--bin-dir- directory where the Tantor SE distribution is installed-V- show utility version-v- enable verbose mode
H.3.6. What the Program Does #
H.3.6.1. Tasks 1-2: Connection and Configuration Discovery #
Connects to Tantor SE via Unix Domain Socket
Locates the
postgresql.conffile
H.3.6.2. Task 3: Checking postgresql.auto.conf #
Verifies existence of the
postgresql.auto.conffile
H.3.6.3. Task 4: Parameter Analysis #
Parses all configuration files
Compiles a parameter list with source info
Handles include directives
H.3.6.4. Task 5: Profile Application #
Reads YAML profile with extension settings
Checks available extensions via
pg_available_extensionsCreates configuration backups
Appends to
shared_preload_librarieswithout overwriting existing entriesAdds new parameters to the end of
postgresql.confTags added parameters with “Added by pg_diag_setup” comment
H.3.6.5. Task 6: Rollback System #
Creates timestamped backups
Allows rollback to any previous backup
H.3.7. Profile File Format #
extension_name:
shared_preload_lib: library_name
create_cmd: CREATE EXTENSION command
params:
parameter1: value1
parameter2: value2
H.3.8. Safety #
All changes are accompanied by backups
Existing parameters are preserved
Extensions are checked before installation
New parameters are added to the end of the file
H.3.9. Backup Examples #
After changes are applied, the following files are created:
postgresql.conf_backup_pds_20240529_143022postgresql.auto.conf_backup_pds_20240529_143022
H.3.10. Logging #
The program provides detailed output for all operations:
Located configuration files
Detected parameters
Backup creation
Applied changes
Operation results
H.3.11. Limitations #
Requires
psqlutilityOnly works with Unix Domain Socket connections
Simple YAML parser (doesn’t support full YAML spec)
Does not perform automatic Tantor SE restart
H.3.12. Troubleshooting #
Tantor SE connection error
Check the
--unix-socket-dirpathEnsure Tantor SE is running
Verify socket file permissions
Configuration read error
Check configuration file permissions
Ensure the user has read/write access
YAML parsing error
Check profile file syntax
Validate indentation (use 2 or 4 spaces)
H.3.13. Recommendations #
Always create full backups before applying changes
Test changes in a staging environment
Tantor SE restart may be required after applying a profile
Track applied profiles and their timestamps
H.3.14. Support #
If issues arise, check:
Tantor SE logs
File access permissions
YAML profile syntax
Extension availability in the system