启动观察程序并启用快速启动故障转移

将观察程序安装在单独的可用性区域中的 Azure 计算 VM 上,并启用快速启动故障转移。
Observer 是 DGMGRL CLI 中内置的低占用空间客户机,与其他任何客户机一样,它可以在与数据库服务器不同的硬件平台上运行。

Data Guard 中介可以自动化和集中创建、维护和监视 Data Guard 配置。它允许您通过中介的客户机界面在本地或远程执行所有管理操作:

  • Oracle Enterprise Manager Cloud Control 或
  • Data Guard 命令行界面,DGMGRL
DGMGRL 命令行是 Oracle AI Database 软件安装的一部分,可从 $ORACLE_HOME/bin/dgmgrl 获取。按照以下步骤启用快速启动故障转移:
  1. 在观察程序 VM 上下载和安装 Oracle AI Database 客户机。对于 Linux x64:
    unzip LINUX.X64_2326100_client.zip
    cd client
    ./runInstaller
    
  2. 使用主数据库和备用数据库的连接字符串创建 tnsnames.ora 文件。将建议的连接字符串与 SCAN 名称结合使用:

    在观察程序 VM 上编辑 $ORACLE_HOME/network/admin/tnsnames.ora

    vi $ORACLE_HOME/network/admin/tnsnamse.ora
    
    DBZONE1=(DESCRIPTION=(CONNECT_TIMEOUT= 90)(RETRY_COUNT=100)(RETRY_DELAY=3)(TRANSPORT_CONNECT_TIMEOUT=1000ms)(LOAD_BALANCE=off)(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=scan-vmcluster-1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME = DBzone1.ocidelegatedsu.ocivnet1.oraclevcn.com)))
    
    DBZONE2=(DESCRIPTION=(CONNECT_TIMEOUT= 90)(RETRY_COUNT=100)(RETRY_DELAY=3)(TRANSPORT_CONNECT_TIMEOUT=1000ms)(LOAD_BALANCE=off)(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=scan-mvcluster-2)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME = DBzone2.ocidelegatedsu.ocivnet2.oraclevcn.com)))
    
    haservice = (DESCRIPTION =
    (CONNECT_TIMEOUT= 90)(RETRY_COUNT=100)(RETRY_DELAY=3)(TRANSPORT_CONNECT_TIMEOUT=1000ms)(LOAD_BALANCE=off)
        (ADDRESS_LIST =
            (LOAD_BALANCE=on)
            (ADDRESS = (PROTOCOL = TCP)(HOST=scan-vmcluster-1)(PORT=1521)))
        (ADDRESS_LIST =
            (LOAD_BALANCE=on)
            (ADDRESS = (PROTOCOL = TCP)(HOST=scan-vmcluster-2)(PORT=1521)))      
        (CONNECT_DATA=(SERVICE_NAME = haservice.oracle.com)))
  3. 验证与主数据库和备用数据库的连接。
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    
    dgmgrl SYS@DBZONE1
    ...
    Connected to "DBzone1"
    Connected as SYSDBA.
                
    dgmgrl SYS@DBZONE2
    ...
    Connected to "DBzone2"
    Connected as SYSDBA.
    
  4. 检查 Data Guard 配置和快速启动故障转移目标设置。
    DGMGRL> show configuration
    Configuration - db26_dgconf
      Protection Mode: MaxAvailability
      Members:
      DBzone1 - Primary database
        DBzone2 - Physical standby database
    Fast-Start Failover:  Disabled
    Configuration Status:
    SUCCESS   (status updated 20 seconds ago)
    
    DGMGRL> show database DBzone1 FastStartFailoverTarget;
      FastStartFailoverTarget = 'DBzone2'
    
    DGMGRL> show database DBzone2 FastStartFailoverTarget;
      FastStartFailoverTarget = 'DBzone1'
  5. 在观察程序 VM 上启动观察程序进程。要在后台运行观察程序,请执行以下操作:
    export WALLET_DIR=/u01/app/oracle/product/23.26.0/dbhome_1/network/admin/wallet
    mkstore -wrl $WALLET_DIR -create
    mkstore -wrl $WALLET_DIR -createCredential 'DBZONE1' sysdg <password>;
    mkstore -wrl $WALLET_DIR -createCredential 'DBZONE2' sysdg <password>;
    mkstore -wrl $WALLET_DIR -createCredential 'HASERVICE' sysdg <password>;
    
    vi /u01/app/oracle/product/23.26.0/dbhome_1/network/admin/sqlnet.ora
    WALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = /u01/app/oracle/product/23.26.0/dbhome_1/network/admin/wallet)))
    SQLNET.WALLET_OVERRIDE = TRUE
    
    dgmgrl SYS@DBZONE1
    DGMGRL> START OBSERVER observer3 IN BACKGROUND FILE IS /home/oracle/observer3.dat LOGFILE IS /home/oracle/observer3.log CONNECT IDENTIFIER IS haservice;
    Submitted command "START OBSERVER" using connect identifier "haservice"
    
    DGMGRL> show observer
    Configuration - db26_dgconf
      Fast-Start Failover:     DISABLED
    Observer "observer3"(23.26.0.0.0)
      Host Name:                    fsfovm3
      Last Ping to Primary:         6 seconds ago
      Log File:                     /home/oracle/observerz3.log
      State File:                   /home/oracle/observerz3.dat
  6. 为配置启用快速启动故障转移。
    DGMGRL> enable fast_start failover
    Enabled in Zero Data Loss Mode.
  7. 验证观察程序和配置状态是否显示 "Fast-Start Failover" 为 "Enabled"。
    DGMGRL> show observer
    Configuration - db26_dgconf
      Fast-Start Failover:     ENABLED
      Primary:            DBzone1
      Active Target:      DBzone2
    Observer "observer3"(23.26.0.0.0) - Master
      Host Name:                    fsfovm3
      Last Ping to Primary:         1 second ago
      Last Ping to Target:          2 seconds ago
      Log File:                     /home/oracle/observerz3.log
      State File:                   /home/oracle/observerz3.dat
    
    DGMGRL> show configuration
    Configuration - db26_dgconf
      Protection Mode: MaxAvailability
      Members:
      DBzone1 - Primary database
        DBzone2 - (*) Physical standby database
    Fast-Start Failover: Enabled in Zero Data Loss Mode
    Configuration Status:
    SUCCESS   (status updated 13 second ago)
    
    DGMGRL> show fast_start failover
    Fast-Start Failover: Enabled in Zero Data Loss Mode
    ...

观察程序正在运行,并且为 Data Guard 配置启用了快速启动故障转移。