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

 

 

[[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中添加如下内容:

#add for primary dg

*.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

*.standby_file_management=‘auto‘

*.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:      251097186

Email:    [email protected]

Blog:     http://blog.csdn.net/tianlesoftware

Weibo:    http://weibo.com/tianlesoftware

Twitter:  http://twitter.com/tianlesoftware

Facebook: http://www.facebook.com/tianlesoftware

Linkedin: http://cn.linkedin.com/in/tianlesoftware

Dave 的QQ群:

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

注意:加群必须注明表空间和数据文件关系 | 不要重复加群

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

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

时间: 2024-10-29 00:18:27

Oracle 12c Data Guard 搭建手册的相关文章

Oracle12c Data Guard搭建手册

Oracle12c Data Guard搭建手册 注:本文来源: 红黑联盟 < Oracle12c Data Guard搭建手册 > Oracle 12c 的DataGuard 是在CDB 级别进行的,所以我们的配置都是从CDB角度出发. 测试里主备库的数据库CDB名称相同. 1 环境说明 1 OS Version: 2 3 [[email protected] etc]# cat /etc/oracle-release 4 5 Oracle Linux Server release 6.3

Oracle 12c Data Guard 纯小白部署手册

子公司需要搭建数据仓库,并且新建ADG作为主从,硬件设备Dell R730机器:192.168.1.11 dwjrdb --主库 192.168.1.12 dwjrstdyd --备库--数据库软件:linuxx64_12201_database.zip--数据库补丁包:p27105253_122010_Linux-x86-64.zip--Opatch升级包:p6880880_122010_Linux-x86-64.zip--目录规划为/u01存放归档日志,数据文件等,目录6.6TB空间 一.数

Oracle RAC + Data Guard 环境搭建

国庆之前就准备做这个实验了. 后来时间不够,就没搞了. 6天的长假一放,都散漫的不成样子了.懒散了很多. 今天7号. 上班也没啥精神,但是该做的实验还得继续. Oracle 高可用性的三个主要体现是: RAC, Data Guard 和 Stream.  所以熟练掌握这些技术就是评价DBA的标准一个. RAC + Data Guard 主要用在灾备或者报表服务器上. 比如用RAC+ 逻辑standby 做报表,从而减轻RAC 系统的压力. 关于Data Guard 的一些原理知识可以参考: Or

Oracle11g Active Data Guard搭建、管理

说明:參考网络众多人的笔记及思路,加上自己亲身实践之后的整理笔记.仅供參考. Data Guard与RAC不同的是.在普通情况下.Standby仅仅有一个节点处于活动状态,全部的应用都连接到主server. 仅仅有当server发生问题时,才考虑切换到备用server. 在Oracle 11g曾经版本号中的的Data Guard物理备用数据库.能够以仅仅读的方式打开数据库.但此时MediaRecovery利用日志进行数据同步的过程就停止了,假设物理备用数据库处于恢复的过程中数据库就不能打开查询.

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

缘起 最近做了10g和11g的物理备库配置实验,发现 Data Guard 其实很容易,但是缺少好文档.我是参考官方文档做的实验,觉得它写的不是很清楚的. Google 出来两个pdf文档,读了觉得比官方文档强很多.翻译下,也许会对某些朋友有用.翻译的同时我也好更熟悉下这两个文档.好久没翻译过英文了,可以顺便练练手. 原文档下载地址(墙外): Configure Dataguard 11gR2 Physical Standby Part 1 Configure Dataguard 11gR2 P

Oracle 11g Data Guard 使用duplicate from active database 创建 standby database

用这种方式来搭建DG ,主库的停机时间很少,只需要重启一下,使参数生效.也可以用这种方法进行DB迁移.DG搭建好,然后把备库激活就可以了. 这样整个迁移中宕机时间也比较短. Oracle 11g的pyhsical standby 支持open read only 下的apply和Real-time query. 因此就有了physical standby 稳定和logical standby 的报表查询功能. Oracle: 11.2.0.1 OS: redhat 5.5 Primary IP:

Oracle 12C Data Gurad RAC TO RAC

Oracle 12C RAC TO RAC Data Guard on RHEL7 0.环境说明   primary db physical standby 操作系统 rhel7 x86_64 rhel7 x86_64 数据库版本 12.2.0.1 12.2.0.1 IP 10.150.10.134/136 10.150.10.139/141 主机名称 vm-oradb1-N1/N2 vm-oradb2-N1/N2 数据库名称 albin albin db_unique_name albin a

ORACLE 11G Data Guard 角色转换

1,ORACLE Dataguard角色切换DataGuard已经是现今标准的主流容灾方案,由于日志传递对于网络适应程度强,且可以采用同步实时的传递方式和异步延迟的传递方式,甚至可以成为远程的异地容灾方案.不管用于何种用途,DG都免不了要进行角色转换,即将standby 数据库切换为primary数据库,角色转换分为:switchover和failover两种 2,两种方式的异同1),switchover是primary库转换成standby库.standby库转换成primary库2),fai

linux 6.4 平台下 Oracle 12c 单实例 安装手册

一.准备工作 1.1 安装需要的RPM 包 binutils-2.20.51.0.2-5.11.el6 (x86_64) glibc-2.12-1.7.el6 (x86_64) libgcc-4.4.4-13.el6 (x86_64) libstdc++-4.4.4-13.el6 (x86_64) libaio-0.3.107-10.el6 (x86_64) libXext-1.1 (x86_64) libXtst-1.0.99.2 (x86_64) libX11-1.3 (x86_64) li