成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

19C?DG?Broker配置和測試

IT那活兒 / 3907人閱讀
19C?DG?Broker配置和測試
一. DG Broker配置

1. DG當(dāng)前測試環(huán)境配置

select name, database_role db_role, controlfile_type cf_type, open_mode, protection_mode, dataguard_broker dg_broker, guard_status, force_logging from v$database;

主庫:

備庫:


2. DG Broker主備庫配置

DB_BROKER_CONFIG_FILEn參數(shù)用于指定DataGuard配置文件的路徑,存在默認(rèn)路徑。

DG_BROKER_START參數(shù)設(shè)置實例啟動的時候是否自動啟動Broker,需要開啟。

alter system set dg_broker_start=true;

數(shù)據(jù)庫的archive_dest_n 參數(shù)會由DG BROKER自動進(jìn)行管理,無需人工干預(yù)。


3. 創(chuàng)建DataGuard Broker配置

[oracle@db1 /home/oracle]$ dgmgrl sys/oracle@prod
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Thu May 13 20:16:43 2021
Version 19.6.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

Welcome to DGMGRL, type "help" for information.
Connected to "prod"
Connected as SYSDBA.
DGMGRL>
create configuration dg_prod as primary database is prod connect identifier is prod;
Configuration "dg_prod" created with primary database "prod"
DGMGRL> add database pstdby as connect identifier is pstdby maintained as physical;
Error: ORA-16698: member has a LOG_ARCHIVE_DEST_n parameter with SERVICE attribute set

Failed.
配置備庫報錯,使用dg broker需要手動清除主備庫的LOG_ARCHIVE_DEST_n參數(shù)配置。重啟主庫和備庫即可添加。
DGMGRL>
add database pstdby as connect identifier is pstdby maintained as physical;
Database "pstdby" added

DGMGRL>
enable configuration
Enabled.
DGMGRL>
show configuration;

Configuration - dg_prod

  Protection Mode: MaxPerformance
  Members:
  pstdby - Primary database
    prod - Physical standby database

Fast-Start Failover: Disabled

Configuration Status:
SUCCESS (status updated 46 second ago)

4. Listener和Tnsnames 配置

##主庫listener
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prod)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = prod)
    )
   (SID_DESC =
      (GLOBAL_DBNAME = prod_DGMGRL)
      (ORACLE_HOME = /database/oracle/product/rdbms/19.3.0)
      (SID_NAME = prod)
    )
  )

#
##備庫listener.ora配置
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = pstdby)
      (ORACLE_HOME = /database/oracle/product/rdbms/19.3.0)
      (SID_NAME = pstdby)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = pstdby_DGMGRL)
      (ORACLE_HOME = /database/oracle/product/rdbms/19.3.0)
      (SID_NAME = pstdby)
    )
  )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = pstdby)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )


###主備庫tnsnames.ora
prod =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.71)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prod)
    )
  )
  
pstdby =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.72)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pstdby)
    )
  )


二. switchover及failover

1. switchover

DGMGRL> switchover to pstdby
Performing switchover NOW, please wait...
Operation requires a connection to database "pstdby"
Connecting ...
Connected to "pstdby"
Connected as SYSDBA.
New primary database "pstdby" is opening...
Operation requires start up of instance "prod" on database "prod"
Starting instance "prod"...
Connected to an idle instance.
ORACLE instance started.
Connected to "prod"
Database mounted.
Database opened.
Connected to "prod"
Switchover succeeded, new primary is "pstdby"
 DGMGRL> show configuration

Configuration - dg_prod

  Protection Mode: MaxPerformance
  Members:
  pstdby - Primary database
    prod - Physical standby database

Fast-Start Failover: Disabled

Configuration Status:
SUCCESS (status updated 50 seconds ago)

2. failover

failover命令:
failover to database-name [immediate];

dgmgrl sys/oracle@pstdby
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Thu May 13 23:12:19 2021
Version 19.6.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

Welcome to DGMGRL, type "help" for information.
Connected to "pstdby"
Connected as SYSDBA.
DGMGRL>
failover to pstdby
Performing failover NOW, please wait...
Failover succeeded, new primary is "pstdby"
DGMGRL>
show configuration

Configuration - dg_prod

  Protection Mode: MaxPerformance
  Members:
  pstdby - Primary database
    prod - Physical standby database (disabled)
      ORA-16661: the standby database needs to be reinstated

Fast-Start Failover: Disabled

Configuration Status:
SUCCESS   (status updated 14 seconds ago)

DGMGRL>
reinstate database prod
Reinstating database "prod", please wait...
Oracle Clusterware is restarting database "prod" ...
Connected to "prod"
Connected to "prod"
Continuing to reinstate database "prod" ...
Reinstatement of database "prod" succeeded
DGMGRL>
enable database prod
Enabled.
DGMGRL>
show configuration

Configuration - dg_prod

  Protection Mode: MaxPerformance
  Members:
  pstdby - Primary database
    prod - Physical standby database 

Fast-Start Failover: Disabled

Configuration Status:
WARNING   (status updated 26 seconds ago)

在主庫發(fā)生故障時需要手動failover,將主庫切換到備庫。此時原主庫需要人為介入進(jìn)行故障診斷和修復(fù),修復(fù)后在DG Broker中執(zhí)行reinstate database [ db_name] 命令可以重新將原主庫轉(zhuǎn)換為備庫恢復(fù)為新的主備關(guān)系,若需要還原為初始環(huán)境執(zhí)行switchover即可。

reinstate database [ db_name] 啟用該功能修復(fù),需要數(shù)據(jù)庫開啟閃回。

在原主庫極端故障無法修復(fù)的情況下,需要重新建立DG環(huán)境。此時主庫是啟用了DG broker的,修復(fù)后的備庫需要執(zhí)行enable database [ db_name] 加入broker環(huán)境。


三. fast_start failover

1. fast_start failover相關(guān)配置

  • 保證主從數(shù)據(jù)庫的閃回數(shù)據(jù)庫功能以及強制歸檔都打開

SQL> select flashback_on,force_logging from v$database;

FLASHBACK_ON                FOR
------------------                        ---
YES                                      YES

  • 開啟fast-start failover

DGMGRL>  enable fast_start failover;
Enabled in Potential Data Loss Mode.

  • 觀察器(observer)設(shè)置

    可以使用后臺進(jìn)程的方式啟動observer,配置如下:

1)查看當(dāng)前的borker配置

DGMGRL> show database verbose prod;

Database - prod

Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
prod

Properties:
DGConnectIdentifier
= prod
ObserverConnectIdentifier =  
此處沒有設(shè)置值,默認(rèn)將使用DGConnectIdentifier的值

2)配置wallet

mkstore -wrl /home/oracle/wallet/ -create  
提示輸入wallet密碼
mkstore -wrl /home/oracle/wallet/ -createCredential prod sys <password>
mkstore -wrl /home/oracle/wallet/ -createCredential pstdby sys <password>
在主庫的sqlnet.ora中添加wallet條目
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME,EZCONNECT)
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/home/oracle/wallet/)))
SQLNET.WALLET_OVERRIDE=TRUE
將主庫的wallet和sqlnet.ora拷貝的備庫的相同位置后,重新reload監(jiān)聽

3)創(chuàng)建后臺進(jìn)程observer

dgmgrl sys/oracle@pstdby
DGMGRL> start observer ob1 in background logfile is /database/oracle/product/diag/rdbms/pstdby/prod/trace/observerlog connect identifier is pstdby;
Connected to "PSTDBY"
Submitted command "START OBSERVER" using connect identifier "pstdby"

dgmgrl sys/oracle@prod
DGMGRL> start observer ob2 in background logfile is /database/oracle/product/diag/rdbms/prod/prod/trace/observer.log connect identifier is prod;
Connected to "prod"
Submitted command "START OBSERVER" using connect identifier "prod"

此時主備節(jié)點都存在observer進(jìn)程


2. 場景一、模擬主庫宕機

  • 查看fast-start failover 狀態(tài)

  • 驗證自動切換,主庫模擬異常關(guān)閉

    prod庫執(zhí)行shutdown abort;

    查看pstdby狀態(tài),自動切換為主庫。

  • 恢復(fù)DG

prod庫啟動后執(zhí)行
DGMGRL> reinstate database prod
Reinstating database "prod", please wait...
Reinstatement of database "prod" succeeded
DGMGRL> enable database prod
Enabled.
DGMGRL> show configuration

Configuration - dg_prod

  Protection Mode: MaxPerformance
  Members:
  pstdby - Primary database
    prod - (*) Physical standby database

Fast-Start Failover: Enabled in Potential Data Loss Mode

Configuration Status:
SUCCESS (status updated 7 seconds ago)

DGMGRL> show observer

Configuration - dg_prod

  Primary: pstdby
  Active Target:      prod

Observer "ob1" - Master

  Host Name: pstdby
  Last Ping to Primary: 1 second ago
  Last Ping to Target:          1 second ago

Observer "ob2" - Backup

  Host Name: prod
  Last Ping to Primary: 2 seconds ago
  Last Ping to Target:          0 seconds ago


3. 場景二、模擬網(wǎng)絡(luò)故障

  • 當(dāng)前borker狀態(tài)

  • 禁用主庫1521端口

[root@pstdby onlinelog]# firewall-cmd --zone=public --remove-port=1521/tcp --permanent
Warning: NOT_ENABLED: 1521:tcp
Success

[oracle@prod /home/oracle]$ tnsping pstdby

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 17-MAY-2021 13:52:01

Copyright (c) 1997, 2019, Oracle. All rights reserved.

Used parameter files:
/database/oracle/product/rdbms/19.3.0/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.72)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pstdby)))
TNS-12543: TNS:destination host unreachable
[oracle@pstdby /home/oracle]$ tnsping prod

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 17-MAY-2021 13:53:20

Copyright (c) 1997, 2019, Oracle. All rights reserved.

Used parameter files:
/database/oracle/product/rdbms/19.3.0/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.71)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prod)))
OK (20 msec)
  • 此時borker狀態(tài)未發(fā)生變化

prod庫的Observer.log中有告警提示

  • 打開pstdb的1521端口,禁用prod的1521端口

[oracle@pstdby /home/oracle]$ tnsping prod

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 17-MAY-2021 14:02:40

Copyright (c) 1997, 2019, Oracle. All rights reserved.

Used parameter files:
/database/oracle/product/rdbms/19.3.0/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.71)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prod)))
TNS-12543: TNS:destination host unreachable

[oracle@prod /home/oracle]$ tnsping pstdby

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 17-MAY-2021 14:02:09

Copyright (c) 1997, 2019, Oracle. All rights reserved.

Used parameter files:
/database/oracle/product/rdbms/19.3.0/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.72)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pstdby)))
OK (10 msec)

此時borker狀態(tài)未發(fā)生變化

  • 同時禁用主備庫的1521端口

[oracle@prod /home/oracle]$ tnsping pstdby

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 17-MAY-2021 14:10:31

Copyright (c) 1997, 2019, Oracle. All rights reserved.

Used parameter files:
/database/oracle/product/rdbms/19.3.0/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.72)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pstdby)))
TNS-12543: TNS:destination host unreachable
[oracle@pstdby /home/oracle]$ tnsping prod

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 17-MAY-2021 14:11:23

Copyright (c) 1997, 2019, Oracle. All rights reserved.

Used parameter files:
/database/oracle/product/rdbms/19.3.0/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.71)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prod)))
TNS-12543: TNS:destination host unreachable

DGMGRL> show configuration

Configuration - dg_prod

  Protection Mode: MaxPerformance
  Members:
  pstdby - Primary database
    prod - (*) Physical standby database
      Error: ORA-16664: unable to receive the result from a member

Fast-Start Failover: Enabled in Potential Data Loss Mode

Configuration Status:
ERROR (status updated 55 seconds ago)

DGMGRL> show observer

Configuration - dg_prod

  Primary: pstdby
  Active Target:      prod

Observer "ob1" - Master

  Host Name: pstdby
  Last Ping to Primary: 1 second ago
  Last Ping to Target:          1 second ago

Observer "ob2" - Backup

  Host Name: prod
  Last Ping to Primary: 0 seconds ago
  Last Ping to Target:          1 second ago


結(jié)論:在網(wǎng)絡(luò)故障時,borker可能會產(chǎn)生一些錯誤的提示,主備庫不會發(fā)生角色切換。

在網(wǎng)絡(luò)恢復(fù)時,錯誤提示會自動清除。


END


更多精彩干貨分享

點擊下方名片關(guān)注

IT那活兒

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/129826.html

相關(guān)文章

  • DG備庫讀寫測試方案

    DG備庫讀寫測試方案 img{ display:block; margin:0 auto !important; width:100%; } body{ width:75%; margin:0...

    IT那活兒 評論0 收藏856

發(fā)表評論

0條評論

IT那活兒

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<