H.2. pg_diag_setup#
H.2. pg_diag_setup #
pg_diag_setup — configuration manage tool for Tantor SE-1C
H.2.1. Introduction #
A tool for managing Tantor SE-1C configuration with profile support and rollback capability.
H.2.2. System Requirements #
Python 3.x
Tantor SE-1C accessible via Unix Domain Socket
psqlutility available in PATH
H.2.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.2.4. Usage #
Note
The utility can be run either via sudo or directly as a postgres user. In the second case, make sure that the user has permissions to read configuration files and write to the backup directory.
H.2.4.1. Basic run (configuration check) #
sudo ./pg_diag_setup.py --port 5432 --unix-socket-dir /tmp
H.2.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.2.4.3. View available backups #
sudo ./pg_diag_setup.py --port 5432 --unix-socket-dir /tmp --list-backups
H.2.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.2.5. Command Line Options #
--port- Tantor SE-1C 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-1C distribution is installed-V- show utility version-v- enable verbose mode
H.2.6. What the Program Does #
H.2.6.1. Tasks 1-2: Connection and Configuration Discovery #
Connects to Tantor SE-1C via Unix Domain Socket
Locates the
postgresql.conffile
H.2.6.2. Task 3: Checking postgresql.auto.conf #
Verifies existence of the
postgresql.auto.conffile
H.2.6.3. Task 4: Parameter Analysis #
Parses all configuration files
Compiles a parameter list with source info
Handles include directives
H.2.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.2.6.5. Task 6: Rollback System #
Creates timestamped backups
Allows rollback to any previous backup
H.2.7. Profile File Format #
extension_name:
shared_preload_lib: library_name
create_cmd: CREATE EXTENSION command
params:
parameter1: value1
parameter2: value2
H.2.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.2.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.2.10. Logging #
The program provides detailed output for all operations:
Located configuration files
Detected parameters
Backup creation
Applied changes
Operation results
H.2.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-1C restart
H.2.12. Troubleshooting #
Tantor SE-1C connection error
Check the
--unix-socket-dirpathEnsure Tantor SE-1C 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.2.13. Recommendations #
Always create full backups before applying changes
Test changes in a staging environment
Tantor SE-1C restart may be required after applying a profile
Track applied profiles and their timestamps
H.2.14. Support #
If issues arise, check:
Tantor SE-1C logs
File access permissions
YAML profile syntax
Extension availability in the system