1. 程式人生 > >Oracle 12c Data Guard 搭建手冊

Oracle 12c Data Guard 搭建手冊

  注:本文謝絕轉載!

Oracle 12c 的DataGuard 是在CDB 級別進行的,所以我們的配置都是從CDB角度出發。

測試裡主備庫的資料庫CDB名稱相同。

1  環境說明

OS Version

[[email protected] etc]# cat /etc/oracle-release

Oracle Linux Server release 6.3

[[email protected] etc]# uname -r

2.6.39-200.29.3.el6uek.x86_64

DB Version:

SQL> select * from v$version;

BANNER                                           CON_ID

------------------------------------------------------------------------------------------

Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0 - 64bit Production          0

PL/SQL Release 12.1.0.1.0 - Production                            0

CORE    12.1.0.1.0  Production                                0

TNS for Linux: Version 12.1.0.1.0 -Production                        0

NLSRTL Version 12.1.0.1.0 - Production                            0

SQL> show pdbs

   CON_ID CON_NAME           OPEN MODE RESTRICTED

---------- ---------------------------------------- ----------

     2 PDB$SEED           READ ONLY NO

     3 PCNDBA             READ WRITE NO

SQL>

例項名:

Database

DB_UNIQUE_NAME

Oracle Net Service Name

Primary

PCNDBA_P

PCNDBA_P

Physical standby

PCNDBA_S

PCNDBA_S

IP 地址:

[[email protected] network-scripts]# cat /etc/hosts

127.0.0.1 localhost dave

192.168.56.3 dg1

192.168.56.4 dg2

[[email protected] network-scripts]#

這裡用主庫上的PDB:PCNDBA 做我們的主庫。

2  主庫啟動FORCE LOGGING

SQL> select name,open_mode from v$pdbs;

NAME                   OPEN_MODE

------------------------------ ----------

PDB$SEED               READ ONLY

PCNDBA                 READ WRITE

SQL> alter database force logging;

Database altered.

SQL> select force_logging fromv$database;

FORCE_LOGGING

---------------------------------------

YES

3  啟動歸檔模式

SQL> show con_name

CON_NAME

------------------------------

CDB$ROOT

SQL> archive log list;

Database log mode          No Archive Mode

Automatic archival         Disabled

Archive destination        USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     14

Current log sequence           16

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 1620115456 bytes

Fixed Size          2288920 bytes

Variable Size       1040188136 bytes

Database Buffers      570425344 bytes

Redo Buffers            7213056 bytes

Database mounted.

SQL> alter database archivelog;

Database altered.

SQL>

這裡歸檔直接放在FRA裡了:

SQL> show  parameter recovery

NAME                     TYPE    VALUE

------------------------------------ -----------------------------------------

db_recovery_file_dest            string  /home/ora12c/app/oracle/fast_recovery_area

db_recovery_file_dest_size       big integer 4800M

recovery_parallelism             integer 0

SQL> alter system setdb_recovery_file_dest_size=10G;

System altered.

SQL> show  parameter recovery

NAME                     TYPE   VALUE

----------------------------------------------- ------------------------------

db_recovery_file_dest           string /home/ora12c/app/oracle/fast_recovery_area

db_recovery_file_dest_size       biginteger 10G

recovery_parallelism             integer    0

SQL>

SQL> alter database open;

Database altered.

SQL> select name,open_mode from v$pdbs;

NAME                   OPEN_MODE

------------------------------ ----------

PDB$SEED               READ ONLY

PCNDBA                 MOUNTED

SQL> alter pluggable database pcndbaopen;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                   OPEN_MODE

------------------------------ ----------

PDB$SEED               READ ONLY

PCNDBA                 READ WRITE

4  在主庫新增 standby redo logfile

在Oracle 12c的架構裡,online redo log 和控制檔案是儲存在CDB中的,PDB中只有執行需要的資料檔案,所以我們這裡加standby redo log,也是在CDB中加。

檢視 Primary 庫的 REDO 相關資訊:

SQL> show con_name

CON_NAME

------------------------------

CDB$ROOT

SQL> select  group#, members,  bytes  from v$log;

   GROUP#    MEMBERS     BYTES

---------- ---------- ----------

     1      2   52428800

     2      2   52428800

     3      2   52428800

SQL> select  member from  v$logfile;

MEMBER

-----------------------------------------------------------------------------------------

/home/ora12c/app/oracle/oradata/CNDBA/onlinelog/o1_mf_3_9y3rrb3v_.log

/home/ora12c/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_3_9y3rrb9n_.log

/home/ora12c/app/oracle/oradata/CNDBA/onlinelog/o1_mf_2_9y3rr54v_.log

/home/ora12c/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_2_9y3rr5b2_.log

/home/ora12c/app/oracle/oradata/CNDBA/onlinelog/o1_mf_1_9y3rqznr_.log

/home/ora12c/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_1_9y3rr09s_.log

新增 4(3+1)個standby  logfile:

SQL> alter  database add  standby  logfile '/home/ora12c/app/oracle/oradata/CNDBA/onlinelog/stdredo01.log'  size 50M;

Database altered.

SQL> alter  database add  standby  logfile '/home/ora12c/app/oracle/oradata/CNDBA/onlinelog/stdredo02.log'  size 50M;

Database altered.

SQL> alter  database add  standby  logfile '/home/ora12c/app/oracle/oradata/CNDBA/onlinelog/stdredo03.log'  size 50M;

Database altered.

SQL> alter  database add  standby  logfile '/home/ora12c/app/oracle/oradata/CNDBA/onlinelog/stdredo04.log'  size 50M;

Database altered.

5  分別在主備庫配置監聽並啟動

--這裡直接使用netmgr工具生成:注意靜態監聽註冊中配置的pdb。

[[email protected] admin]$ cat listener.ora

# listener.ora Network Configuration File:/home/ora12c/app/oracle/product/12.1.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

 (SID_LIST =

   (SID_DESC =

     (GLOBAL_DBNAME = cndba)

     (ORACLE_HOME = /home/ora12c/app/oracle/product/12.1.0/db_1)

     (SID_NAME = cndba)

    )

  )

LISTENER =

 (DESCRIPTION_LIST =

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = TCP)(HOST = dave)(PORT = 1521))

    )

  )

ADR_BASE_LISTENER = /home/ora12c/app/oracle

[[email protected] admin]$ lsnrctl reload

LSNRCTL for Linux: Version 12.1.0.1.0 -Production on 06-AUG-2014 19:26:50

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

The command completed successfully

6  分別在主備庫配置tnsnames.ora

[o[email protected] admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /home/ora12c/app/oracle/product/12.1.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

CNDBA_S =

 (DESCRIPTION =

   (ADDRESS_LIST =

     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.4)(PORT = 1521))

    )

   (CONNECT_DATA =

     (SERVICE_NAME = cndba)

    )

  )

CNDBA_P =

 (DESCRIPTION =

   (ADDRESS_LIST =

     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.3)(PORT = 1521))

    )

   (CONNECT_DATA =

     (SERVICE_NAME = cndba)

    )

  )

[[email protected] admin]$ tnsping cndba_s

[[email protected] admin]$ tnsping cndba_p

7  在備庫建立必要的目錄

可以參考主庫的pfile中的路徑:

[[email protected] admin]$ mkdir -p /home/ora12c/app/oracle/fast_recovery_area

[[email protected] admin]$ mkdir -p/home/ora12c/app/oracle/oradata

[[email protected] admin]$ mkdir -p/home/ora12c/app/oracle/admin/cndba/adump

8  在主庫建立pfile 檔案並修改pfile 內容

SQL> create pfile from spfile;

File created.

在pfile中新增如下內容:

*.db_name='cndba'

*.db_unique_name='cndba_p'

*.log_archive_config='dg_config=(cndba_p,cndba_s)'

*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DESTvalid_for=(all_logfiles,all_roles) db_unique_name=cndba_p'

*.log_archive_dest_2='service=cndba_s valid_for=(online_logfiles,primary_role)  lgwr affirmsync db_unique_name=cndba_s'

*.log_archive_dest_state_1=enable

*.log_archive_dest_state_2=enable

*.fal_server='cndba_s'

如果主備庫CDB名稱不同,還需要加如下引數:

*.DB_FILE_NAME_CONVERT='cndba','dave'

*.LOG_FILE_NAME_CONVERT='cndba','dave'

用新引數重啟資料庫:

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> create spfile from pfile;

File created.

SQL> startup

ORACLE instance started.

Total System Global Area 1620115456 bytes

Fixed Size          2288920 bytes

Variable Size       1040188136 bytes

Database Buffers      570425344 bytes

Redo Buffers            7213056 bytes

Database mounted.

Database opened.

SQL>

9  將主庫的口令檔案copy到備庫

我這裡主備庫的CDB例項相同,如果不同,可以使用orapwd命令重建。

[[email protected] dbs]$ scp orapwcndba192.168.56.4:`pwd`

[email protected]'s password:

orapwcndba                             100% 7680     7.5KB/s  00:00   

[[email protected] dbs]$

10 將主庫的引數檔案copy到備庫並修改

[[email protected] dbs]$ scp initcndba.ora192.168.56.4:`pwd`

[email protected]'s password:

initcndba.ora                         100% 1593     1.6KB/s  00:00   

[[email protected] dbs]$

修改如下內容,在重新生成spfile:

#add for standby dg

*.db_unique_name='cndba_s'

*.log_archive_config='dg_config=(cndba_p,cndba_s)'

*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DESTvalid_for=(all_logfiles,all_roles) db_unique_name=cndba_s'

*.log_archive_dest_2='service=cndba_pvalid_for=(online_logfiles,primary_role) lgwr affirm sync db_unique_name=cndba_p'

*.log_archive_dest_state_1=enable

*.log_archive_dest_state_2=enable

*.standby_file_management='auto'

*.fal_server='cndba_p'

注意修改控制檔案的路徑,也使用新路徑。

SQL> create spfile from pfile;

File created.

11 用spfile 將備庫啟動到nomount 狀態

SQL> startup nomount

ORACLE instance started.

Total System Global Area 1620115456 bytes

Fixed Size          2288920 bytes

Variable Size       1040188136 bytes

Database Buffers      570425344 bytes

Redo Buffers            7213056 bytes

SQL>

12 開始進行Active duplicate

[[email protected] network-scripts]$ rman targetsys/[email protected]_p auxiliary sys/[email protected]_s;

Recovery Manager: Release 12.1.0.1.0 -Production on Wed Aug 6 20:41:02 2014

Copyright (c) 1982, 2013, Oracle and/or itsaffiliates.  All rights reserved.

connected to target database: CNDBA(DBID=119362621)

connected to auxiliary database: CNDBA (notmounted)

RMAN>duplicatetarget database for standby from active database nofilenamecheck dorecover;

[[email protected] network-scripts]$ rman targetsys/[email protected]_p auxiliary sys/[email protected]_s;

Recovery Manager: Release 12.1.0.1.0 -Production on Wed Aug 6 20:41:02 2014

Copyright (c) 1982, 2013, Oracle and/or itsaffiliates.  All rights reserved.

connected to target database: CNDBA(DBID=119362621)

connected to auxiliary database: CNDBA (notmounted)

RMAN> duplicate target database forstandby from active database nofilenamecheck dorecover;

Starting Duplicate Db at 06-AUG-14

using target database control file insteadof recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=21 devicetype=DISK

current log archived

contents of Memory Script:

{

  backup as copy reuse

  targetfile '/home/ora12c/app/oracle/product/12.1.0/db_1/dbs/orapwcndba' auxiliaryformat

 '/home/ora12c/app/oracle/product/12.1.0/db_1/dbs/orapwcndba'   ;

}

executing Memory Script

Starting backup at 06-AUG-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=48 device type=DISK

Finished backup at 06-AUG-14

contents of Memory Script:

{

  sql clone "alter system set control_files =

 ''/home/ora12c/app/oracle/oradata/CNDBA/controlfile/o1_mf_9y3rqtn9_.ctl'',''/home/ora12c/app/oracle/fast_recovery_area/CNDBA/controlfile/o1_mf_9y3rqvky_.ctl''comment=

 ''Set by RMAN'' scope=spfile";

  restore clone from service 'cndba_p' standby controlfile;

}

executing Memory Script

sql statement: alter system set  control_files =   ''/home/ora12c/app/oracle/oradata/CNDBA/controlfile/o1_mf_9y3rqtn9_.ctl'',''/home/ora12c/app/oracle/fast_recovery_area/CNDBA/controlfile/o1_mf_9y3rqvky_.ctl''comment= ''Set by RMAN'' scope=spfile

Starting restore at 06-AUG-14

using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: restoring controlfile

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:07

output file name=/home/ora12c/app/oracle/oradata/CNDBA/controlfile/o1_mf_9y3rqtn9_.ctl

output filename=/home/ora12c/app/oracle/fast_recovery_area/CNDBA/controlfile/o1_mf_9y3rqvky_.ctl

Finished restore at 06-AUG-14

contents of Memory Script:

{

  sql clone 'alter database mount standby database';

}

executing Memory Script

sql statement: alter database mount standbydatabase

contents of Memory Script:

{

  set newname for clone tempfile  1to new;

  set newname for clone tempfile  2to new;

  set newname for clone tempfile  3to new;

   switchclone tempfile all;

  set newname for clone datafile  1to new;

  set newname for clone datafile  3to new;

  set newname for clone datafile  4to new;

  set newname for clone datafile  5to new;

  set newname for clone datafile  6to new;

  set newname for clone datafile  7to new;

  set newname for clone datafile  8to new;

  set newname for clone datafile  9to new;

  set newname for clone datafile  10to new;

  restore

  from service  'cndba_p'   clone database

   ;

  sql 'alter system archive log current';

}

executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_temp_%u_.tmp in controlfile

renamed tempfile 2 to/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_temp_%u_.tmp in controlfile

renamed tempfile 3 to/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_temp_%u_.tmp in controlfile

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 06-AUG-14

using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifyingdatafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00001 to /home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_system_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:01:37

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifyingdatafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00003 to /home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_sysaux_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:01:25

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifying datafile(s)to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00004 to/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_undotbs1_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:25

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifyingdatafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00005 to /home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_system_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:35

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifyingdatafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00006 to /home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_users_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:01

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifyingdatafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00007 to /home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_sysaux_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:01:15

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifyingdatafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00008 to /home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_system_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:35

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifyingdatafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00009 to /home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_sysaux_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:01:15

channel ORA_AUX_DISK_1: starting datafilebackup set restore

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: specifyingdatafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile00010 to /home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_users_%u_.dbf

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:03

Finished restore at 06-AUG-14

sql statement: alter system archive logcurrent

current log archived

contents of Memory Script:

{

  restore clone force from service 'cndba_p'

          archivelog from scn  1922781;

  switch clone datafile all;

}

executing Memory Script

Starting restore at 06-AUG-14

using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting archivedlog restore to default destination

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: restoring archivedlog

archived log thread=1 sequence=18

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:01

channel ORA_AUX_DISK_1: starting archivedlog restore to default destination

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: restoring archivedlog

archived log thread=1 sequence=19

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:02

channel ORA_AUX_DISK_1: starting archivedlog restore to default destination

channel ORA_AUX_DISK_1: using networkbackup set from service cndba_p

channel ORA_AUX_DISK_1: restoring archivedlog

archived log thread=1 sequence=20

channel ORA_AUX_DISK_1: restore complete,elapsed time: 00:00:01

Finished restore at 06-AUG-14

datafile 1 switched to datafile copy

input datafile copy RECID=12STAMP=854916586 filename=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_system_9y48opp7_.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=13STAMP=854916586 filename=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_sysaux_9y48rr3z_.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=14STAMP=854916586 file name=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_undotbs1_9y48vf5v_.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=15STAMP=854916586 filename=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_system_9y48w6bx_.dbf

datafile 6 switched to datafile copy

input datafile copy RECID=16STAMP=854916586 filename=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_users_9y48x8jb_.dbf

datafile 7 switched to datafile copy

input datafile copy RECID=17STAMP=854916586 file name=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_sysaux_9y48xb36_.dbf

datafile 8 switched to datafile copy

input datafile copy RECID=18STAMP=854916586 filename=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_system_9y48zp0f_.dbf

datafile 9 switched to datafile copy

input datafile copy RECID=19STAMP=854916586 filename=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_sysaux_9y490r5z_.dbf

datafile 10 switched to datafile copy

input datafile copy RECID=20STAMP=854916586 file name=/home/ora12c/app/oracle/oradata/CNDBA_S/datafile/o1_mf_users_9y493301_.dbf

contents of Memory Script:

{

  set until scn  1923489;

  recover

  standby

  clone database

   delete archivelog

   ;

}

executing Memory Script

executing command: SET until clause

Starting recover at 06-AUG-14

using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 18is already on disk as file/home/ora12c/app/oracle/fast_recovery_area/CNDBA_S/archivelog/2014_08_06/o1_mf_1_18_9y49378o_.arc

archived log for thread 1 with sequence 19is already on disk as file/home/ora12c/app/oracle/fast_recovery_area/CNDBA_S/archivelog/2014_08_06/o1_mf_1_19_9y49387d_.arc

archived log for thread 1 with sequence 20is already on disk as file/home/ora12c/app/oracle/fast_recovery_area/CNDBA_S/archivelog/2014_08_06/o1_mf_1_20_9y493976_.arc

archived log filename=/home/ora12c/app/oracle/fast_recovery_area/CNDBA_S/archivelog/2014_08_06/o1_mf_1_18_9y49378o_.arcthread=1 sequence=18

archived log filename=/home/ora12c/app/oracle/fast_recovery_area/CNDBA_S/archivelog/2014_08_06/o1_mf_1_19_9y49387d_.arcthread=1 sequence=19

archived log filename=/home/ora12c/app/oracle/fast_recovery_area/CNDBA_S/archivelog/2014_08_06/o1_mf_1_20_9y493976_.arcthread=1 sequence=20

media recovery complete, elapsed time:00:00:01

Finished recover at 06-AUG-14

Finished Duplicate Db at 06-AUG-14

RMAN>

13 開啟備庫並並啟動apply

duplicate 完成之後,備庫是mount的。

SQL> select open_mode from v$database;

OPEN_MODE

----------------------------------------

MOUNTED

SQL> show pdbs

   CON_ID CON_NAME           OPEN MODE RESTRICTED

---------- ---------------------------------------- ----------

     2 PDB$SEED           MOUNTED

     3 PCNDBA             MOUNTED

SQL> alter database open;

Database altered.

SQL> show pdbs

   CON_ID CON_NAME           OPEN MODE RESTRICTED

---------- ---------------------------------------- ----------

     2 PDB$SEED           READ ONLY NO

     3 PCNDBA             MOUNTED

SQL> alter pluggable database pcndbaopen;

Pluggable database altered.

SQL> show pdbs

   CON_ID CON_NAME           OPEN MODE RESTRICTED

---------- ---------------------------------------- ----------

     2 PDB$SEED           READ ONLY NO

     3 PCNDBA             READ ONLY NO

備庫是隻讀的。

--檢視主庫:

SQL> select log_mode,open_mode ,database_role from v$database;

LOG_MODE    OPEN_MODE        DATABASE_ROLE

------------ ------------------------------------

ARCHIVELOG  READ WRITE       PRIMARY

--備庫:

SQL> select log_mode,open_mode ,database_role from v$database;

LOG_MODE    OPEN_MODE        DATABASE_ROLE

------------ ------------------------------------

ARCHIVELOG  READ ONLY        PHYSICAL STANDBY

--啟動real-time apply

SQL> alter database recover managedstandby database using current logfile disconnect from session;

Database altered.

SQL> select open_mode from v$database;

OPEN_MODE

--------------------

READ ONLY WITH APPLY

14 驗證DG

--在主庫建立一個table

SQL> alter session set container=pcndba;

Session altered.

SQL> create table cndba as select * fromdba_users;

create table cndba as select * fromdba_users

*

ERROR at line 1:

ORA-01109: database not open

SQL> show pdbs  

    CON_ID CON_NAME           OPEN MODE  RESTRICTED

---------- ---------------------------------------- ----------

     3 PCNDBA             MOUNTED

SQL> alter database open;

Database altered.

SQL> create table cndba as select * fromdba_users;

Table created.

SQL> alter system switch logfile;

alter system switch logfile

*

ERROR at line 1:

ORA-65040: operation not allowed fromwithin a pluggable database

注意:這裡可以看到,對於12c的庫,日誌的切換隻能在CDB中進行,也就是我們前面講的,DG 是在CDB 級別進行的。

SQL> alter system switch logfile;

System altered.

備庫查詢:

SQL> select count(1) from cndba;

select count(1) from cndba

                     *

ERROR at line 1:

ORA-00942: table or view does not exist

提示表不存在,實際上,我們是在PDB裡建立的,切換到對應的PDB下,就可以查詢到了:

SQL> alter session container=pcndba;

alter session container=pcndba

              *

ERROR at line 1:

ORA-00922: missing or invalid option

SQL> alter session set container=pcndba;

Session altered.

SQL> select count(1) from cndba;

 COUNT(1)

----------

    36

--------------------------------------------------------------------------------------------

AboutDave:

QQ:492913789

Email:[email protected]

Dave 的QQ群:

--------------------------------------------------------------------------------------------

注意:加群必須註明表空間和資料檔案關係 | 不要重複加群

CNDBA_1: 104207940 (滿)    CNDBA_2: 62697716 (滿)   CNDBA_3: 283816689

CNDBA_4: 391125754   CNDBA_5: 62697850    CNDBA_6: 62697977   CNDBA_7: 142216823(滿)

相關推薦

Oracle 12c Data Guard 搭建手冊

  注:本文謝絕轉載! Oracle 12c 的DataGuard 是在CDB 級別進行的,所以我們的配置都是從CDB角度出發。 測試裡主備庫的資料庫CDB名稱相同。 1  環境說明 OS Version: [[email protected] etc]#

Oracle 12c Data Guard 純小白部署手冊

inpu rdbms work inux ORC opatch users library get 子公司需要搭建數據倉庫,並且新建ADG作為主從,硬件設備Dell R730機器;192.168.1.11 dwjrdb --主庫 192.1

Oracle RAC + Data Guard 環境搭建

引用:http://blog.csdn.net/xujinyang/article/details/6836780 國慶之前就準備做這個實驗了。 後來時間不夠,就沒搞了。 6天的長假一放,都散漫的不成樣子了。懶散了很多。 今天7號。 上班也沒啥精神,但是該做

ORACLE 12C R2 RAC搭建

目錄 1、ORACLE 12.2軟硬體要求 1.1 硬體最低配置要求 序號

Oracle 11g Data Guard引數詳解

注:本文譯自《Oracle Data Guard 11g Handbook》 Page 78 – Page 88 就Data Guard(後面都寫成DG)來說,我們只關注如下三種引數: 1.獨立於資料庫角色的引數 2.資料庫角色為primary時的引數 3.資料庫角色

Oracle 11g Data Guard 物理備庫快速配置指南(上)

緣起 最近做了10g和11g的物理備庫配置實驗,發現 Data Guard 其實很容易,但是缺少好文件。我是參考官方文件做的實驗,覺得它寫的不是很清楚的。 Google 出來兩個pdf文件,讀了覺得比官方文件強很多。翻譯下,也許會對某些朋友有用。翻譯的同時我也好更熟悉下這兩

Oracle 11g Data Guard 物理備庫快速配置指南(下)

第二部分 作者介紹 作者 Jed Walker 是科羅拉多 Centennial Comcast 媒體中心的資料操作經理(Manager of Databse Operation)。他從1997年開始做 Oracle 資料庫相關工作,是9i, 10g和11g的OCP。 簡介

Oracle 11g Data Guard之主備庫切換(switchover不使用DG Broker)

--目前主庫PROD3,備庫AUX --檢視主備庫日誌傳輸情況 [email protected]> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) --------------

Oracle 11g Data Guard 使用duplicate from active database 建立物理DG

概要介紹      直接把原資料庫進行復制,11g的RMANduplicate可以通過Active databaseduplicate和Backup-based duplicate兩種方法實現,這裡用Activedatabase duplicate這種方式來搭建DG,主庫的停機時間很少,只需要重啟一下

ORACLE 11G DATA GUARD配置之Dataguard基本原理

1、DATAGUARD原理 DATAGUARD是通過建立一個PRIMARY和STANDBY組來確立其參照關係。 STANDBY一旦建立,DATAGUARD就會通過將主資料庫(PRIMARY)的REDO傳遞給STANDBY資料庫,然後在STANDBY中應用RE

Oracle 11g Data Guard 之邏輯備庫角色轉換

   邏輯備庫不復制資料庫服務,在進行switchover或者failover時,連線主庫服務的中間層將不能連線(因為服務的建立沒有被複制),或者連線不正確的版本(因為服務屬性的修改沒有被複制)。    Oracle叢集不復制管理邏輯備庫的服務,必須手動對主庫與備庫進行同步

Oracle 11g Data Guard暫停物理備庫的日誌傳輸(log_archive_dest_state_n的defer引數)

本文轉載自   http://blog.itpub.net/26506993/viewspace-1850590/ 在實際生產系統中,通常有這樣的場景,例如在系統維護日,對主庫進行大量的業務更新,會有大量的DML操作; 為了避免主庫中的業務更新對備庫造成影響,可以暫停主

Oracle 11g Data Guard中實現Connect Time Failover & Transparent Application Failover(TAF)

背景介紹:在switchover或failover時主庫進行切換後,客戶端獲得自己重連主庫的能力。 環境修改: 1.修改$ORACLE_HOME/network/admin/tnsnames.ora PRIOCM= (DESCRIPTION = (ADDR

Oracle數據庫11g 中Data Guard物理備用數據庫搭建與配置

Oracle Data Guard Oracle主備 Oracle Data Guard是由Oracle公司提供的一套高可用性數據庫解決方案。Data Guard可以確保企業數據的高可用性,並實現數據保護和災難恢復。Data Guard提供了一套綜合創建、維護、管理和監視一個或多個備用數據庫的

淺析Oracle 12cData Guard新特性

  淺析Oracle 12c中Data Guard新特性   寫在前面 無論是做Oracle運維的小夥伴還是老夥伴,想必對Oracle資料庫的資料級災備核心技術—Data Guard是再熟悉不過了!這項從Oracle 8i就開始大面積普及的資料複製與災備技術以其久經考

Oracle data guard 10g 搭建

ora-01078 esc product dom rail des force swa 應用 Oracle data guard 10g 搭建 1系統常規參數檢查 硬盤 [root@localhost ~]# df -h 內核 [root@localhost ~]# u

oracleOracle Data Guard 環境搭建

Oracle Data Guard 環境搭建 二、 配置主庫 1、 強制寫日誌  2、 設定資料庫為歸檔模式  3、 在主庫新增備庫日誌檔案  4、 檢視備庫日誌檔案  5、 配置靜態

oracle 搭建實時同步data guard的最高可用-切換主備

搭建實時同步data guard的最高可用-切換主備 首先保證主庫在歸檔模式下:錯過N次了 準備二臺機器(hostname gw hosts ech0)host-only [[email protected] ~]# ifconfig eth0      Lin

用Broker搭建Oracle Data Guard的必須注意知識點

最近在用Broker 配置和管理Data Guard(Oracle version : 10.2.0.1.0),以前的資料庫都基本不設定db_domain的,當使用database link的時候,啟用了global_names=true,也設定了db_domain,所以以

Oracle 12C 新特性之擴展數據類型(extended data type)

stand 特性 standard ava dbm har sco stat rac Oracle 12C 新特性-擴展數據類型,在12c中,與早期版本相比,諸如VARCHAR2, NAVARCHAR2以及 RAW這些數據類型的大小會從4K以及2K字節擴展至32K字節。只要