ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 利用RMAN 建立Oracle9i RAC Data Guard(完善版)

利用RMAN 建立Oracle9i RAC Data Guard(完善版)

原创 Linux操作系统 作者:tolywang 时间:2007-03-05 00:00:00 0 删除 编辑

相关术语解释:

目标服务器: target , 需要被备份的原据库服务器.primary database 服务器 .

錄服务器: catalog , 保存备份信息的目錄服务器, data guard 服务器 .

1. RMAN服务器的配置:

以下在Dataguard Server (錄服务器)上配置.

1.0 建立RMAN数据库(比如SID=RMAN) .


1.1 RMAN用户表空间(表空间大小设置为500m左右即可) .

create tablespace rman_data

datafile '/u01/data/rman_data1.dbf' size 500M

extent management local uniform size 5M ;

1.2 RMAN用户:

create user rman identified by rman

default tablespace rman_data

temporary tablespace temp ;

1.3 RMAN用户授于相关系统权限:

grant resource, connect, recovery_catalog_owner to rman;

1.4 Dataguard Server(錄服务器)上设置tnsnames.ora 用于target服务器(Primary DB) .

tnsnames.ora 文件中加入以下内容:

DELL_RAC1 =

(DESCRIPTION =

(ADDRESS_LIST =

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

)

(CONNECT_DATA =

(SERVICE_NAME = orcl)

(INSTANCE_NAME = orcl1)

)

)

1.5 接目标服务器与CATALOG服务器. (Dataguard Server上的RMAN数据库上操作)

rman target sys/oracle@dell_rac1 catalog rman/rman(user/password必须为目标服务器上的拥有sysdba权限的用户.:sys)

1.6 在目标服务器上建CATALOG 錄.

CREATE CATALOG

1.7 CATALOG服务器上注册目标服务器.

REGISTER DATABASE;

到这里,RMAN备份环境已经准备好,幷已接至目标与目錄服务器.

2. Data Guard

2.1 COPY目标服务器上(Primary DB Server)的初始化參數文件及密码文件到Data Guard相对应目錄.

2.2 使用RMANImage copy拷贝目标服务器上的.DBF文件至Data Guard相应目錄.(见后面的详细介绍) .

2.2.1 使用REPORT SCHEMA出将要拷贝的所有目标据库上的据文件.

2.2.2 使用下面的SQL生成所有据文件的copy脚本.

SELECT 'datafile '||''''||name||''''||' to '||''''||'/data'||name||''''||',' FROM v$datafile; 或者

SELECT 'datafile '||''''||name||''''||' to '||''''||name||''''||',' FROM v$datafile;

RMAN IMAGE COPY脚本:

RUN {

ALLOCATE CHANNEL XXXXX DEVICE TYPE DISK;

COPY

...........,

..----- 放入上面SQL生成的脚本 .

……… ;

RELEASE CHANNEL XXXX;}

脚本 (如果在Data Guard Server上文件径有变化, 即与Primary DB一样, 我们会在生成控制文件后, Data Guard DBMount态下使用 alter database rename file 据文件, 脚本中前面的文件径表示Primary DB上的, 后面的径表示Data Guard Server上的文件 ) .

以下脚本例子中的 /backup目录是dataguard上的/data目录影射到Primary DB上的MountLabel (详细的nfs mount见后面的nfs mount介绍) .

RUN {

ALLOCATE CHANNEL XXXX DEVICE TYPE DISK;

COPY

datafile '/ocfs_arch2/orcldbf/log_data10.dbf' to '/backup/ocfs_arch2/orcldbf/log_data10.dbf',

datafile '/ocfs_arch2/orcldbf/log_index9.dbf' to '/backup/ocfs_arch2/orcldbf/log_index9.dbf',

datafile '/ocfs_arch2/orcldbf/sn_data16.dbf' to '/backup/ocfs_arch2/orcldbf/sn_data16.dbf',

datafile '/ocfs_arch2/orcldbf/sn_data17.dbf' to '/backup/ocfs_arch2/orcldbf/sn_data17.dbf',

datafile '/ocfs_arch2/orcldbf/sn_data18.dbf' to '/backup/ocfs_arch2/orcldbf/sn_data18.dbf',

datafile '/ocfs_arch2/orcldbf/sn_data19.dbf' to '/backup/ocfs_arch2/orcldbf/sn_data19.dbf',

datafile '/ocfs_arch2/orcldbf/sn_data20.dbf' to '/backup/ocfs_arch2/orcldbf/sn_data20.dbf',

datafile '/ocfs_arch2/orcldbf/sn_data21.dbf' to '/backup/ocfs_arch2/orcldbf/sn_data21.dbf',

datafile '/ocfs_arch2/orcldbf/sn_idx13.dbf' to '/backup/ocfs_arch2/orcldbf/sn_idx13.dbf',

datafile '/ocfs_arch2/orcldbf/sn_idx14.dbf' to '/backup/ocfs_arch2/orcldbf/sn_idx14.dbf',

datafile '/ocfs_arch2/orcldbf/sn_idx15.dbf' to '/backup/ocfs_arch2/orcldbf/sn_idx15.dbf',

datafile '/ocfs_arch2/orcldbf/sn_idx17.dbf' to '/backup/ocfs_arch2/orcldbf/sn_idx17.dbf',

datafile '/ocfs_arch2/orcldbf/sn_idx18.dbf' to '/backup/ocfs_arch2/orcldbf/sn_idx18.dbf',

datafile '/ocfs_data/orcl/cwmlite01.dbf' to '/backup/ocfs_data/orcl/cwmlite01.dbf',

datafile '/ocfs_data/orcl/drsys01.dbf' to '/backup/ocfs_data/orcl/drsys01.dbf',

datafile '/ocfs_data/orcl/example01.dbf' to '/backup/ocfs_data/orcl/example01.dbf',

datafile '/ocfs_data/orcl/ict_data1.dbf' to '/backup/ocfs_data/orcl/ict_data1.dbf',

datafile '/ocfs_data/orcl/ict_data2.dbf' to '/backup/ocfs_data/orcl/ict_data2.dbf',

datafile '/ocfs_data/orcl/ict_data3.dbf' to '/backup/ocfs_data/orcl/ict_data3.dbf',

datafile '/ocfs_data/orcl/ict_data4.dbf' to '/backup/ocfs_data/orcl/ict_data4.dbf',

datafile '/ocfs_data/orcl/indx01.dbf' to '/backup/ocfs_data/orcl/indx01.dbf',

datafile '/ocfs_data/orcl/log_data1.dbf' to '/backup/ocfs_data/orcl/log_data1.dbf',

datafile '/ocfs_data/orcl/log_data2.dbf' to '/backup/ocfs_data/orcl/log_data2.dbf',

datafile '/ocfs_data/orcl/log_data3.dbf' to '/backup/ocfs_data/orcl/log_data3.dbf',

datafile '/ocfs_data/orcl/log_data4.dbf' to '/backup/ocfs_data/orcl/log_data4.dbf',

datafile '/ocfs_data/orcl/log_data5.dbf' to '/backup/ocfs_data/orcl/log_data5.dbf',

datafile '/ocfs_data/orcl/log_data6.dbf' to '/backup/ocfs_data/orcl/log_data6.dbf',

datafile '/ocfs_data/orcl/log_data7.dbf' to '/backup/ocfs_data/orcl/log_data7.dbf',

datafile '/ocfs_data/orcl/log_data8.dbf' to '/backup/ocfs_data/orcl/log_data8.dbf',

datafile '/ocfs_data/orcl/log_data9.dbf' to '/backup/ocfs_data/orcl/log_data9.dbf',

datafile '/ocfs_data/orcl/sn_data1.dbf' to '/backup/ocfs_data/orcl/sn_data1.dbf',

datafile '/ocfs_data/orcl/sn_data10.dbf' to '/backup/ocfs_data/orcl/sn_data10.dbf',

datafile '/ocfs_data/orcl/sn_data11.dbf' to '/backup/ocfs_data/orcl/sn_data11.dbf',

datafile '/ocfs_data/orcl/sn_data12.dbf' to '/backup/ocfs_data/orcl/sn_data12.dbf',

datafile '/ocfs_data/orcl/sn_data13.dbf' to '/backup/ocfs_data/orcl/sn_data13.dbf',

datafile '/ocfs_data/orcl/sn_data14.dbf' to '/backup/ocfs_data/orcl/sn_data14.dbf',

datafile '/ocfs_data/orcl/sn_data15.dbf' to '/backup/ocfs_data/orcl/sn_data15.dbf',

datafile '/ocfs_data/orcl/sn_data2.dbf' to '/backup/ocfs_data/orcl/sn_data2.dbf',

datafile '/ocfs_data/orcl/sn_data3.dbf' to '/backup/ocfs_data/orcl/sn_data3.dbf',

datafile '/ocfs_data/orcl/sn_data4.dbf' to '/backup/ocfs_data/orcl/sn_data4.dbf',

datafile '/ocfs_data/orcl/sn_data5.dbf' to '/backup/ocfs_data/orcl/sn_data5.dbf',

datafile '/ocfs_data/orcl/sn_data6.dbf' to '/backup/ocfs_data/orcl/sn_data6.dbf',

datafile '/ocfs_data/orcl/sn_data7.dbf' to '/backup/ocfs_data/orcl/sn_data7.dbf',

datafile '/ocfs_data/orcl/sn_data8.dbf' to '/backup/ocfs_data/orcl/sn_data8.dbf',

datafile '/ocfs_data/orcl/sn_data9.dbf' to '/backup/ocfs_data/orcl/sn_data9.dbf',

datafile '/ocfs_data/orcl/system01.dbf' to '/backup/ocfs_data/orcl/system01.dbf',

datafile '/ocfs_data/orcl/tools01.dbf' to '/backup/ocfs_data/orcl/tools01.dbf',

datafile '/ocfs_data/orcl/track_data1.dbf' to '/backup/ocfs_data/orcl/track_data1.dbf',

datafile '/ocfs_data/orcl/track_data2.dbf' to '/backup/ocfs_data/orcl/track_data2.dbf',

datafile '/ocfs_data/orcl/track_data3.dbf' to '/backup/ocfs_data/orcl/track_data3.dbf',

datafile '/ocfs_data/orcl/track_data4.dbf' to '/backup/ocfs_data/orcl/track_data4.dbf',

datafile '/ocfs_data/orcl/track_data5.dbf' to '/backup/ocfs_data/orcl/track_data5.dbf',

datafile '/ocfs_data/orcl/track_data6.dbf' to '/backup/ocfs_data/orcl/track_data6.dbf',

datafile '/ocfs_data/orcl/track_data7.dbf' to '/backup/ocfs_data/orcl/track_data7.dbf',

datafile '/ocfs_data/orcl/track_data8.dbf' to '/backup/ocfs_data/orcl/track_data8.dbf',

datafile '/ocfs_data/orcl/undotbs01.dbf' to '/backup/ocfs_data/orcl/undotbs01.dbf',

datafile '/ocfs_data/orcl/undotbs01_1.dbf' to '/backup/ocfs_data/orcl/undotbs01_1.dbf',

datafile '/ocfs_data/orcl/undotbs02.dbf' to '/backup/ocfs_data/orcl/undotbs02.dbf',

datafile '/ocfs_data/orcl/undotbs02_1.dbf' to '/backup/ocfs_data/orcl/undotbs02_1.dbf',

datafile '/ocfs_data/orcl/undotbs02_2.dbf' to '/backup/ocfs_data/orcl/undotbs02_2.dbf',

datafile '/ocfs_data/orcl/users01.dbf' to '/backup/ocfs_data/orcl/users01.dbf',

datafile '/ocfs_data/orcl/xdb01.dbf' to '/backup/ocfs_data/orcl/xdb01.dbf',

datafile '/ocfs_data2/orcl/ict_data07.dbf' to '/backup/ocfs_data2/orcl/ict_data07.dbf',

datafile '/ocfs_data2/orcl/ict_data08.dbf' to '/backup/ocfs_data2/orcl/ict_data08.dbf',

datafile '/ocfs_data2/orcl/ict_data09.dbf' to '/backup/ocfs_data2/orcl/ict_data09.dbf',

datafile '/ocfs_data2/orcl/ict_data10.dbf' to '/backup/ocfs_data2/orcl/ict_data10.dbf',

datafile '/ocfs_data2/orcl/ict_data11.dbf' to '/backup/ocfs_data2/orcl/ict_data11.dbf',

datafile '/ocfs_data2/orcl/ict_data12.dbf' to '/backup/ocfs_data2/orcl/ict_data12.dbf' ;

RELEASE CHANNEL XXXX;}

Copy datafile /ocfs_data/orcl/xx.dbf to /backup/ocfs_data/orcl/xx.dbf'中.

第一个`/ocfs_data/orcl/xx.dbf'是目标服务器的据文件地址. /backup/ocfs_data/orcl/xx.dbf 是挂载到目标服务器上的dataguard的相应目錄.

假设脚本文件保存为 rman.txt 文件 .

注意: 如果某个文件上有逻辑坏块, 可以用如下语句查询并在RMAN中忽略处理 .

查询坏块: ( 一般在LogTrace文件中会有文件及数据块标示 )

SELECT segment_name,segment_type,extent_id,block_id, blocks

from dba_extents t

where file_id = 10

AND 51896 between block_id and (block_id + blocks - 1)

RMAN> run2> {3> set maxcorrupt for datafile 10 to 200; -----表示忽略掉文间file#=10200个坏块4> }

:

需要先将将要成为dataguard服务器的文件存放目錄使用NFS映像至目标服务器(Primary DB Server ) 相关目錄.

具体步骤如下:

LinuxNFS的配置

2.3. NFS server(在此处为Data Guard服务器)及客户端(Primary DB Server)设置:

2.3.1 /etc/exports 发布挂载的目錄(dataguard server上操作).

: /data *(rw,no_root_squash)

/datadata guard server上分享的目錄,*表示允许任何主机分享,rw,no_root_squash參數

代表意义如下:

rw: 写的权限

ro: 的权限

no_root_squash: 登入 NFS 主机使用分享目錄的使用者,如果是 root 的话,那么对于这个分享的目錄來說,他就具有 root 的权限!

root_squash: 在登入 NFS 主机使用分享之目錄的使用者如果是 root 时,那么这个使用者的权限将被压缩成为名使用者.

2.3.2 Data Gurad DB Server上启动个相关服务

#/etc/rc.d/init.d/portmap start (or:#service portmap start)

#/etc/rc.d/init.d/nfs start (or:#service nfs start)

2.3.3. NFS客户端的设定(TARGET服务器, Primary database Server )

用其它设定,直接挂载就可以

#mount -t nfs dataguard_server_ip:/directory /mountpoint

/mountpoint Primary Database Server上的挂载点 .

:

mount -t nfs 10.161.8.83:/data /backup

例子:

[root@dmdii-node1 root]# mount -t nfs 10.155.4.83:/data /backup

[root@dmdii-node1 root]# df

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sdi6 2063504 375456 1583228 20% /

/dev/sdi3 256665 20696 222716 9% /boot

none 1934772 0 1934772 0% /dev/shm

/dev/sdi7 2063504 32848 1925836 2% /tmp

/dev/sdi9 52633212 9093964 40865632 19% /u01

/dev/sdi8 8254240 2193704 5641244 28% /usr

/dev/sdi2 2300688 33480 2150336 2% /home

/dev/emcpowere1 314566752 178588640 135978112 57% /ocfs_data

/dev/emcpowerf1 5002336 920800 4081536 19% /ocfs_ctrl_redo

/dev/emcpowerf2 20007008 1420768 18586240 8% /ocfs_arch1

/dev/emcpowerf3 20007008 156640 19850368 1% /ocfs_arch2

/dev/emcpowerf4 269544672 178439264 91105408 67% /ocfs_index

10.155.4.83:/data 423027280 353234868 48303872 88% /backup

Copy datafile

/ocfs_data/orcl/xx.dbf to /backup/ocfs_data/orcl/xx.dbf'中.

第一个`/ocfs_data/orcl/xx.dbf'是目标服务器的据文件地址. /backup/ocfs_data/orcl/xx.dbf 是挂载到目标服务器上的dataguard的相应目錄.

2.4在目錄服务器(Data Guard Server) RMAN环境下执以上的脚本

rman接目标服务器与目錄服务器 .

rman target sys/oracle@intel_rac1 catalog rman/rman(user/password必须为目标服务器上的拥有sysdba权限的用户.:sys)

RMAN > @rman.txt

copy据文件完成后,在目标服务器创建STANDBY CONTROLFILE

ALTER DTABASE CREATE STANDBY CONTROLFILE AS '..........'

2.5 COPY目标服务器归档日志至DATAGUARD.

2.6 RECOVER STANDBY DATATABASE.

2.7 测试DATAGUARD能否换至只模式

========================================================

备注:

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

下一篇: 常见的补血食物
请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    13102605