您好,登錄后才能下訂單哦!
Oracle Data Guard確保了企業數據的高可用性、數據保護和災難恢復。Data Guard提供了一套全面的服務,用于創建、維護、管理和監視一個或多個備用數據庫,以使生產數據庫能夠在災難和數據損壞中生存。Data Guard將這些備用數據庫維護為生產數據庫的事務一致副本。然后,如果由于計劃內或計劃外停機而導致生產數據庫不可用,則Data Guard可以將任何備用數據庫切換到生產角色,從而將與停機相關的停機時間降至最低。數據保護可以與傳統的備份、恢復和群集技術一起使用,以提供高級別的數據保護和數據可用性。
[oracle@wallet01?~]$?sqlplus?/?as?sysdba SQL>?alter?database?force?logging; Database?altered. SQL>?col?force_logging?for?a15 SQL>?select?force_logging?from?v$database; FORCE_LOGGING --------------- YES SQL>?archive?log?list; Database?log?mode??????????????Archive?Mode Automatic?archival?????????????Enabled Archive?destination????????????USE_DB_RECOVERY_FILE_DEST Oldest?online?log?sequence?????35 Next?log?sequence?to?archive???37 Current?log?sequence???????????37 SQL>?alter?system?set?db_unique_name='walletmdb'?scope=spfile; SQL>?alter?system?set?log_archive_config='dg_config=(walletmdb,walletsdb)'?scope=spfile; SQL>?alter?system?set?log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST?valid_for=(all_logfiles,all_roles)?db_unique_name=walletmdb'?scope=spfile; SQL>?alter?system?set?log_archive_dest_2='service=walletsdb?lgwr?async?valid_for=(online_logfiles,primary_role)?db_unique_name=walletsdb'?scope=spfile; SQL>?alter?system?set?fal_server='walletsdb'?scope=spfile; SQL>?alter?system?set?standby_file_management='auto'?scope=spfile; SQL>?alter?system?set?log_archive_dest_state_2='defer'?scope=spfile; SQL>?alter?system?set?service_names=walletdb,walletmdb?scope=spfile; [oracle@wallet01?~]$?cd?$ORACLE_HOME/dbs [oracle@wallet01?dbs]$?sqlplus?/?as?sysdba SQL>?create?pfile?from?spfile;?? File?created. [oracle@wallet01?dbs]$?scp?initwalletdb.ora?192.168.1.202:/u01/app/oracle/product/11.2.0/db_1/dbs [oracle@wallet01?dbs]$?scp?orapwwalletdb?192.168.1.202:/u01/app/oracle/product/11.2.0/db_1/dbs [oracle@wallet01?~]$?mkdir?backup [oracle@wallet02?~]$?mkdir?backup [oracle@wallet01?~]$?rman?target?/ RMAN>?backup?device?type?disk?format?'/home/oracle/backup/%U'?database?plus?archivelog; RMAN>?backup?device?type?disk?format?'/home/oracle/backup/%U'?current?controlfile?for?standby; [oracle@wallet01?~]$?scp?/home/oracle/backup/*??192.168.1.202:/home/oracle/backup [oracle@wallet01?~]$?vi?$ORACLE_HOME/network/admin/tnsnames.ora walletmdb?= ??(DESCRIPTION?= ????(ADDRESS_LIST?= ??????(ADDRESS?=?(PROTOCOL?=?TCP)(HOST?=?192.168.1.201)(PORT?=?1521)) ????) ????(CONNECT_DATA?= ??????(SERVICE_NAME?=?walletdb) ????) ??) walletsdb?= ??(DESCRIPTION?= ????(ADDRESS_LIST?= ??????(ADDRESS?=?(PROTOCOL?=?TCP)(HOST?=?192.168.1.202)(PORT?=?1521)) ????) ????(CONNECT_DATA?= ??????(SERVICE_NAME?=?walletdb) ????) ??) [oracle@wallet02?~]$?vi?$ORACLE_HOME/network/admin/listener.ora SID_LIST_LISTENER?= ??(SID_LIST?= ????(SID_DESC?= ??????(GLOBAL_DBNAME?=?walletdb) ??????(ORACLE_HOME?=?/u01/app/oracle/product/11.2.0/db_1) ??????(SID_NAME?=?walletdb) ????) ??) LISTENER?= ??(DESCRIPTION?= ????(ADDRESS?=?(PROTOCOL?=?TCP)(HOST?=?wallet02)(PORT?=?1521)) ??) ADR_BASE_LISTENER?=?/u01/app/oracle [oracle@wallet02?~]$?lsnrctl?start [oracle@wallet02?~]$?lsnrctl?status?? [oracle@wallet02?~]$?vi?$ORACLE_HOME/network/admin/tnsnames.ora walletmdb?= ??(DESCRIPTION?= ????(ADDRESS_LIST?= ??????(ADDRESS?=?(PROTOCOL?=?TCP)(HOST?=?192.168.1.201)(PORT?=?1521)) ????) ????(CONNECT_DATA?= ??????(SERVICE_NAME?=?walletdb) ????) ??) walletsdb?= ??(DESCRIPTION?= ????(ADDRESS_LIST?= ??????(ADDRESS?=?(PROTOCOL?=?TCP)(HOST?=?192.168.1.202)(PORT?=?1521)) ????) ????(CONNECT_DATA?= ??????(SERVICE_NAME?=?walletdb) ????) ??) ?? [oracle@wallet01?~]$?tnsping?walletsdb Used?TNSNAMES?adapter?to?resolve?the?alias Attempting?to?contact?(DESCRIPTION?=?(ADDRESS_LIST?=?(ADDRESS?=?(PROTOCOL?=?TCP)(HOST?=?192.168.1.202)(PORT?=?1521)))?(CONNECT_DATA?=?(SERVICE_NAME?=? walletdb))) OK?(40?msec) [oracle@wallet02?~]$?tnsping?walletmdb Used?TNSNAMES?adapter?to?resolve?the?alias Attempting?to?contact?(DESCRIPTION?=?(ADDRESS_LIST?=?(ADDRESS?=?(PROTOCOL?=?TCP)(HOST?=?192.168.1.201)(PORT?=?1521)))?(CONNECT_DATA?=?(SERVICE_NAME?=? walletdb))) OK?(30?msec)?? [oracle@wallet02?~]$?cd?$ORACLE_HOME/dbs [oracle@wallet02?dbs]$?vi?initambdb.ora *.audit_file_dest='/u01/app/oracle/admin/walletdb/adump' *.audit_trail='db' *.compatible='11.2.0.4.0' *.control_files='/u01/app/oracle/oradata/ambdb/control01.ctl','/u01/app/oracle/fast_recovery_area/ambdb/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='walletdb' *.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' *.db_recovery_file_dest_size=107374182400 *.db_unique_name='walletsdb' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP)?(SERVICE=walletdbXDB)' *.fal_server='walletmdb' *.log_archive_config='dg_config=(walletmdb,walletsdb)' *.log_archive_dest_1='location=db_recovery_file_dest?valid_for=(all_logfiles,all_roles)?db_unique_name=walletsdb' *.log_archive_dest_2='service=walletmdb?lgwr?async?valid_for=(online_logfiles,primary_role)?db_unique_name=walletmdb' *.memory_max_target=1073741824 *.memory_target=1073741824 *.open_cursors=300 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.service_names='walletdb','walletsdb' *.standby_file_management='auto' *.undo_tablespace='UNDOTBS1' [oracle@wallet02?dbs]$?sqlplus?/?as?sysdba SQL>?create?spfile?from?pfile; File?created. [oracle@wallet02?~]$?mkdir?-p?/u01/app/oracle/admin/walletdb/adump [oracle@wallet02?~]$?mkdir?-p?/u01/app/oracle/oradata/walletdb [oracle@wallet02?~]$?mkdir?-p?/u01/app/oracle/fast_recovery_area/walletdb [oracle@wallet02?~]$?sqlplus?/?as?sysdba SQL>?startup?nomount; ORACLE?instance?started. Total?System?Global?Area?1068937216?bytes Fixed?Size??????????????????2260088?bytes Variable?Size?????????????432014216?bytes Database?Buffers??????????629145600?bytes Redo?Buffers????????????????5517312?bytes [oracle@wallet02?~]$?rman?target?sys/oracle@walletmdb?auxiliary?sys/oracle@walletsdb?nocatalog Recovery?Manager:?Release?11.2.0.4.0?-?Production?on?Sat?Mar?31?14:25:26?2018 Copyright?(c)?1982,?2011,?Oracle?and/or?its?affiliates.??All?rights?reserved. connected?to?target?database:?walletdb?(DBID=1072562510) using?target?database?control?file?instead?of?recovery?catalog connected?to?auxiliary?database:?walletdb?(not?mounted) RMAN>?duplicate?target?database?for?standby?dorecover?nofilenamecheck; [oracle@wallet02?~]$?sqlplus?/?as?sysdba SQL>?alter?database?add?standby?logfile?'/u01/app/oracle/oradata/walletdb/standby01.log'?size?50m; SQL>?alter?database?add?standby?logfile?'/u01/app/oracle/oradata/walletdb/standby02.log'?size?50m; SQL>?alter?database?add?standby?logfile?'/u01/app/oracle/oradata/walletdb/standby03.log'?size?50m; SQL>?alter?database?add?standby?logfile?'/u01/app/oracle/oradata/walletdb/standby04.log'?size?50m; SQL>?alter?database?recover?managed?standby?database?disconnect?from?session?using?current?logfile; [oracle@wallet01?~]$?sqlplus?/?as?sysdba SQL>?alter?system?set?log_archive_dest_state_2=enable?scope=both; SQL>?alter?system?switch?logfile; [oracle@wallet02?~]$?sqlplus?/?as?sysdba SQL>?alter?database?recover?managed?standby?database?cancel; SQL>?alter?database?open; SQL>?alter?database?recover?managed?standby?database?disconnect?from?session?using?current?logfile; [oracle@wallet01?~]$?sqlplus?/?as?sysdba sql>?set?line?200 sql>?col?database_mode?for?a30 sql>?col?protection_mode?for?a30 sql>?col?recovery_mode?for?a30 sql>?select?dest_id?,?database_mode?,?recovery_mode?,?protection_mode?from?v$archive_dest_status?where?dest_id=2; ???dest_id?database_mode??????????????????recovery_mode??????????????????protection_mode ----------?------------------------------?------------------------------?------------------------------ ?????????2?open_read-only?????????????????managed?real?time?apply????????maximum?performance ????????? sql>?col?dest_name?for?a20 sql>?col?destination?for?a30 sql>?col?error?for?a50? sql>?select?dest_id,dest_name,status,?destination,?error?from?v$archive_dest?where?dest_id<=2; ???dest_id?dest_name????????????status??????????????????????destination????????????????????error ----------?--------------------?---------------------------?------------------------------?-------------------------------------------------- ?????????1?log_archive_dest_1???valid???????????????????????db_recovery_file_dest ?????????2?log_archive_dest_2???valid???????????????????????walletsdb sql>?col?type?for?a20 sql>?select?dest_name,destination,status,type,archived_seq#,applied_seq#?from?v$archive_dest_status?where?dest_id<=2;? dest_name????????????destination????????????????????status??????????????????????type?????????????????archived_seq#?applied_seq# --------------------?------------------------------?---------------------------?--------------------?-------------?------------ log_archive_dest_1???db_recovery_file_dest??????????valid???????????????????????local???????????????????????????50????????????0 log_archive_dest_2???walletsdb??????????????????????valid???????????????????????physical????????????????????????50???????????49 sql>?select?thread#?,?sequence#?,?status?from?v$log; ???thread#??sequence#?status ----------?----------?------------------------------------------------ ?????????1?????????49?inactive ?????????1?????????50?inactive ?????????1?????????51?current ????????? [oracle@wallet02?~]$?sqlplus?/?as?sysdba sql>?set?line?200 sql>?col?archived?for?a10 sql>?select?thread#?,?sequence#?,?archived?,?status?from?v$standby_log; ???thread#??sequence#?archived???status ----------?----------?----------?------------------------------ ?????????1?????????51?yes????????active ?????????1??????????0?no?????????unassigned ?????????0??????????0?yes????????unassigned ?????????0??????????0?yes????????unassigned ????????? sql>?select?process?,?status?,?thread#?,?sequence#?,?block#?,?blocks??from?v$managed_standby?where?process?!=?'ARCH'; process?????????????????????status??????????????????????????????????thread#??sequence#?????block#?????blocks ---------------------------?------------------------------------?----------?----------?----------?---------- rfs?????????????????????????idle??????????????????????????????????????????0??????????0??????????0??????????0 rfs?????????????????????????idle??????????????????????????????????????????0??????????0??????????0??????????0 rfs?????????????????????????idle??????????????????????????????????????????1?????????51???????4381??????????1 mrp0????????????????????????applying_log??????????????????????????????????1?????????51???????4381?????102400
Data?Guard?保護模式 Data?Guard?保護模式 SQL>?alter?system?set?log_archive_dest_2='SERVICE=walletsdb?LGWR?SYNC?AFFIRM?valid_for=(online_logfiles,primary_role)?db_unique_name=walletsdb'?scope=spfile; SQL>?shutdown?immediate; SQL>?startup?mount; SQL>?alter?database?set?standby?database?to?maximize?availability; SQL>?alter?database?open; SQL>?select?DEST_ID?,?DATABASE_MODE?,?RECOVERY_MODE?,?PROTECTION_MODE?from?v$archive_dest_status?where?DEST_ID=2; ???DEST_ID?DATABASE_MODE???RECOVERY_MODE???????????PROTECTION_MODE ----------?---------------?-----------------------?-------------------- ?????????2?OPEN_READ-ONLY??MANAGED?REAL?TIME?APPLY?MAXIMUM?AVAILABILITY ????????? SQL>?alter?system?set?log_archive_dest_2='SERVICE=walletsdb?LGWR?SYNC?AFFIRM?valid_for=(online_logfiles,primary_role)?db_unique_name=walletsdb'?scope=spfile; SQL>?shutdown?immediate; SQL>?startup?mount; SQL>?alter?database?set?standby?database?to?maximize?protection; SQL>?alter?database?open; QL>?select?DEST_ID?,?DATABASE_MODE?,?RECOVERY_MODE?,?PROTECTION_MODE?from?v$archive_dest_status?where?DEST_ID=2; ???DEST_ID?DATABASE_MODE???RECOVERY_MODE???????????PROTECTION_MODE ----------?---------------?-----------------------?-------------------- ?????????2?OPEN_READ-ONLY??MANAGED?REAL?TIME?APPLY?MAXIMUM?PROTECTION ????????? SQL>?alter?system?set?log_archive_dest_2='SERVICE=walletsdb?LGWR?ASYNC?valid_for=(online_logfiles,primary_role)?db_unique_name=walletsdb'?scope=spfile; SQL>?shutdown?immediate; SQL>?startup?mount; SQL>?alter?database?set?standby?database?to?maximize?performance; SQL>?alter?database?open; SQL>?select?DEST_ID?,?DATABASE_MODE?,?RECOVERY_MODE?,?PROTECTION_MODE?from?v$archive_dest_status?where?DEST_ID=2; ???DEST_ID?DATABASE_MODE???RECOVERY_MODE???????????PROTECTION_MODE ----------?---------------?-----------------------?-------------------- ?????????2?OPEN_READ-ONLY??MANAGED?REAL?TIME?APPLY?MAXIMUM?PERFORMANCE
Data?Guard?Switchover 原主庫(轉換為備庫) SQL>?select?switchover_status?from?v$database; SWITCHOVER_STATUS -------------------- TO?STANDBY SQL>?alter?database?commit?to?switchover?to?physical?standby?with?session?shutdown; Database?altered. SQL>?shutdown?immediate; SQL>?startup?mount; SQL>?alter?database?open?read?only; Database?altered. SQL>?alter?database?recover?managed?standby?database?using?current?logfile?disconnect?from?session; Database?altered. SQL>?select?database_role?from?v$database; DATABASE_ROLE ---------------- PHYSICAL?STANDBY 原備庫(轉換為主庫) SQL>?select?switchover_status?from?v$database; SWITCHOVER_STATUS -------------------- TO?PRIMARY SQL>?alter?database?commit?to?switchover?to?primary; Database?altered. SQL>?alter?database?open;????? Database?altered. SQL>?select?database_role?from?v$database; DATABASE_ROLE ---------------- PRIMARY SQL>?select?DEST_ID?,?DATABASE_MODE?,?RECOVERY_MODE?,?PROTECTION_MODE?from?v$archive_dest_status?where?DEST_ID=2; ???DEST_ID?DATABASE_MODE???RECOVERY_MODE???????????PROTECTION_MODE ----------?---------------?-----------------------?-------------------- ?????????2?OPEN_READ-ONLY??MANAGED?REAL?TIME?APPLY?MAXIMUM?PERFORMANCE
Data?Guard?Failover 開啟主庫的閃回模式 SQL>?select?name,?open_mode,?database_role,?flashback_on?from?v$database;? NAME??????OPEN_MODE????????????DATABASE_ROLE????FLASHBACK_ON ---------?--------------------?----------------?------------------ DB01??????READ?WRITE???????????PRIMARY??????????NO SQL>?shutdown?immediate; SQL>?startup?mount? SQL>?alter?database?flashback?on; SQL>?alter?database?open;? SQL>?select?flashback_on?from?v$database;? FLASHBACK_ON ------------------ YES SQL>?show?parameter?flashback? NAME?????????????????????????????????TYPE????????VALUE ------------------------------------?-----------?------------------------------ db_flashback_retention_target????????integer?????1440 模擬主庫故障 SQL>?shutdown?abort;? 原備庫(轉換為主庫) SQL>?alter?database?recover?managed?standby?database?cancel;? SQL>?alter?database?recover?managed?standby?database?finish;? SQL>?select?open_mode,?database_role?from?v$database;? OPEN_MODE????????????DATABASE_ROLE --------------------?---------------- READ?ONLY????????????PHYSICAL?STANDBY SQL>?alter?database?commit?to?switchover?to?primary?with?session?shutdown;? Database?altered. SQL>?alter?database?open; Database?altered. SQL>??select?open_mode,?database_role?from?v$database;? OPEN_MODE????????????DATABASE_ROLE --------------------?---------------- READ?WRITE???????????PRIMARY SQL>?select?STANDBY_BECAME_PRIMARY_SCN?from?v$database; STANDBY_BECAME_PRIMARY_SCN -------------------------- ???????????????????1194433 ??????????????????? 原主庫(轉換為備庫) SQL>?startup?mount;? SQL>?flashback?database?to?scn?1194433; Flashback?complete. SQL>?alter?database?convert?to?physical?standby; Database?altered. SQL>?shutdown?immediate; SQL>?startup?mount; SQL>?select?open_mode,?database_role?from?v$database;? OPEN_MODE????????????DATABASE_ROLE --------------------?---------------- MOUNTED??????????????PHYSICAL?STANDBY SQL>?alter?database?recover?managed?standby?database?using?current?logfile?disconnect?from?session;? Database?altered. SQL>?alter?database?recover?managed?standby?database?cancel; SQL>?alter?database?open;? SQL>?alter?database?recover?managed?standby?database?using?current?logfile?disconnect?from?session;? SQL>?select?open_mode,?database_role?from?v$database;? OPEN_MODE????????????DATABASE_ROLE --------------------?---------------- READ?ONLY?WITH?APPLY?PHYSICAL?STANDBY
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。