Failover

更新时间:
复制 MD 格式

You can use the pdbcli failover command to manually fail over a cluster.

The following commands are used for cluster failover:

  • To query all standby nodes that are available for manual failover:

    pdbcli failover --list

    The following is a sample output:

    Using config file: ./config.yaml
    Cluster Status:
    {
            "phase": "RunningPhase",
            "master": {
                    "endpoint": "10.XX.XX.1:1521",
                    "phase": "RUNNING",
                    "start_at": "2020-09-24 23:32:07",
                    "sync_status": "SYNC"
            },
            "standby": [
                    {
                            "endpoint": "10.XX.XX.2:1521",
                            "phase": "RUNNING",
                            "start_at": "2020-09-24 23:32:10",
                            "sync_status": "SYNC"
                    },
                    {
                            "endpoint": "10.XX.XX.3:1521",
                            "phase": "RUNNING",
                            "start_at": "2020-09-24 23:32:10",
                            "sync_status": "SYNC"
                    }
            ]
    }
    
    Available Candidates:  # All standby nodes available for manual failover
    IP Address
    10.XX.XX.2
    10.XX.XX.3
  • To manually fail over to a specific standby node:

    pdbcli failover --target 'IP address of the target standby node'

    For example, to manually fail over to the node with the endpoint 10.XX.XX.2:

    pdbcli failover --target 10.XX.XX.2

To get help for the failover command, run pdbcli help failover or pdbcli failover --help:

Using config file: ./config.yaml
Perform PolarDB Cluster manual failover.
    
    For example:

    pdbcli failover --target 10.XX.XX.2

Usage:
 pdbcli failover [flags]

Flags:
 -h, --help      help for failover  # Get help information for the failover command.
   --list      Prints the list of failover candidates. # Display all standby nodes available for manual failover.
   --no-prompt    No command line confirmation. # If you add this flag, no command line confirmation is required. Use this flag with caution.
   --target string  The standby target IP-ADDRESS which the failover will occur on. (REQUIRED if more than one standby host) # If more than one standby node exists, specify the IP address of the target standby node for the failover.

Global Flags:
   --config string  Specify Config file. (default "./config.yaml") # Specify the configuration file. The default file is ./config.yaml.
   --debug      Enable additional output for debugging. # Display more output information for debugging.