日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Duplicate standby database from active database

發(fā)布時(shí)間:2023/11/30 编程问答 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Duplicate standby database from active database 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
11g Release1 中引入了新的RMAN duplicate命令,即duplicate from active database命令。利用該命令可以更加便捷地創(chuàng)建Data Guard環(huán)境,你甚至不需要將Primary Database shutdown(整個(gè)過(guò)程中主庫(kù)都可以處于打開狀態(tài)下),也不需要在配置前做一些額外的備份操作,僅需要配置起auxiliary輔助實(shí)例,同時(shí)創(chuàng)建密碼文件,并在監(jiān)聽(tīng)(LISTENER)中加入靜態(tài)注冊(cè)信息后就可以開始工作了! 以下示例中我們會(huì)在Primary Database所在的同一臺(tái)服務(wù)器上部署一套物理備庫(kù)(Physical Standby),實(shí)際上這樣比在不同的2臺(tái)服務(wù)器上配置Data Guard要復(fù)雜些,原因是那樣的話我們無(wú)需做File Name的轉(zhuǎn)換,具體的環(huán)境:
Database RoleDB_UNIQUE_NAME
Primary DatabasePROD
Standby DatabaseSBDB
? /* 需要注意的是DG環(huán)境中force logging,不要用了新特性就將這個(gè)基本的要求忘記了 ! */SQL> select * from v$version;BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production PL/SQL Release 11.2.0.2.0 - Production CORE 11.2.0.2.0 Production TNS for Linux: Version 11.2.0.2.0 - Production NLSRTL Version 11.2.0.2.0 - Production/* 顯然PROD主庫(kù)應(yīng)當(dāng)處于歸檔模式并且是FORCE LOGGING狀態(tài)下 */SQL> alter database force logging; Database altered.同時(shí)在Primary Database上創(chuàng)建必要的standby logfile:SQL> alter database add standby logfile group 7 size 50M; Database altered.SQL> alter database add standby logfile group 8 size 50M; Database altered.............../* standby實(shí)例只需要db_name參數(shù)就可以啟動(dòng)到nomount模式了,并為standby數(shù)據(jù)庫(kù)創(chuàng)建密碼文件 */[maclean@rh6 ~]$ echo "db_name=PROD" >$ORACLE_HOME/dbs/initSBDB.ora[maclean@rh6 ~]$ orapwd file=$ORACLE_HOME/dbs/orapwSBDB password=XXXX entries=10[maclean@rh6 ~]$ cd $ORACLE_HOME/network/admin我們需要保證PROD和SBDB實(shí)例在監(jiān)聽(tīng)器Listener中被靜態(tài)注冊(cè),同時(shí)也包括DGMGRL需要用到的*_DGMGRL服務(wù)名[maclean@rh6 admin]$ cat listener.ora # listener23920.ora Network Configuration File: /tmp/listener23920.ora # Generated by Oracle configuration tools.DGLSN =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = rh6.oracle.com)(PORT = 1588)))SID_LIST_DGLSN =(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = PROD)(ORACLE_HOME = /s01/product/11.2.0/dbhome_2)(SID_NAME = PROD))(SID_DESC =(GLOBAL_DBNAME = SBDB)(ORACLE_HOME = /s01/product/11.2.0/dbhome_2)(SID_NAME = SBDB))(SID_DESC =(GLOBAL_DBNAME = PROD_DGMGRL)(ORACLE_HOME = /s01/product/11.2.0/dbhome_2)(SID_NAME = PROD))(SID_DESC =(GLOBAL_DBNAME = SBDB_DGMGRL)(ORACLE_HOME = /s01/product/11.2.0/dbhome_2)(SID_NAME = SBDB)))/* 并在tnsnames.ora文件中加入必要的服務(wù)別名 */[maclean@rh6 admin]$ cat tnsnames.ora # tnsnames.ora Network Configuration File: /s01/product/11.2.0/dbhome_2/network/admin/tnsnames.ora # Generated by Oracle configuration tools.PROD =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = rh6.oracle.com)(PORT = 1588))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = PROD)))SBDB =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = rh6.oracle.com)(PORT = 1588)))(CONNECT_DATA =(SERVICE_NAME = SBDB)))DGLSN =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = rh6.oracle.com)(PORT = 1588)))接著我們來(lái)啟動(dòng)輔助實(shí)例[maclean@rh6 ~]$ export ORACLE_SID=SBDB [maclean@rh6 ~]$ sqlplus / as sysdba SQL> startup nomount; ORACLE instance started./* 使用遠(yuǎn)程登錄測(cè)試是否可以以SYSDBA登錄SBDB實(shí)例 */[maclean@rh6 ~]$ sqlplus sys/XXXXXX@SBDB as sysdba下面我們需要準(zhǔn)備一份duplicate standby database的腳本, 因?yàn)槲覀兪窃谕慌_(tái)主機(jī)上配置Data Guard所以這里要用到db_file_name_convert和log_file_name_convert, 如果你的環(huán)境中不需要這么做那么你可以指定NOFILENAMECHECK;以下為示例的腳本,可以看到它并不復(fù)雜只是指定了必要的初始化參數(shù),十分易于記憶。[maclean@rh6 ~]$ cat duplicate_act_standby.rcv duplicate target database for standby from active database DORECOVER spfile set db_unique_name='SBDB' set log_archive_dest_1='location=/standby/arch02' set log_archive_dest_2='service=PROD async lgwr register valid_for=(online_logfile,primary_role) db_unique_name=PROD' set standby_file_management='AUTO' set fal_server='PROD' set fal_client='SBDB' set control_files='/standby/oradata/SBDB/controlfile/control1.ctl','/standby/oradata/SBDB/controlfile/control2.ctl' set db_file_name_convert='PROD','SBDB' set log_file_name_convert='PROD','SBDB' set memory_target='0' set sga_target='400M';具體執(zhí)行以上腳本,我們需要同時(shí)登錄target database PROD和auxiliary instance輔助實(shí)例SBDB:[maclean@rh6 ~]$ echo $ORACLE_SID PROD[maclean@rh6 ~]$ rman target / auxiliary sys/oracle@SBDB cmdfile=duplicate_act_standby.rcv log=das.logconnected to target database: PROD (DBID=158660885) connected to auxiliary database: PROD (not mounted)RMAN> duplicate target database 2> for standby 3> from active database 4> DORECOVER 5> spfile 6> set db_unique_name='SBDB' 7> set log_archive_dest_1='location=/standby/arch02' 8> set log_archive_dest_2='service=PROD async lgwr register valid_for=(online_logfile,primary_role) db_unique_name=PROD' 9> set standby_file_management='AUTO' 10> set fal_server='PROD' 11> set fal_client='SBDB' 12> set control_files='/standby/oradata/SBDB/controlfile/control1.ctl','/standby/oradata/SBDB/controlfile/control2.ctl' 13> set db_file_name_convert='PROD','SBDB' 14> set log_file_name_convert='PROD','SBDB' 15> set memory_target='0' 16> set sga_target='400M'; 17> Starting Duplicate Db at 26-MAR-11 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=96 device type=DISKcontents of Memory Script: {backup as copy reusetargetfile '/s01/product/11.2.0/dbhome_2/dbs/orapwPROD' auxiliary format'/s01/product/11.2.0/dbhome_2/dbs/orapwSBDB' targetfile'/s01/product/11.2.0/dbhome_2/dbs/spfilePROD.ora' auxiliary format'/s01/product/11.2.0/dbhome_2/dbs/spfileSBDB.ora' ;sql clone "alter system set spfile= ''/s01/product/11.2.0/dbhome_2/dbs/spfileSBDB.ora''"; } executing Memory ScriptStarting backup at 26-MAR-11 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=17 device type=DISK Finished backup at 26-MAR-11sql statement: alter system set spfile= ''/s01/product/11.2.0/dbhome_2/dbs/spfileSBDB.ora''contents of Memory Script: {sql clone "alter system set db_unique_name =''SBDB'' comment='''' scope=spfile";sql clone "alter system set log_archive_dest_1 =''location=/standby/arch02'' comment='''' scope=spfile";sql clone "alter system set log_archive_dest_2 =''service=PROD async lgwr register valid_for=(online_logfile,primary_role) db_unique_name=PROD'' comment='''' scope=spfile";sql clone "alter system set standby_file_management =''AUTO'' comment='''' scope=spfile";sql clone "alter system set fal_server =''PROD'' comment='''' scope=spfile";sql clone "alter system set fal_client =''SBDB'' comment='''' scope=spfile";sql clone "alter system set control_files =''/standby/oradata/SBDB/controlfile/control1.ctl'', ''/standby/oradata/SBDB/controlfile/control2.ctl'' comment='''' scope=spfile";sql clone "alter system set db_file_name_convert =''PROD'', ''SBDB'' comment='''' scope=spfile";sql clone "alter system set log_file_name_convert =''PROD'', ''SBDB'' comment='''' scope=spfile";sql clone "alter system set memory_target =0 comment='''' scope=spfile";sql clone "alter system set sga_target =400M comment='''' scope=spfile";shutdown clone immediate;startup clone nomount; } executing Memory Scriptsql statement: alter system set db_unique_name = ''SBDB'' comment= '''' scope=spfilesql statement: alter system set log_archive_dest_1 = ''location=/standby/arch02'' comment= '''' scope=spfilesql statement: alter system set log_archive_dest_2 = ''service=PROD async lgwr register valid_for=(online_logfile,primary_role) db_unique_name=PROD'' comment= '''' scope=spfilesql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfilesql statement: alter system set fal_server = ''PROD'' comment= '''' scope=spfilesql statement: alter system set fal_client = ''SBDB'' comment= '''' scope=spfilesql statement: alter system set control_files = ''/standby/oradata/SBDB/controlfile/control1.ctl'', ''/standby/oradata/SBDB/controlfile/control2.ctl'' comment= '''' scope=spfilesql statement: alter system set db_file_name_convert = ''PROD'', ''SBDB'' comment= '''' scope=spfilesql statement: alter system set log_file_name_convert = ''PROD'', ''SBDB'' comment= '''' scope=spfilesql statement: alter system set memory_target = 0 comment= '''' scope=spfilesql statement: alter system set sga_target = 400M comment= '''' scope=spfileOracle instance shut downconnected to auxiliary database (not started) Oracle instance startedTotal System Global Area 417546240 bytesFixed Size 2227072 bytes Variable Size 134218880 bytes Database Buffers 272629760 bytes Redo Buffers 8470528 bytescontents of Memory Script: {backup as copy current controlfile for standby auxiliary format '/standby/oradata/SBDB/controlfile/control1.ctl';restore clone controlfile to '/standby/oradata/SBDB/controlfile/control2.ctl' from'/standby/oradata/SBDB/controlfile/control1.ctl'; } executing Memory ScriptStarting backup at 26-MAR-11 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy copying standby control file output file name=/s01/product/11.2.0/dbhome_2/dbs/snapcf_PROD.f tag=TAG20110326T195144 RECID=2 STAMP=746826704 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 26-MAR-11Starting restore at 26-MAR-11 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=134 device type=DISKchannel ORA_AUX_DISK_1: copied control file copy Finished restore at 26-MAR-11contents of Memory Script: {sql clone 'alter database mount standby database'; } executing Memory Scriptsql statement: alter database mount standby databasecontents of Memory Script: {set newname for tempfile 1 to"/standby/oradata/SBDB/datafile/o1_mf_temp_6rvjsmr4_.tmp";switch clone tempfile all;set newname for datafile 1 to"/standby/oradata/SBDB/datafile/o1_mf_system_6rvjrtxh_.dbf";set newname for datafile 2 to"/standby/oradata/SBDB/datafile/o1_mf_sysaux_6rvjs6vh_.dbf";set newname for datafile 3 to"/standby/oradata/SBDB/datafile/o1_mf_undotbs1_6rvjsjjg_.dbf";set newname for datafile 4 to"/standby/oradata/SBDB/datafile/o1_mf_users_6rvjsy5q_.dbf";backup as copy reusedatafile 1 auxiliary format"/standby/oradata/SBDB/datafile/o1_mf_system_6rvjrtxh_.dbf" datafile2 auxiliary format"/standby/oradata/SBDB/datafile/o1_mf_sysaux_6rvjs6vh_.dbf" datafile3 auxiliary format"/standby/oradata/SBDB/datafile/o1_mf_undotbs1_6rvjsjjg_.dbf" datafile4 auxiliary format"/standby/oradata/SBDB/datafile/o1_mf_users_6rvjsy5q_.dbf" ;sql 'alter system archive log current'; } executing Memory Scriptexecuting command: SET NEWNAMErenamed tempfile 1 to /standby/oradata/SBDB/datafile/o1_mf_temp_6rvjsmr4_.tmp in control fileexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting backup at 26-MAR-11 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/standby/oradata/PROD/datafile/o1_mf_system_6rvjrtxh_.dbf output file name=/standby/oradata/SBDB/datafile/o1_mf_system_6rvjrtxh_.dbf tag=TAG20110326T195152 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=/standby/oradata/PROD/datafile/o1_mf_sysaux_6rvjs6vh_.dbf output file name=/standby/oradata/SBDB/datafile/o1_mf_sysaux_6rvjs6vh_.dbf tag=TAG20110326T195152 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/standby/oradata/PROD/datafile/o1_mf_undotbs1_6rvjsjjg_.dbf output file name=/standby/oradata/SBDB/datafile/o1_mf_undotbs1_6rvjsjjg_.dbf tag=TAG20110326T195152 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/standby/oradata/PROD/datafile/o1_mf_users_6rvjsy5q_.dbf output file name=/standby/oradata/SBDB/datafile/o1_mf_users_6rvjsy5q_.dbf tag=TAG20110326T195152 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 26-MAR-11sql statement: alter system archive log currentcontents of Memory Script: {backup as copy reusearchivelog like "/standby/arch01/1_17_746822549.dbf" auxiliary format"/standby/arch02/1_17_746822549.dbf" ;catalog clone archivelog "/standby/arch02/1_17_746822549.dbf";switch clone datafile all; } executing Memory ScriptStarting backup at 26-MAR-11 using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=17 RECID=3 STAMP=746826751 output file name=/standby/arch02/1_17_746822549.dbf RECID=0 STAMP=0 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 Finished backup at 26-MAR-11cataloged archived log archived log file name=/standby/arch02/1_17_746822549.dbf RECID=1 STAMP=746826752datafile 1 switched to datafile copy input datafile copy RECID=2 STAMP=746826752 file name=/standby/oradata/SBDB/datafile/o1_mf_system_6rvjrtxh_.dbf datafile 2 switched to datafile copy input datafile copy RECID=3 STAMP=746826752 file name=/standby/oradata/SBDB/datafile/o1_mf_sysaux_6rvjs6vh_.dbf datafile 3 switched to datafile copy input datafile copy RECID=4 STAMP=746826752 file name=/standby/oradata/SBDB/datafile/o1_mf_undotbs1_6rvjsjjg_.dbf datafile 4 switched to datafile copy input datafile copy RECID=5 STAMP=746826752 file name=/standby/oradata/SBDB/datafile/o1_mf_users_6rvjsy5q_.dbfcontents of Memory Script: {set until scn 242517;recoverstandbyclone databasedelete archivelog; } executing Memory Scriptexecuting command: SET until clauseStarting recover at 26-MAR-11 using channel ORA_AUX_DISK_1starting media recoveryarchived log for thread 1 with sequence 17 is already on disk as file /standby/arch02/1_17_746822549.dbf archived log file name=/standby/arch02/1_17_746822549.dbf thread=1 sequence=17 media recovery complete, elapsed time: 00:00:00 Finished recover at 26-MAR-11 Finished Duplicate Db at 26-MAR-11Recovery Manager complete.[maclean@rh6 ~]$ export ORACLE_SID=PROD [maclean@rh6 ~]$ sqlplus / as sysdba/* 在主庫(kù)PROD上設(shè)置到物理備庫(kù)SBDB的歸檔目的地 */SQL> alter system set log_archive_dest_2='service=sbdb lgwr async ? valid_for=(online_logfiles,primary_role) db_unique_name=SBDB'; System altered.以上完成了對(duì)物理備庫(kù)Physical Standby的配置,緊接著我們來(lái)配合Data Broker:SQL> alter system set dg_broker_start=true; System altered.[maclean@rh6 ~]$ export ORACLE_SID=SBDB [maclean@rh6 ~]$ sqlplus / as sysdbaSQL> alter system set dg_broker_start=true; System altered.[maclean@rh6 ~]$ dgmgrl sys/oracle@PROD DGMGRL for Linux: Version 11.2.0.2.0 - 64bit ProductionCopyright (c) 2000, 2009, Oracle. All rights reserved.Welcome to DGMGRL, type "help" for information. Connected.DGMGRL> create CONFIGURATION PROD as PRIMARY DATABASE IS PROD CONNECT IDENTIFIER IS PROD; Configuration "prod" created with primary database "prod"DGMGRL> add database sbdb AS CONNECT IDENTIFIER IS sbdb MAINTAINED AS PHYSICAL; Database "sbdb" addedDGMGRL> enable configuration; Enabled.DGMGRL> edit database prod set property LogXptMode='sync'; Property "logxptmode" updated DGMGRL> edit database sbdb set property LogXptMode='sync'; Property "logxptmode" updated/* 修改當(dāng)前DG的保護(hù)模式為最大可用模式MaxAvailability */DGMGRL> edit CONFIGURATION SET PROTECTION MODE as MaxAvailability; Succeeded.DGMGRL> show configuration;Configuration - prodProtection Mode: MaxAvailabilityDatabases:prod - Primary databasesbdb - Physical standby databaseError: ORA-16766: Redo Apply is stoppedFast-Start Failover: DISABLEDConfiguration Status: ERROR/* 以上可以看到物理備庫(kù)SBDB上的REDO APPLY被停止了,我們可以在DGMGRL中啟動(dòng)其REDO APPLY */DGMGRL> edit database sbdb set state='APPLY-ON'; Succeeded.DGMGRL> show configuration;Configuration - prodProtection Mode: MaxAvailabilityDatabases:prod - Primary databasesbdb - Physical standby databaseFast-Start Failover: DISABLEDConfiguration Status: SUCCESS/* 以下使用DGMGRL來(lái)回切換主備庫(kù)角色,十分方便 */DGMGRL> switchover to sbdb; Performing switchover NOW, please wait... New primary database "sbdb" is opening... Operation requires shutdown of instance "PROD" on database "prod" Shutting down instance "PROD"... ORACLE instance shut down. Operation requires startup of instance "PROD" on database "prod" Starting instance "PROD"... ORACLE instance started. Database mounted. Switchover succeeded, new primary is "sbdb"DGMGRL> switchover to prod; Performing switchover NOW, please wait... New primary database "prod" is opening... Operation requires shutdown of instance "SBDB" on database "sbdb" Shutting down instance "SBDB"... ORACLE instance shut down. Operation requires startup of instance "SBDB" on database "sbdb" Starting instance "SBDB"... ORACLE instance started. Database mounted. Switchover succeeded, new primary is "prod"

轉(zhuǎn)載于:https://www.cnblogs.com/macleanoracle/archive/2013/03/19/2967711.html

總結(jié)

以上是生活随笔為你收集整理的Duplicate standby database from active database的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。