用RMAN复制搭建物理DataGurad环境.docx

上传人:b****5 文档编号:3524793 上传时间:2022-11-23 格式:DOCX 页数:13 大小:19.86KB
下载 相关 举报
用RMAN复制搭建物理DataGurad环境.docx_第1页
第1页 / 共13页
用RMAN复制搭建物理DataGurad环境.docx_第2页
第2页 / 共13页
用RMAN复制搭建物理DataGurad环境.docx_第3页
第3页 / 共13页
用RMAN复制搭建物理DataGurad环境.docx_第4页
第4页 / 共13页
用RMAN复制搭建物理DataGurad环境.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

用RMAN复制搭建物理DataGurad环境.docx

《用RMAN复制搭建物理DataGurad环境.docx》由会员分享,可在线阅读,更多相关《用RMAN复制搭建物理DataGurad环境.docx(13页珍藏版)》请在冰豆网上搜索。

用RMAN复制搭建物理DataGurad环境.docx

用RMAN复制搭建物理DataGurad环境

Data Guard 环境:

操作系统:

 redhat 4.7 

Primary数据库:

IP地址:

10.85.10.1

数据库SID:

orcl

DB_UNIQUE_NAME:

orcl_pd

 

Standby数据库:

IP地址:

10.85.10.2

数据库SID:

orcl

DB_UNIQUE_NAME:

orcl_st

之前也做过相关实验, 今天这个测试主要是用RMAN 来复制备份, 之前一直是直接copy 文件的。

 实验步骤都差不多。

 

一. Primary 端的配置

1.  主库设置为force logging 模式

SQL> alter database force logging;

2. 主库设为归档模式

SQL> archive log list; 

SQL> shutdown immediate 

SQL> startup mount 

SQL> alter database archivelog; 

SQL> archive log list; 

3. 创建备库的口令文件

[oracle@localhost dbs]$ orapwd file=/u02/orapworcl password=admin

如果已经存在,就不用创建了。

 缺省情况下,win下口令文件的格式是pwdsid.ora,unix下的格式是orapwSID(大小写敏感)。

 Linux默认位置为$ORACLE_HOME/dbs目录下下,Windows 默认为$ORACLE_HOME/database目录。

用SCP命令将这个口令文件传输到备库的对应位置:

[oracle@db1 dbs]$ scp orapworcl 10.85.10.2:

/u01/app/oracle/product/10.2.0/db_1/dbs

The authenticity of host '10.85.10.2 (10.85.10.2)' can't be established.

RSA key fingerprint is 1a:

20:

7a:

05:

bd:

e0:

ac:

04:

21:

02:

b1:

72:

01:

69:

40:

d6.

Are you sure you want to continue connecting (yes/no)?

 yes

Warning:

 Permanently added '10.85.10.2' (RSA) to the list of known hosts.

oracle@10.85.10.2's password:

orapworcl                                     100% 1536     1.5KB/s   00:

00

注意,如果不用RMAN 复制的话,还需要创建备库的控制文件。

 RMAN复制的话,自己会创建控制文件。

4. 修改初始化参数文件

Pfile 默认位置在$ORACLE_HOME/dbs目录下,也可以自己指定位置:

SQL> create pfile from spfile;

在initorcl.ora 添加如下内容:

*.DB_UNIQUE_NAME='orcl_pd' 

*.log_archive_dest_1='location=/u02/archivelog' 

*.log_archive_dest_2='SERVICE=orcl_st' 

*.LOG_ARCHIVE_DEST_STATE_1=ENABLE 

*.LOG_ARCHIVE_DEST_STATE_2=ENABLE 

*.standby_file_management='AUTO'

*.standby_archive_dest='/u02/archivelog'

*.FAL_SERVER='orcl_st' 

*.FAL_CLIENT='orcl_pd' 

如果主库和备库的数据文件位置不同,还需要加如下2个参数:

*.log_file_name_convert='/u02/oradata/orcl/','/u03/oradata/orcl/'

*.db_file_name_convert='/u02/oradata/orcl/','/u03/oradata/orcl/'

-- 注意:

orcl_st,orcl_pd 是在tnsnames文件中配置的

用刚修改的pfile 启动数据库,并生成spfile。

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup pfile=?

/dbs/initorcl.ora

ORACLE instance started.

Total System Global Area  247463936 bytes

Fixed Size                  1218748 bytes

Variable Size              75499332 bytes

Database Buffers          163577856 bytes

Redo Buffers                7168000 bytes

Database mounted.

Database opened.

SQL> !

echo $ORACLE_HOME

/u01/app/oracle/product/10.2.0/db_1

SQL> create spfile from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora';

File created.

5. 修改listener.ora 和tnsnames.ora 文件

Listener.ora 文件:

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

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

      (PROGRAM = extproc)

    )

(SID_DESC =

(GLOBAL_DBNAME = orcl)

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

        (SID_NAME = orcl)  

    )

  )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

    )

  )

注意:

SID_LIST_LISTENER 配置的是静态注册,如果没有该参数,而且Data Guard 启动顺序又不正确,那么在主库可能会报 PING[ARC1]:

 Heartbeat failed to connect to standby 'orcl_st'. Error is 12514. 错误,导致归档无法完成。

Tnsnames.ora 文件

ORCL_ST =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

(SERVER = DEDICATED) 

        (SERVICE_NAME = orcl)

    )

  )

ORCL_PD =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

          (SERVER = DEDICATED) 

        (SERVICE_NAME = orcl)

    )

  )

 

 

二. Standby 端配置

 1. 创建备库存放数据文件和后台跟踪目录。

 这个目录可以和主库相同, 如果不同,就需要在主库的初始化文件中进行转换。

 如:

*.log_file_name_convert='/u02/oradata/orcl/','/u03/oradata/orcl/'

*.db_file_name_convert='/u02/oradata/orcl/','/u03/oradata/orcl/'

 

   $ORACLE_BASE/ORADATA/ORCL 

   $ORACLE_BASE/admin/orcl 

   $ORACLE_BASE/admin/orcl/adump 

   $ORACLE_BASE/admin/orcl/bdump 

   $ORACLE_BASE/admin/orcl/cdump 

   $ORACLE_BASE/admin/orcl/dpdump 

   $ORACLE_BASE/admin/orcl/pfile 

   $ORACLE_BASE/admin/orcl/udump 

   $ORACLE_BASE/admin/orcl/ 

2. 修改初始化参数文件

从主库copy过来,修改如下:

*.DB_UNIQUE_NAME='orcl_st' 

*.log_archive_dest_1='location=/u01/archivelog' 

*.log_archive_dest_2='SERVICE=orcl_pd' 

*.LOG_ARCHIVE_DEST_STATE_1=ENABLE 

*.LOG_ARCHIVE_DEST_STATE_2=ENABLE 

*.FAL_SERVER='orcl_pd' 

*.FAL_CLIENT='orcl_st' 

*.standby_file_management='AUTO'

*.standby_archive_dest='/u01/archivelog'

log_file_name_convert =('orcl','orcl')  -- 该参数用于RMAN复制时重建redo 文件。

4. 修改listener.ora 和 tnsnames.ora 文件,同主库。

如果不存在,就从主库上copy 过去。

5. RMAN 复制数据库

5.1 备份主库

[oracle@db1 backup]$ rman target sys/admin@MYNEW1_PD

Recovery Manager:

 Release 10.2.0.1.0 - Production on Sun Jul 18 18:

26:

16 2010

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

connected to target database:

 ORCL (DBID=1248423599)

RMAN>RUN { 

allocate channel c1 type disk;

allocate channel c2 type disk;

sql 'alter system archive log current';

backup current controlfile for standby format='/u02/backup/control_%U';

BACKUP FORMAT '/u02/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE ; 

sql 'alter system archive log current';

BACKUP FORMAT '/u02/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT; 

release channel c2;

release channel c1;

}

backup full database include current controlfile for standby plus archivelog FORMAT '/u02/backup/orcl_%U_%T' skip inaccessible filesperset 5 ;

备份脚本,具体参考:

Linux 平台下 RMAN 全备 和 增量备份 shell 脚本

5.2  用SCP将备份集复制到备库相同的位置,或者直接用NFS 挂载到相同位置。

 这些位置写入了控制文件,所以位置必须相同。

 

   Linux NFS 和 Samba 共享配置

如果出现:

ORA-27054 NFS file system where the file is created or resides is not mounted with correct options的错误,可能是NFS 挂载的参数使用不正确。

 

mount -t nfs 192.168.19.219:

/u01/rman -o hard,rw,noac,rsize=32768,wsize=32768,suid,proto=tcp,vers=3 /u01/rman

如果用SCP复制,复制结束要后注意文件用户和权限。

5.3 用pfile文件将备库启动到nomout状态

[oracle@localhost u01]$ sqlplus /nolog

SQL*Plus:

 Release 10.2.0.1.0 - Production on Wed Jul 21 09:

35:

07 2010

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

SQL> conn / as sysdba

Connected to an idle instance.

SQL> startup nomount pfile=?

/dbs/initorcl.ora

ORACLE instance started.

Total System Global Area  247463936 bytes

Fixed Size                  1218772 bytes

Variable Size              79693612 bytes

Database Buffers          163577856 bytes

Redo Buffers                2973696 bytes

5.4  执行duplicate 复制standby库

[oracle@db1 dbs]$ rman target / auxiliary sys/admin@orcl_st;

Recovery Manager:

 Release 10.2.0.1.0 - Production on Tue Jul 20 22:

32:

59 2010

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

connected to target database:

 ORCL (DBID=1248423599)

connected to auxiliary database:

 ORCL (not mounted)

RMAN> duplicate target database for standby nofilenamecheck dorecover;

Starting Duplicate Db at 21-JUL-10

using target database control file instead of recovery catalog

allocated channel:

 ORA_AUX_DISK_1

channel ORA_AUX_DISK_1:

 sid=155 devtype=DISK

contents of Memory Script:

{

   set until scn  800873;

   restore clone standby controlfile;

   sql clone 'alter database mount standby database';

}

executing Memory Script

executing command:

 SET until clause

Starting restore at 21-JUL-10

using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1:

 starting datafile backupset restore

channel ORA_AUX_DISK_1:

 restoring control file

channel ORA_AUX_DISK_1:

 reading from backup piece /u02/backup/control_6mljbc6r_1_1

channel ORA_AUX_DISK_1:

 restored backup piece 1

piece handle=/u02/backup/control_6mljbc6r_1_1 tag=TAG20100721T115609

channel ORA_AUX_DISK_1:

 restore complete, elapsed time:

 00:

00:

02

output filename=/u01/app/oracle/oradata/orcl/control01.ctl

output filename=/u01/app/oracle/oradata/orcl/control02.ctl

output filename=/u01/app/oracle/oradata/orcl/control03.ctl

Finished restore at 21-JUL-10

sql statement:

 alter database mount standby database

released channel:

 ORA_AUX_DISK_1

contents of Memory Script:

{

   set until scn  800873;

   set newname for tempfile  1 to  "/u01/app/oracle/oradata/orcl/temp01.dbf";

   switch clone tempfile all;

   set newname for datafile  1 to  "/u01/app/oracle/oradata/orcl/system01.dbf";

   set newname for datafile  2 to  "/u01/app/oracle/oradata/orcl/undotbs01.dbf";

   set newname for datafile  3 to  "/u01/app/oracle/oradata/orcl/sysaux01.dbf";

   set newname for datafile  4 to  "/u01/app/oracle/oradata/orcl/users01.dbf";

   set newname for datafile  5 to  "/u01/app/oracle/oradata/orcl/example01.dbf";

   restore

   check readonly

   clone database

   ;

}

executing Memory Script

executing command:

 SET until clause

executing command:

 SET NEWNAME

renamed temporary file 1 to /u01/app/oracle/oradata/orcl/temp01.dbf in control file

executing command:

 SET NEWNAME

executing command:

 SET NEWNAME

executing command:

 SET NEWNAME

executing command:

 SET NEWNAME

executing command:

 SET NEWNAME

Starting restore at 21-JUL-10

allocated channel:

 ORA_AUX_DISK_1

channel ORA_AUX_DISK_1:

 sid=155 devtype=DISK

channel ORA_AUX_DISK_1:

 starting datafile backupset restore

channel ORA_AUX_DISK_1:

 specifying datafile(s) to restore from backup set

restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf

restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf

restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf

channel ORA_AUX_DISK_1:

 reading from backup piece /u02/backup/orcl_6oljbc7f_1_1_20100721

channel ORA_AUX_DISK_1:

 restored backup piece 1

piece handle=/u02/backup/orcl_6oljbc7f_1_1_20100721 tag=TAG20100721T115629

channel ORA_AUX_DISK_1:

 restore complete, elapsed time:

 00:

00:

39

channel ORA_AUX_DISK_1:

 starting datafile backupset restore

channel ORA_AUX_DISK_1:

 specifying datafile(s) to restor

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 营销活动策划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1