Data Guard 之RMAN备份在线搭建物理standby

此种方式搭建DG,不需要停止主库,极大提高了生产库的可用性。

一、大致步骤

通过RMAN备份创建standby数据库大致分为这几个步骤:

1)设置主数据库为force loggin模式

2)设置主数据库为archived log模式

3)配置好主备库的参数文件

4)两边的密码文件保持一致

5)配置监听

6)用参数文件启动standbynomount状态

7)通过rman对主库做完全备份

8)通过rmanstandby创建控制文件

9)通过rman dumplicate命令创建备库

10)创建完成后,自动将standby 数据库启动到mount状态,并且不会自动启动redo apply

二、实施创建操作

环境:primary数据库名PROD1standby数据库名PROD2

db_unique_name=PROD1

Data Guard 环境中Standby Database 主要有2种角色,physical standby logic standby,这里讲述 physical standby的搭建过程。

Data Guard提供了3种级别的保护模式,无论搭建physical standby还是logic standby,都需要考虑使用什么样的保护模式来保护数据,定义何种保护模式主要就是设置redo的传输方式。

1)最大保护LGWR SYNC

2)最高可用性LGWR SYNC

3)最高性能 LGWR ASYNC ARCH

软件环境:

虚拟机:VMware-Workstation-Full-10

系统: rhel-server-5.4-i386

Oraclelinux_11gR2_database

ip地址:

primary192.168.31.2

standby192.168.31.3

host文件

192.168.31.2   oracle1.example.com

192.168.31.3  oracle2.example.com

实例名

primaryPROD1

standbyPROD2

一,Data Guard搭建步骤

1.vmware上安装2linux虚拟机,按照上面要求设置好IP,然后在2linux上分别安装oracle软件(linux_11gR2_database),192.168.31.2创建好数据库实例名为PROD1,先保证实例PROD1能够正常运行,并且两台linux系统可以互相ping通。

2.在主数据库上激活FORCE LOGGING模式,想必大家知道有一些DDL 语句可以通过指定NOLOGGING 子句的方式避免写redo log(目的是提高速度,某些时候确实有效),指定数据库为FORCE LOGGING 模式后,数据库将会记录除临时表空间或临时回滚段外所有的操作而忽略类似NOLOGGING之类的指定参数。如果在执行force logging时有nologging 之类的语句在执行,则force logging 会等待直到这类语句全部执行。FORCE LOGGING 是做为固定参数保存在控制文件中,因此其不受重启之类操作的影响(只执行一次即可),如果想取消,可以通过alter database no force logging 语句关闭强制记录。

SQL> alter database force logging;

Database altered.

3.配置主数据库为归档模式(如果已经归档模式这一步不需要)

SQL> archive log list;

Database log mode No Archive Mode //非归档

Automatic archival Disabled

Archive destination USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence 2

Current log sequence 4

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 318046208 bytes

Fixed Size 1299652 bytes

Variable Size 239078204 bytes

Database Buffers 71303168 bytes

Redo Buffers 6365184 bytes

Database mounted.

SQL> alter database archivelog; //激活归档

Database altered.

SQL> alter database open;

Database altered.

5. 在主数据库生成一个pfile文件,用于配置DG的相关属性(也可以直接通过alter system 语句修改)

SQL> create pfile from spfile;

File created.

主库

alter system set LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/files/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PROD1′;

alter system set LOG_ARCHIVE_DEST_2=’SERVICE=PROD2 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD2′;

alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;

alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE;

#alter system set LOG_ARCHIVE_START=true scope =spfile;

alter system set LOG_ARCHIVE_FORMAT=’log%t_%s_%r.arc’ scope=spfile;

alter system set FAL_SERVER=PROD2;

alter system set FAL_CLIENT=PROD1;

alter system set DB_UNIQUE_NAME=PROD1 scope=spfile;

alter system set DB_FILE_NAME_CONVERT=’/u01/app/oracle/oradata/PROD2/’,'/u01/app/oracle/oradata/PROD1/’ scope=spfile;

alter system set LOG_FILE_NAME_CONVERT=’/u01/app/oracle/oradata/PROD2/’,'/u01/app/oracle/oradata/PROD1/’ scope=spfile;

备库

alter system set LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/files VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PROD2′;

alter system set LOG_ARCHIVE_DEST_2=’SERVICE=PROD1 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD1′;

alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;

alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE;

#alter system set LOG_ARCHIVE_START=true scope =spfile;

alter system set LOG_ARCHIVE_FORMAT=’log%t_%s_%r.arc’ scope=spfile;

alter system set FAL_SERVER=PROD1;

alter system set FAL_CLIENT=PROD2;

alter system set DB_UNIQUE_NAME=PROD2 scope=spfile;

alter system set DB_FILE_NAME_CONVERT=’/u01/app/oracle/oradata/PROD1/’,'/u01/app/oracle/oradata/PROD2/’ scope=spfile;

alter system set LOG_FILE_NAME_CONVERT=’/u01/app/oracle/oradata/PROD1/’,'/u01/app/oracle/oradata/PROD2/’ scope=spfile;

alter system set service_names=PROD1;

1)在备库上使用spfile启动到nomount状态。

SQL> startup nomount;

ORACLE instance started.

Total System Global Area 318046208 bytes

Fixed Size 1299652 bytes

Variable Size 297798460 bytes

Database Buffers 12582912 bytes

Redo Buffers 6365184 bytes

SQL>

2)将主库用rman连接 备份主库

RMAN> backup database include current controlfile for standby plus archivelog;

//注意 备份数据库的同时创建了standby控制文件,并且包含了归档日志。 也可以分开来做例如

backup database 

copy current controlfile for standby to ‘/tmp/st.ctl’

RMAN> backup database include current controlfile for standby plus archivelog;

Starting backup at 27-MAY-15

current log archived

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=32 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=24 RECID=2 STAMP=880037637

input archived log thread=1 sequence=25 RECID=3 STAMP=880037748

input archived log thread=1 sequence=26 RECID=4 STAMP=880795744

input archived log thread=1 sequence=27 RECID=5 STAMP=880798248

input archived log thread=1 sequence=28 RECID=6 STAMP=880816639

channel ORA_DISK_1: starting piece 1 at 27-MAY-15

channel ORA_DISK_1: finished piece 1 at 27-MAY-15

piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_annnn_TAG20150527T151720_bpbvw0yg_.bkp tag=TAG20150527T151720 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04

Finished backup at 27-MAY-15

Starting backup at 27-MAY-15

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf

input datafile file number=00010 name=/u02/oradata/prod1/test_tbs.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/PROD1/example01.dbf

channel ORA_DISK_1: starting piece 1 at 27-MAY-15

channel ORA_DISK_1: finished piece 1 at 27-MAY-15

piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvw50n_.bkp tag=TAG20150527T151724 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf

channel ORA_DISK_1: starting piece 1 at 27-MAY-15

channel ORA_DISK_1: finished piece 1 at 27-MAY-15

piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvx99p_.bkp tag=TAG20150527T151724 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00009 name=/u01/app/oracle/oradata/PROD1/EXAMPLE.dbf

input datafile file number=00006 name=/u01/app/oracle/oradata/PROD1/indx.dbf

input datafile file number=00008 name=/u01/app/oracle/oradata/PROD1/TEST.dbf

input datafile file number=00007 name=/u01/app/oracle/oradata/PROD1/TOOLS.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf

channel ORA_DISK_1: starting piece 1 at 27-MAY-15

channel ORA_DISK_1: finished piece 1 at 27-MAY-15

piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvxd4b_.bkp tag=TAG20150527T151724 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including standby control file in backup set

channel ORA_DISK_1: starting piece 1 at 27-MAY-15

channel ORA_DISK_1: finished piece 1 at 27-MAY-15

piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_ncnnf_TAG20150527T151724_bpbvxgh2_.bkp tag=TAG20150527T151724 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 27-MAY-15

Starting backup at 27-MAY-15

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=29 RECID=7 STAMP=880816687

channel ORA_DISK_1: starting piece 1 at 27-MAY-15

channel ORA_DISK_1: finished piece 1 at 27-MAY-15

piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_annnn_TAG20150527T151807_bpbvxj54_.bkp tag=TAG20150527T151807 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 27-MAY-15

Starting Control File and SPFILE Autobackup at 27-MAY-15

piece handle=/home/oracle/flash/PROD1/autobackup/2015_05_27/o1_mf_s_880816689_bpbvxkk9_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 27-MAY-15

3) 复制备份集到备库

首先在备库上使用oracle账号创建/u01/app/oracle/flash /PROD1/backupset/目录,如果使用root需要修改目录权限。

[oracle@guo flash] mkdir -p /u01/app/oracle/flash

在主库执行scp命令copy所有的备份片到备库,可以从第2步中得知生成了哪些备份片,也可以通过相关命令查看

[oracle@guo] cd /u01/app/oracle/flash/PROD1/backupset/2015_05_27

[oracle@guo 2015_05_27]$ scp * 192.168.31.3:/u01/app/oracle/fast_recovery_area/PROD1/backupset/2015_05_27

oracle@192.168.31.3’s password:

监听和tns两边都要配好,本例中走静态监听

tnsname.ora

PROD2 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = oracle2.example.com)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = PROD1)

)

)

PROD1 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = oracle1.example.com)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = PROD1)

)

)

监听文件

SID_LIST_LISTENER=

(SID_LIST=

(SID_DESC=

(GLOBAL_DBNAME=PROD1)

(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)

(SID_NAME=PROD1))

(SID_DESC=

(SID_NAME=plsextproc)

(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)

(PROGRAM=extproc)))

密码文件,两边密码要相同

orapwd  file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle  entries=5

如果 remote_login_passwordfile 该参数已经设置为EXCLUSIVE ;你最好是拷贝主库的密码文件 修改为standby库上的 orapwSID

orapwd file=orapwPROD1 password=oracle entries=30

4)使用rman连接到主库和备库

[oracle@guo admin]$ rman target / auxiliary sys/oracle@PROD2//同时连接到主备库(用到密码文件)

Recovery Manager: Release 11.2.0.3.0 – Production on Sun Sep 22 19:41:53 2013

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: PROD1 (DBID=773380365, not open) //显示出主库状态是not open,即mount

connected to auxiliary database: PROD1 (not mounted)//显示出备库状态是为not mounted,即nomout

[oracle@edbjr2p1 scripts]$ rman target / auxiliary sys/oracle@PROD2

Recovery Manager: Release 11.2.0.3.0 – Production on Wed May 27 15:23:48 2015

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

connected to target database: PROD1 (DBID=2082231315)

connected to auxiliary database: PROD1 (not mounted)

如果监听配置有问题会返回下列错误。

connected to target database: PROD1 (DBID=773380365, not open)

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00554: initialization of internal recovery manager package failed

RMAN-04006: error from auxiliary database: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

RMAN> duplicate target database for standby;//使用duplicate命令还原

如果在RMAN恢复时不指定 nofilenamecheck 参数,则在数据文件相同文件名恢复时会出现RMAN-05501错误,当主库,备库的数据库文件目录是一样的时候,必须使用 nofilenamecheck参数告诉rman主库和被创建的备份库拥有一样的文件目录和文件名。

RMAN> duplicate target database for standby nofilenamecheck;

RMAN> duplicate target database for standby nofilenamecheck;

Starting Duplicate Db at 27-MAY-15

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=10 device type=DISK

contents of Memory Script:

{

restore clone standby controlfile;

}

executing Memory Script

Starting restore at 27-MAY-15

using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/flash/PROD1/autobackup/2015_05_27/o1_mf_s_880816689_bpbvxkk9_.bkp

channel ORA_AUX_DISK_1: piece handle=/home/oracle/flash/PROD1/autobackup/2015_05_27/o1_mf_s_880816689_bpbvxkk9_.bkp tag=TAG20150527T151809

channel ORA_AUX_DISK_1: restored backup piece 1

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

output file name=/u01/app/oracle/oradata/PROD2/control01.ctl

output file name=/u01/app/oracle/oradata/PROD2/control02.ctl

output file name=/u01/app/oracle/oradata/PROD2/control03.ctl

Finished restore at 27-MAY-15

contents of Memory Script:

{

sql clone ‘alter database mount standby database’;

}

executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:

{

set newname for tempfile  1 to

“/u01/app/oracle/oradata/PROD2/temp01.dbf”;

set newname for tempfile  2 to

“/u01/app/oracle/oradata/PROD2/TEMP1.dbf”;

set newname for tempfile  3 to

“/u01/app/oracle/oradata/PROD2/TEMP2.dbf”;

switch clone tempfile all;

set newname for datafile  1 to

“/u01/app/oracle/oradata/PROD2/system01.dbf”;

set newname for datafile  2 to

“/u01/app/oracle/oradata/PROD2/sysaux01.dbf”;

set newname for datafile  3 to

“/u01/app/oracle/oradata/PROD2/undotbs01.dbf”;

set newname for datafile  4 to

“/u01/app/oracle/oradata/PROD2/users01.dbf”;

set newname for datafile  5 to

“/u01/app/oracle/oradata/PROD2/example01.dbf”;

set newname for datafile  6 to

“/u01/app/oracle/oradata/PROD2/indx.dbf”;

set newname for datafile  7 to

“/u01/app/oracle/oradata/PROD2/TOOLS.dbf”;

set newname for datafile  8 to

“/u01/app/oracle/oradata/PROD2/TEST.dbf”;

set newname for datafile  9 to

“/u01/app/oracle/oradata/PROD2/EXAMPLE.dbf”;

set newname for datafile  10 to

“/u02/oradata/prod1/test_tbs.dbf”;

restore

clone database

;

}

executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/PROD2/temp01.dbf in control file

renamed tempfile 2 to /u01/app/oracle/oradata/PROD2/TEMP1.dbf in control file

renamed tempfile 3 to /u01/app/oracle/oradata/PROD2/TEMP2.dbf in control file

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

executing command: SET NEWNAME

Starting restore at 27-MAY-15

using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore

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

channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/PROD2/system01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD2/sysaux01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD2/example01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00010 to /u02/oradata/prod1/test_tbs.dbf

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvw50n_.bkp

channel ORA_AUX_DISK_1: piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvw50n_.bkp tag=TAG20150527T151724

channel ORA_AUX_DISK_1: restored backup piece 1

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

channel ORA_AUX_DISK_1: starting datafile backup set restore

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

channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD2/undotbs01.dbf

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvx99p_.bkp

channel ORA_AUX_DISK_1: piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvx99p_.bkp tag=TAG20150527T151724

channel ORA_AUX_DISK_1: restored backup piece 1

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

channel ORA_AUX_DISK_1: starting datafile backup set restore

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

channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD2/users01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD2/indx.dbf

channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/PROD2/TOOLS.dbf

channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/PROD2/TEST.dbf

channel ORA_AUX_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/PROD2/EXAMPLE.dbf

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvxd4b_.bkp

channel ORA_AUX_DISK_1: piece handle=/home/oracle/flash/PROD1/backupset/2015_05_27/o1_mf_nnndf_TAG20150527T151724_bpbvxd4b_.bkp tag=TAG20150527T151724

channel ORA_AUX_DISK_1: restored backup piece 1

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

Finished restore at 27-MAY-15

contents of Memory Script:

{

switch clone datafile all;

}

executing Memory Script

datafile 1 switched to datafile copy

input datafile copy RECID=2 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=3 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=4 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=5 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/users01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=6 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/example01.dbf

datafile 6 switched to datafile copy

input datafile copy RECID=7 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/indx.dbf

datafile 7 switched to datafile copy

input datafile copy RECID=8 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/TOOLS.dbf

datafile 8 switched to datafile copy

input datafile copy RECID=9 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/TEST.dbf

datafile 9 switched to datafile copy

input datafile copy RECID=10 STAMP=880817113 file name=/u01/app/oracle/oradata/PROD2/EXAMPLE.dbf

datafile 10 switched to datafile copy

input datafile copy RECID=11 STAMP=880817113 file name=/u02/oradata/prod1/test_tbs.dbf

Finished Duplicate Db at 27-MAY-15

RMAN>

5)搭建完成验证

主库创建测试表:

SYS@PROD1 > create table guo as select * from dba_objects;

Table created.

SYS@PROD1 > alter system switch logfile;

System altered.

SYS@PROD1 > /

/

System altered.

SYS@PROD1 > /

System altered.

SYS@PROD1 >

System altered.

SYS@PROD1 > /

备库验证:

SYS@PROD1 >alter database open;

Database altered.

SYS@PROD1 > alter database recover managed standby database disconnect from session;//执行redo apply

Database altered.

SYS@PROD1 > select count(*) from guo;

COUNT(*)

———-

75196

如果发现无法同步,请检查密码文件是否一致。

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24742969/viewspace-1674111/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24742969/viewspace-1674111/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以帮你解答。以下是Oracle 19c Data Guard物理备库搭建的步骤: 1. 在主库上创建备份主库上创建备份,可以使用RMAN或者其他备份工具。备份完成后,将备份拷贝至备库服务器上。 2. 在备库上安装Oracle软件 在备库服务器上安装Oracle软件,确保与主库版本一致。安装过程中需要选择安装“Oracle Database软件”和“Oracle Net Services”组件。 3. 创建pfile或者spfile 在备库上创建pfile或者spfile,确保参数与主库一致。可以将主库的pfile拷贝至备库上,并进行修改。 4. 配置tnsnames.ora 在备库服务器上配置tnsnames.ora文件,确保与主库的配置一致。 5. 创建密码文件 在备库服务器上创建密码文件,使用主库上的orapwd工具即可。 6. 启动实例 在备库服务器上启动实例,可以使用startup nomount命令。启动完成后,使用rman工具恢复备份。 7. 配置Data Guard 修改备库的参数文件,开启Data Guard。在备库上执行以下命令: ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORCL_DG)'; ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=ORCL LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCL'; 其中,ORCL_DG为Data Guard配置名称,ORCL为备库的DB_UNIQUE_NAME,可以根据实际情况进行修改。 8. 启动Redo Transport 在主库上执行以下命令: ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE; 在备库上执行以下命令: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT; 9. 验证配置 在主库上执行以下命令,查看Data Guard状态: SELECT NAME,OPEN_MODE,DATABASE_ROLE FROM V$DATABASE; 如果备库的DATABASE_ROLE为PHYSICAL STANDBY,说明配置成功。 以上就是Oracle 19c Data Guard物理备库搭建的步骤。希望能对你有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值