[Oracle][DATAGUARD] PHYSICAL STANDBY环境里,使用CATALOG管理Primary和Standby


1.先使用控制文件构筑好PHYSICAL STANDBY环境(Primary:Single 11.2.0.4,Standby Single 11.2.0.4)

2.构筑好Catalog用的服务器(Catalog:Single 11.2.0.4)

3.构建Catalog


|SQL> startup mount ------------------Mount启动
|ORACLEインスタンスが起動しました。

|Total System Global Area  839282688 bytes
|Fixed Size                  2257880 bytes
|Variable Size             541068328 bytes
|Database Buffers          289406976 bytes
|Redo Buffers                6549504 bytes
|データベースがマウントされました。
|SQL> alter database archivelog; ------------------变成archivelog模式

|データベースが変更されました。

|SQL> archive log list ------------------变换成功
|データベース・ログ・モード     アーカイブ・モード
|自動アーカイブ                 有効
|アーカイブ先                    USE_DB_RECOVERY_FILE_DEST
|最も古いオンライン・ログ順序   5
|アーカイブする次のログ順序    7
|現行のログ順序               7
|SQL> alter database open;

|データベースが変更されました。

|SQL> CREATE TABLESPACE tools DATAFILE SIZE 1000M SEGMENT SPACE MANAGEMENT AUTO; ------------------创建表领域

|表領域が作成されました。

|SQL> CREATE USER rman IDENTIFIED BY rman
|  TEMPORARY TABLESPACE temp
|  DEFAULT TABLESPACE tools
|  QUOTA UNLIMITED ON tools;  2    3    4 ------------------创建需要用的用户

|ユーザーが作成されました。

|SQL> GRANT RECOVERY_CATALOG_OWNER TO rman; ------------------赋予RECOVERY_CATALOG_OWNER权限

|権限付与が成功しました。

|SQL> grant dba to rman; ------------------保险起见,还是给予了dba权限

|権限付与が成功しました。

|SQL> exit
|Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
|With the Partitioning, OLAP, Data Mining and Real Application Testing optionsとの接続が切断されました。
|[oracle@db11204 ~]$ export NLS_LANG='American'
|[oracle@db11204 ~]$ export NLS_DATE_FORMAT=YYYY-MM-DD_HH24:MI:SS
|[oracle@db11204 ~]$ rman catalog rman/rman@ora11204 ------------------连接

|Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 12 17:12:36 2017

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

|connected to recovery catalog database

|RMAN> drop catalog; ------------------如果有,就Drop,当然没有也没啥

|recovery catalog owner is RMAN
|enter DROP CATALOG command again to confirm catalog removal

|RMAN> create catalog tablespace tools; ------------------建造catalog

|recovery catalog created

4.在Primary侧,执行REGISTER DATABASE;

|[oracle@primary ~]$ export NLS_LANG='American'
|[oracle@primary ~]$ export NLS_DATE_FORMAT=YYYY-MM-DD_HH24:MI:SS
|[oracle@primary ~]$ rman target / catalog rman/rman@db11204

|Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 12 17:13:37 2017

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

|connected to target database: ORCL (DBID=1460344535)
|connected to recovery catalog database

|RMAN> REGISTER DATABASE; ------------------执行REGISTER DATABASE;

|database registered in recovery catalog
|starting full resync of recovery catalog
|full resync complete

5.在Standby侧,尝试连接catalog

|[oracle@standby ~]$ export NLS_LANG='American'
|[oracle@standby ~]$ export NLS_DATE_FORMAT=YYYY-MM-DD_HH24:MI:SS
|[oracle@standby ~]$ env | grep ORA
|ORACLE_SID=orcls
|ORACLE_BASE=/u01/app/oracle
|ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
|[oracle@standby ~]$ rman target / catalog rman/rman@db11204 ------------------可以连接

6.在Catalog侧,确认是否成功

|RMAN> LIST DB_UNIQUE_NAME ALL;

|[oracle@db11204 ~]$ rman catalog rman/rman@ora11204

|Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 12 17:12:36 2017

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

|connected to recovery catalog database

|RMAN> list db_unique_name all;
|List of Databases
|DB Key  DB Name  DB ID            Database Role    Db_unique_name
|------- ------- ----------------- ---------------  ------------------
|1       ORCL     1460344535       PRIMARY          ORCL ------------------成功
|1       ORCL     1460344535       STANDBY          ORCLS ------------------成功

|RMAN> upgrade catalog; ------------------保险起见,执行两次upgrade catalog;

|recovery catalog owner is RMAN
|enter UPGRADE CATALOG command again to confirm catalog upgrade

|RMAN> upgrade catalog; ------------------保险起见,执行两次upgrade catalog;

|recovery catalog upgraded to version 11.02.00.04
|DBMS_RCVMAN package upgraded to version 11.02.00.04
|DBMS_RCVCAT package upgraded to version 11.02.00.04

|RMAN> list db_unique_name all;


|List of Databases
|DB Key  DB Name  DB ID            Database Role    Db_unique_name
|------- ------- ----------------- ---------------  ------------------
|1       ORCL     1460344535       PRIMARY          ORCL ------------------成功
|1       ORCL     1460344535       STANDBY          ORCLS ------------------成功

7.在Primary侧动作确认

|[oracle@primary ~]$ rman target / catalog rman/rman@db11204

|Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 12 17:15:52 2017

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

|connected to target database: ORCL (DBID=1460344535)
|connected to recovery catalog database

|RMAN>

|RMAN>

|RMAN> list backupset verbose; ------------------没问题


|List of Backup Sets
|===================


|BS Key  Size       Device Type Elapsed Time Completion Time
|------- ---------- ----------- ------------ -------------------
|129     6.24M      DISK        00:00:02     2017-01-09_12:47:19
|        BP Key: 133   Status: AVAILABLE  Compressed: YES  Tag: TAG20170109T124717
|        Piece Name: /tmp/standby_archive_01rpjdel_1_1

|  List of Archived Logs in backup set 129
|  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
|  ---- ------- ---------- ------------------- ---------- ---------
|  1    53      697572     2017-01-06_14:20:24 704298     2017-01-09_12:47:10

|BS Key  Type LV Size       Device Type Elapsed Time Completion Time
|------- ---- -- ---------- ----------- ------------ -------------------
|130     Full    353.30M    DISK        00:04:11     2017-01-09_12:51:32
|        BP Key: 134   Status: AVAILABLE  Compressed: YES  Tag: TAG20170109T124721
|        Piece Name: /tmp/standby_database_02rpjdep_1_1
|  List of Datafiles in backup set 130
|  File LV Type Ckp SCN    Ckp Time            Name
|  ---- -- ---- ---------- ------------------- ----
|  1       Full 704308     2017-01-09_12:47:21 /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_d6y7bpkd_.dbf

8.在Standby侧动作确认

|[oracle@standby ~]$ rman target / catalog rman/rman@db11204

|Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 12 17:24:42 2017

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

|connected to target database: ORCL (DBID=1460344535, not open)
|connected to recovery catalog database

|RMAN> list backupset verbose;  ------------------出错了(我了个去)

|RMAN-00571: ===========================================================
|RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
|RMAN-00571: ===========================================================
|RMAN-03002: failure of list command at 10/12/2017 17:24:46
|RMAN-03014: implicit resync of recovery catalog failed
|RMAN-03009: failure of partial resync command on default channel at 10/12/2017 17:24:46
|RMAN-20999: internal error

|RMAN> exit ------------------先出去


|Recovery Manager complete.
|[oracle@standby ~]$ sqlplus / as sysdba

|SQL*Plus: Release 11.2.0.4.0 Production on Thu Oct 12 17:28:26 2017

|Copyright (c) 1982, 2013, Oracle.  All rights reserved.


|Connected to:
|Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
|With the Partitioning, OLAP, Data Mining and Real Application Testing options

|SQL> recover managed standby database using current logfile disconnect; ------------------打开MRP,进行REDO应用
|Media recovery complete.
|set line 200
|col name for a100
|SQL>
|SQL> select sequence#, name, applied from v$archived_log where resetlogs_change# = (select resetlogs_change# from v$database) order by sequence#;

| SEQUENCE# NAME                                                                                                 APPLIED
|---------- ---------------------------------------------------------------------------------------------------- ---------
|        55 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_01_09/o1_mf_1_55_d768d472_.arc              YES
|        56 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_01_09/o1_mf_1_56_d768dvdr_.arc              YES
|        57 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_17/o1_mf_1_57_dsb0ljby_.arc              YES
|        58 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_17/o1_mf_1_58_dsb0lgkq_.arc              YES
|        59 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_17/o1_mf_1_59_dsb0lgk1_.arc              YES
|        60 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_17/o1_mf_1_60_dsb0ljc1_.arc              YES
|        61 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_17/o1_mf_1_61_dsb0mg3z_.arc              YES
|        62 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_62_dssw8dyj_.arc              YES
|        63 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_63_dssw81co_.arc              YES
|        64 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_64_dssw875p_.arc              YES
|        65 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_65_dsswpmjq_.arc              YES

| SEQUENCE# NAME                                                                                                 APPLIED
|---------- ---------------------------------------------------------------------------------------------------- ---------
|        66 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_66_dsswsswg_.arc              YES
|        67 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_67_dsswx135_.arc              YES
|        68 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_68_dsswytvj_.arc              YES
|        69 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_69_dssx0tjp_.arc              YES
|        70 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_70_dssx2d95_.arc              YES
|        71 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_71_dssxyzmk_.arc              YES
|        72 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_72_dsszd9j0_.arc              YES
|        73 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_73_dsszfm4y_.arc              YES
|        74 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_74_dsszh6os_.arc              YES
|        75 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_08_23/o1_mf_1_75_dst02m6p_.arc              YES
|        76 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_09_25/o1_mf_1_76_dwjvjb0l_.arc              YES

| SEQUENCE# NAME                                                                                                 APPLIED
|---------- ---------------------------------------------------------------------------------------------------- ---------
|        77 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_09_25/o1_mf_1_77_dwjvjf1t_.arc              YES
|        78 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_09_25/o1_mf_1_78_dwjvyj29_.arc              YES
|        79 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_10_12/o1_mf_1_79_dxy69k4v_.arc              YES
|        80 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_10_12/o1_mf_1_80_dxy691hf_.arc              YES
|        81 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_10_12/o1_mf_1_81_dxy691h9_.arc              YES
|        82 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_10_12/o1_mf_1_82_dxy6984z_.arc              YES
|        83 /u01/app/oracle/fast_recovery_area/ORCLS/archivelog/2017_10_12/o1_mf_1_83_dxy9jgry_.arc              IN-MEMORY ------------------成功了

|29 rows selected.

|SQL> exit
|Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
|With the Partitioning, OLAP, Data Mining and Real Application Testing options
|[oracle@standby ~]$ rman target / catalog rman/rman@db11204 ------------------再一次连接

|Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 12 17:29:14 2017

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

|connected to target database: ORCL (DBID=1460344535, not open)
|connected to recovery catalog database

|RMAN> list backupset verbose; ------------------好用了


|List of Backup Sets
|===================


|BS Key  Type LV Size       Device Type Elapsed Time Completion Time
|------- ---- -- ---------- ----------- ------------ -------------------
|269     Full    353.30M    DISK        00:00:00     2017-01-09_12:47:21
|        BP Key: 273   Status: AVAILABLE  Compressed: YES  Tag: TAG20170109T124721
|        Piece Name: /tmp/standby_database_02rpjdep_1_1
|  List of Datafiles in backup set 269
|  File LV Type Ckp SCN    Ckp Time            Name
|  ---- -- ---- ---------- ------------------- ----
|  1       Full 704308     2017-01-09_12:47:21 /u01/app/oracle/oradata/ORCLS/datafile/o1_mf_system_d765zflg_.dbf
|  2       Full 704308     2017-01-09_12:47:21 /u01/app/oracle/oradata/ORCLS/datafile/o1_mf_sysaux_d765zflp_.dbf
|  3       Full 704308     2017-01-09_12:47:21 /u01/app/oracle/oradata/ORCLS/datafile/o1_mf_undotbs1_d765zflw_.dbf
|  4       Full 704308     2017-01-09_12:47:21 /u01/app/oracle/oradata/ORCLS/datafile/o1_mf_users_d765zfm5_.dbf