大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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