【DG】Oracle 19c使用dbca來搭建物理DG
【DG】Oracle 19c使用dbca來搭建物理DG(12cR2可以使用但主庫必須是單機非CDB的庫,18c無限制)
Using DBCA to Create a Data Guard Standby
The Database Configuration Assistant (DBCA) can also be used as a simple command-line method to create an Oracle Data Guard physical standby database.
The DBCA command qualifier used to create the physical standby database is createDuplicateDB .
DBCA can only be used to create standby databases for non-multitenant primary databases. In addition, this capability creates only single instance standby databases,not Oracle Real Application Clusters (Oracle RAC) databases. If required, the standby can then be converted to an Oracle RAC standby database, either manually or using Oracle Enterprise Manager Cloud Control.
在 12cR2 ( 12.2.0.1 )之前建立物理備庫的方法有:
1 、使用 RMAN 備份恢復方法;
2 、在 11g 時可以選擇 duplicate 方式建立物理備庫;通過這種方式直接線上從主庫搭建物理備庫。
到 12cR2 ( 12.2.0.1 )後, Oracle 又提供更簡單的方式來建立物理備庫,即使用 DBCA 方式直接建立物理備庫。這個功能再次簡化了建立備庫的複雜度。
通過 DBCA 提供的引數 createDuplicateDB 可以很容易的搭建一個物理備庫。其具體語法如下:
-------------- 12cR2 -createDuplicateDB - Command to Duplicate a database. -gdbName <Global database name> -primaryDBConnectionString <EZCONNECT string to connect to primary database for example "host:port/servicename"> -sid <Database system identifier> [-createAsStandby <Option to create a standby database>] [-dbUniqueName <db_unique_name for standby db>] [-customScripts <A comma separated list of SQL scripts which needs to be run post db creation.The scripts are run in order they are listed>] [-datafileDestination <Destination directory for all database files>] [-initParams <Comma separated list of name=value pairs>] [-initParamsEscapeChar <Specify escape character for comma when a specific initParam has multiple values.If the escape character is not specified backslash is the default escape character>] ----------- 18c -createDuplicateDB - Command to Duplicate a database. -gdbName <Global database name> -primaryDBConnectionString <EZCONNECT string to connect to primary database for example "host:port/servicename"> -sid <Database system identifier> [-initParams <Comma separated list of name=value pairs>] [-initParamsEscapeChar <Specify escape character for comma when a specific initParam has multiple values.If the escape character is not specified backslash is the default escape character>] [-policyManaged | -adminManaged] [-policyManaged <Policy managed database, default option is Admin managed database>] -serverPoolName <Specify the single server pool name in case of create server pool or comma separated list in case of existing server pools> [-pqPoolName <value>] [-createServerPool <Create a new server pool, which will be used by the database>] [-pqPoolName <value>] [-forceServerPoolCreation <To create server pool by force when adequate free servers are not available. This may affect the database which is already in running mode>] [-pqCardinality <value>] [-cardinality <Specify the cardinality of the new server pool that is to be created, default is the number of qualified nodes>] [-adminManaged <Admin managed database, this is default option>] [-datafileDestination <Destination directory for all database files>] [-nodelist <Node names separated by comma for the database>] [-databaseConfigType <SINGLE | RAC | RACONENODE>] [-RACOneNodeServiceName <Service name for the service to be created for RAC One Node database. This option is mandatory when the databaseConfigType is RACONENODE>] [-createAsStandby <Option to create a standby database>] [-dbUniqueName <db_unique_name for standby db>] [-customScripts <A comma separated list of SQL scripts which needs to be run post db creation.The scripts are run in order they are listed>] ----------- 19c -createDuplicateDB - Command to Duplicate a database. -gdbName <Global database name> -primaryDBConnectionString <EZCONNECT string to connect to primary database for example "host:port/servicename"> -sid <Database system identifier> [-useWalletForDBCredentials <true | false> Specify true to load database credentials from wallet] -dbCredentialsWalletLocation <Path of the directory containing the wallet files> [-dbCredentialsWalletPassword <Password to open wallet with auto login disabled>] [-initParams <Comma separated list of name=value pairs>] [-initParamsEscapeChar <Specify escape character for comma when a specific initParam has multiple values.If the escape character is not specified backslash is the default escape character>] [-policyManaged | -adminManaged] [-policyManaged <Policy managed database, default option is Admin managed database>] -serverPoolName <Specify the single server pool name in case of create server pool or comma separated list in case of existing server pools> [-pqPoolName <value>] [-createServerPool <Create a new server pool, which will be used by the database>] [-pqPoolName <value>] [-forceServerPoolCreation <To create server pool by force when adequate free servers are not available. This may affect the database which is already in running mode>] [-pqCardinality <value>] [-cardinality <Specify the cardinality of the new server pool that is to be created, default is the number of qualified nodes>] [-adminManaged <Admin managed database, this is default option>] [-datafileDestination <Destination directory for all database files>] [-nodelist <Node names separated by comma for the database>] [-databaseConfigType <SINGLE | RAC | RACONENODE>] [-RACOneNodeServiceName <Service name for the service to be created for RAC One Node database. This option is mandatory when the databaseConfigType is RACONENODE>] [-createAsStandby <Option to create a standby database>] [-dbUniqueName <db_unique_name for standby db>] [-customScripts <A comma separated list of SQL scripts which needs to be run post db creation.The scripts are run in order they are listed>]
雖然通過 DBCA 能非常簡單的建立一個物理備庫,但是要使用這個功能,必須滿足以下條件:
① 主庫必須是單機環境,非 RAC 資料庫;
② 主庫必須是非 CDB 環境;
如果不滿足以上條件, 那麼 在使用 DBCA 建立備庫的時候,會提示如下錯誤:
若 主庫是 CDB 環境,錯誤如下:
[FATAL] [DBT-16057] Specified primary database is a container database (CDB). CAUSE: Duplicate database operation is supported only for non container databases.
若 主庫是 RAC 資料庫,錯誤如下:
[FATAL] [DBT-16056] Specified primary database is not a Single Instance (SI) database. CAUSE: Duplicate database operation is supported only for SI databases.
也就說通過 DBCA 搭建出來的備庫也是一個單機非 CDB 的備庫。
需要注意的是,在 12cR2 ( 12.2.0.1 )中,通過 DBCA 建立物理需要保證主庫是單機非 CDB 的庫,但是從 Oracle 18c ( 12.2.0.2 )開始,這些限制條件已經取消了,即主庫是 CDB 或 rac 環境都可以通過 dbca 來建立物理備庫。
以下命令為 18c 中建立 rac 型別的 dg :
dbca -silent -createDuplicateDB \ -gdbName lhrdb \ -sid lhrdbdg \ -sysPassword oracle \ -primaryDBConnectionString 192.168.20.10:1521/lhrdb \ -nodelist rac18c-n1,rac18c-n2 \ -adminManaged \ -databaseConfigType RAC \ -createAsStandby -dbUniqueName lhrdbdg \ -datafileDestination '+DATA' \ -initParams db_create_file_dest=+DATA, db_create_online_log_dest_1=+DATA,local_listener="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.20.10)(PORT=1521)))"
基於同一個主機搭建 單例項的物理 DG ( 19c ):
SELECT CDB FROM V$DATABASE; alter database force logging; alter database open; alter database archivelog; alter pluggable database all open; alter pluggable database all save state; select thread#,group#,bytes/1024/1024 SIZE_MB, status,members from v$log; select member from v$logfile; alter database add standby logfile thread 1 group 4 '/u01/app/oracle/oradata/LHR19C/standby_redo04.log' size 50M ; alter database add standby logfile thread 1 group 5 '/u01/app/oracle/oradata/LHR19C/standby_redo05.log' size 50M ; alter database add standby logfile thread 1 group 6 '/u01/app/oracle/oradata/LHR19C/standby_redo06.log' size 50M ; alter database add standby logfile thread 1 group 7 '/u01/app/oracle/oradata/LHR19C/standby_redo07.log' size 50M ; --------配置tns lhr19c = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.52)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = lhr19c) ) ) lhr19cdg = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.52)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = lhr19cdg) ) ) --------配置監聽 LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.52)(PORT = 1521)) ) ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = lhr19c) (ORACLE_HOME = /u01/app/oracle/product/19.2.0/dbhome_1) (SID_NAME = lhr19c) ) (SID_DESC = (GLOBAL_DBNAME = lhr19cdg) (ORACLE_HOME = /u01/app/oracle/product/19.2.0/dbhome_1) (SID_NAME = lhr19cdg) ) ) LISTENER_DG = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.52)(PORT = 1522)) ) SID_LIST_LISTENER_DG = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = lhr19c) (ORACLE_HOME = /u01/app/oracle/product/19.2.0/dbhome_1) (SID_NAME = lhr19c) ) (SID_DESC = (GLOBAL_DBNAME = lhr19cdg) (ORACLE_HOME = /u01/app/oracle/product/19.2.0/dbhome_1) (SID_NAME = lhr19cdg) ) ) lsnrctl start LISTENER_DG dbca -silent -createDuplicateDB \ -gdbName lhr19c \ -sid lhr19cdg \ -sysPassword lhr \ -primaryDBConnectionString 192.168.59.52:1522/lhr19c \ -nodelist raclhr-18c-n1 \ -databaseConfigType SINGLE \ -createAsStandby -dbUniqueName lhr19cdg \ -datafileDestination '/u01/app/oracle/oradata/lhr19cdg/' \ -initParams db_create_file_dest=/u01/app/oracle/oradata/lhr19cdg/, db_create_online_log_dest_1=/u01/app/oracle/oradata/lhr19cdg/,local_listener="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1522)))" --主庫修改引數 alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lhr19c'; alter system set LOG_ARCHIVE_DEST_2='service=lhr19cdg VALID_FOR=(online_logfiles,primary_role) DB_UNIQUE_NAME=lhr19cdg'; alter system set log_archive_config='dg_config=(lhr19c,lhr19cdg)'; alter system set db_file_name_convert='/u01/app/oracle/oradata/LHR19CDG/','/u01/app/oracle/oradata/LHR19C/' scope=spfile; alter system set log_file_name_convert='/u01/app/oracle/oradata/LHR19CDG/','/u01/app/oracle/oradata/LHR19C/' scope=spfile; alter system set standby_file_management=auto scope=spfile; alter system set fal_client='lhr19c'; alter system set fal_server='lhr19cdg' sid='*'; alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1522)))','(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1521)))'; shutdown immediate startup --備庫修改引數 alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lhr19cdg' scope=spfile; alter system set log_archive_config='dg_config=(lhr19c,lhr19cdg)'; alter system set db_file_name_convert='/u01/app/oracle/oradata/LHR19C/','/u01/app/oracle/oradata/LHR19CDG/' scope=spfile; alter system set log_file_name_convert='/u01/app/oracle/oradata/LHR19C/','/u01/app/oracle/oradata/LHR19CDG/' scope=spfile; alter system set standby_file_management=auto scope=spfile; alter system set fal_client='lhr19cdg'; alter system set fal_server='lhr19c' sid='*'; alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1522)))','(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1521)))'; shutdown immediate startup alter system register; --備庫查詢實時應用 alter database recover managed standby database cancel; alter database recover managed standby database using current logfile disconnect; ! ps -ef|grep ora_mrp select INST_ID, dbid,name,DB_UNIQUE_NAME,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database; COL NAME FOR A100 SET LINESIZE 9999 PAGESIZE 9999 COL NEXT_CHANGE# FOR 999999999999999 SELECT THREAD#, NAME, SEQUENCE#, ARCHIVED, APPLIED, A.NEXT_CHANGE# FROM V$ARCHIVED_LOG A WHERE A.SEQUENCE# >= (SELECT MAX(B.SEQUENCE#) - 3 FROM V$ARCHIVED_LOG B WHERE B.THREAD# = A.THREAD# AND B.RESETLOGS_CHANGE# = A.RESETLOGS_CHANGE# AND B.RESETLOGS_CHANGE# = (SELECT D.RESETLOGS_CHANGE# FROM V$DATABASE D) AND B.APPLIED = 'YES' GROUP BY B.THREAD#) ORDER BY A.THREAD#, A.SEQUENCE#;
About Me
........................................................................................................................ ● 本文作者:小麥苗,部分內容整理自網路,若有侵權請聯絡小麥苗刪除 ● 本文在itpub( http://blog.itpub.net/26736162 )、部落格園( http://www.cnblogs.com/lhrbest )和個人weixin公眾號( xiaomaimiaolhr )上有同步更新 ● 本文itpub地址: http://blog.itpub.net/26736162 ● 本文部落格園地址: http://www.cnblogs.com/lhrbest ● 本文pdf版、個人簡介及小麥苗雲盤地址: http://blog.itpub.net/26736162/viewspace-1624453/ ● 資料庫筆試面試題庫及解答: http://blog.itpub.net/26736162/viewspace-2134706/ ● DBA寶典今日頭條號地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826 ........................................................................................................................ ● QQ群號: 230161599 (滿) 、618766405 ● weixin群:可加我weixin,我拉大家進群,非誠勿擾 ● 聯絡我請加QQ好友 ( 646634621 ) ,註明新增緣由 ● 於 2019-03-01 06:00 ~ 2019-03-31 24:00 在魔都完成 ● 最新修改時間:2019-03-01 06:00 ~ 2019-03-31 24:00 ● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解 ● 版權所有,歡迎分享本文,轉載請保留出處 ........................................................................................................................ ● 小麥苗的微店 : https://weidian.com/s/793741433?wfr=c&ifr=shopdetail ● 小麥苗出版的資料庫類叢書 : http://blog.itpub.net/26736162/viewspace-2142121/ ● 小麥苗OCP、OCM、高可用網路班 : http://blog.itpub.net/26736162/viewspace-2148098/ ● 小麥苗騰訊課堂主頁 : https://lhr.ke.qq.com/ ........................................................................................................................ 使用 weixin客戶端 掃描下面的二維碼來關注小麥苗的weixin公眾號( xiaomaimiaolhr )及QQ群(DBA寶典)、新增小麥苗weixin, 學習最實用的資料庫技術。
........................................................................................................................ |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2638038/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【DG】Oracle 19c使用dbca來搭建物理DG--主rac備racOracle
- Oracle 18c使用dbca建立級聯DGOracle
- 物理DG、邏輯DG和快照DG的搭建(視訊講解)
- Oracle 11g單主搭建物理DGOracle
- oracle 19c dg搭建duplicate過程中報錯Oracle
- Oracle RAC+DG搭建Oracle
- 3 建立物理DG
- G007-ORACLE-INS-DG-01 ORACLE 19C DG 1P1S-CDB Ins ON RHEL 8.2Oracle
- 【DG】備庫RMAN還原方式搭建DG(不使用duplicate命令)
- G008-ORACLE-DG ORACLE 19C Active Data Guard DML RedirectionOracle
- Oracle:DG 的 switchoverOracle
- oracle dg報錯Oracle
- DG搭建配置方案
- 【DG】Oracle之級聯DG--(cascade dg) --(一主一備一級聯)Oracle
- 使用ansible-playbook自動化安裝Oracle DG資料庫19cOracle資料庫
- Oracle DG 日常點檢Oracle
- Oracle DG管理Broker配置Oracle
- DG -- READ ONLY模式開啟物理Standby模式
- ORACLE DG之備庫角色Oracle
- Oracle DG運維常用SQLOracle運維SQL
- oracle dg切換操作示例Oracle
- ORACLE 11.2.0.4 DG(Broker) for linux 部署OracleLinux
- Oracle DG Standby Database型別OracleDatabase型別
- Oracle DG建立Physical Standby DatabaseOracleDatabase
- Oracle DG建立Logical Standby DatabaseOracleDatabase
- 【DG】Data Guard搭建(physical standby)
- oracle ADG與DG的區別Oracle
- Oracle dg歸檔同步失敗Oracle
- Oracle DG管理Redo Transport服務Oracle
- Oracle DG異構主備支援Oracle
- ORACLE19C RAC+DGOracle
- Oracle 面試寶典-DG篇Oracle面試
- Oracle RAC DG手動切換Oracle
- ORACLE RAC TO RAC DG搭建過程中可能遇到的問題Oracle
- 11G RAC+DG搭建
- 【ASK_ORACLE】Oracle Data Guard(一)DG架構Oracle架構
- oracle DG 日誌傳輸小結Oracle
- ORACLE RAC+DG調整redo大小Oracle