Skip to content

Conversation

@pangpang20
Copy link
Collaborator

Description

This PR introduces enhancements to the OpenGauss database setup, focusing on high availability (HA). It adds a new Python script, cluster_ha_showcase.py, to demonstrate HA capabilities such as disaster recovery, load balancing, and automatic primary node discovery. Additionally, it improves the tests-ssl.yml workflow by refining configuration file creation and permissions, and includes a Docker setup script (cluster_opengauss_docker.sh) along with its documentation (cluster_opengauss_docker_readme.md) for streamlined cluster deployment.

Changes Made

  • Added cluster_ha_showcase.py:

    • Implements a Python script to showcase HA scenarios including disaster recovery, load balancing, and automatic primary node discovery.
    • Supports multiple cluster modes (master-standby, distributed, single, main standby, cascade standby).
    • Includes DSN masking for secure logging and connection retry logic for robustness.
    • Tests read/write operations with load balancing modes (sequential and random).
  • Updated tests-ssl.yml:

    • Replaced tee with cat for creating postgresql.conf and pg_hba.conf to simplify file creation.
    • Simplified configuration syntax by removing unnecessary quotes for string literals.
    • Adjusted directory ownership to remove redundant opengauss/conf ownership command.
    • Enhanced permission settings for configuration files and directories.
  • Added cluster_opengauss_docker.sh:

    • A Bash script to automate the creation of an OpenGauss master-slave cluster using Docker.
    • Configures network, IP addresses, and ports for master and slave nodes.
    • Supports customizable parameters for subnet, passwords, and node counts.
  • Added cluster_opengauss_docker_readme.md:

    • Provides detailed documentation for setting up and running the OpenGauss cluster using the Docker script.
    • Includes prerequisites, usage instructions, and troubleshooting steps.

Why

These changes aim to:

  • Enhance HA Testing: The cluster_ha_showcase.py script provides a robust way to test and demonstrate OpenGauss's high availability features, improving reliability in production environments.
  • Simplify Configuration: Updates to tests-ssl.yml streamline the configuration process, making it more maintainable and less error-prone.
  • Ease Cluster Setup: The Docker script and its documentation simplify the deployment of OpenGauss clusters, reducing setup time and potential configuration errors.
  • Improve Security: DSN masking in cluster_ha_showcase.py ensures sensitive information is not exposed in logs, aligning with best practices for secure logging.

Testing

  • Unit Tests for cluster_ha_showcase.py:
    • Tested disaster recovery scenarios with simulated primary node failures, verifying fallback to standby nodes.
    • Validated load balancing in both sequential and random modes, ensuring read operations are distributed correctly.
    • Confirmed automatic primary node discovery in master-standby and distributed modes.
  • Workflow Tests for tests-ssl.yml:
    • Ran GitHub Actions workflow to verify SSL configuration and file creation using cat instead of tee.
    • Checked file permissions and ownership for postgresql.conf and pg_hba.conf.
  • Docker Script Testing:
    • Deployed a master-slave cluster with 1 master and 2 slave nodes using cluster_opengauss_docker.sh.
    • Verified node connectivity and replication setup using gsql commands.
    • Tested script with different SLAVE_COUNT values to ensure scalability.
  • Documentation Validation:
    • Reviewed cluster_opengauss_docker_readme.md for clarity and completeness by following the setup instructions on a fresh environment.

chenyunliang520 added 7 commits September 6, 2025 19:28
…balancing, and primary node discovery in GaussDB clusters
… permissions step in workflow, improve code formatting, add type hints, and enhance string literals in cluster_ha_showcase.py
…ssions to include directory creation, add null checks for database queries, and improve error handling in connect_with_retry
…ig permissions step, use tee for file creation, simplify string quoting in postgresql.conf and pg_hba.conf, and fix string literal consistency in get_node_role
…ership and permissions fix step for opengauss directory
…ership and permissions fix step for opengauss directory
…dd cluster_opengauss_docker.sh for OpenGauss cluster deployment, and include cluster_opengauss_docker_readme.md for setup instructions; set executable permissions for modified and new files
@liubao68 liubao68 merged commit 3e2d21f into HuaweiCloudDeveloper:master Sep 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants