相关术语解释:
目标服务器: target , 需要被备份的原數据库服务器.这裡指primary database 服务器 .
目錄服务器: catalog , 保存备份信息的目錄服务器, 这裡指data guard 服务器 .
1. 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 在目錄服务器(即Standby Server)上设置tnsnames.ora 用于連target服务器(Primary DB) .
tnsnames.ora 文件中加入:
INTEL_RAC1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.161.8.81)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = intel)
(INSTANCE_NAME = intel1)
)
)
1.5 連接目标服务器与CATALOG服务器.
rman target sys/oracle@intel_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 使用RMAN的Image 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 XXXX DEVICE TYPE DISK;
COPY
...........,
…..----- 这裡放入上面SQL生成的脚本 .
……… ;
RELEASE CHANNEL XXXX;}
脚本例子 (如果在Data Guard Server上文件路径有变化, 即与Primary DB上路径不一样, 我们会在生成控制文件后, 在Data Guard DB上Mount狀态下使用 alter database rename file 更改數据文件路径, 脚本中前面的文件路径表示Primary DB上的路径, 后面的路径表示Data Guard Server上的文件路径 ) . 有时候可能后面的路径需要修改 。 那么脚本需要手工编辑。
RUN {
ALLOCATE CHANNEL XXXX DEVICE TYPE DISK;
COPY
datafile '/ocfs_data/intel/system01.dbf' to '/ocfs_data/intel/system01.dbf',
datafile '/ocfs_data/intel/undotbs01.dbf' to '/ocfs_data/intel/undotbs01.dbf',
datafile '/ocfs_data/intel/cwmlite01.dbf' to '/ocfs_data/intel/cwmlite01.dbf',
datafile '/ocfs_data/intel/drsys01.dbf' to '/ocfs_data/intel/drsys01.dbf',
datafile '/ocfs_data/intel/indx01.dbf' to '/ocfs_data/intel/indx01.dbf',
datafile '/ocfs_data/intel/tools01.dbf' to '/ocfs_data/intel/tools01.dbf',
datafile '/ocfs_data/intel/users01.dbf' to '/ocfs_data/intel/users01.dbf',
datafile '/ocfs_data/intel/xdb01.dbf' to '/ocfs_data/intel/xdb01.dbf',
datafile '/ocfs_data/intel/undotbs02.dbf' to '/ocfs_data/intel/undotbs02.dbf',
datafile '/ocfs_data/intel/base_data01.dbf' to '/ocfs_data/intel/base_data01.dbf',
datafile '/ocfs_data/intel/base_data02.dbf' to '/ocfs_data/intel/base_data02.dbf',
datafile '/ocfs_data/intel/base_data03.dbf' to '/ocfs_data/intel/base_data03.dbf',
datafile '/ocfs_data/intel/base_data04.dbf' to '/ocfs_data/intel/base_data04.dbf',
datafile '/ocfs_data/intel/base_data05.dbf' to '/ocfs_data/intel/base_data05.dbf',
datafile '/ocfs_data/intel/base_data06.dbf' to '/ocfs_data/intel/base_data06.dbf',
datafile '/ocfs_index/intel/base_idx01.dbf' to '/ocfs_index/intel/base_idx01.dbf',
datafile '/ocfs_index/intel/base_idx02.dbf' to '/ocfs_index/intel/base_idx02.dbf',
datafile '/ocfs_index/intel/base_idx03.dbf' to '/ocfs_index/intel/base_idx03.dbf',
datafile '/ocfs_data/intel/log_data01.dbf' to '/ocfs_data/intel/log_data01.dbf',
datafile '/ocfs_data/intel/log_data02.dbf' to '/ocfs_data/intel/log_data02.dbf',
datafile '/ocfs_data/intel/log_data03.dbf' to '/ocfs_data/intel/log_data03.dbf',
datafile '/ocfs_data/intel/log_data04.dbf' to '/ocfs_data/intel/log_data04.dbf',
datafile '/ocfs_data/intel/log_data05.dbf' to '/ocfs_data/intel/log_data05.dbf',
datafile '/ocfs_data/intel/log_data06.dbf' to '/ocfs_data/intel/log_data06.dbf',
datafile '/ocfs_data/intel/log_data07.dbf' to '/ocfs_data/intel/log_data07.dbf',
datafile '/ocfs_data/intel/log_data08.dbf' to '/ocfs_data/intel/log_data08.dbf',
datafile '/ocfs_index/intel/log_index01.dbf' to '/ocfs_index/intel/log_index01.dbf',
datafile '/ocfs_index/intel/log_index02.dbf' to '/ocfs_index/intel/log_index02.dbf',
datafile '/ocfs_index/intel/log_index03.dbf' to '/ocfs_index/intel/log_index03.dbf',
datafile '/ocfs_index/intel/log_index04.dbf' to '/ocfs_index/intel/log_index04.dbf',
datafile '/ocfs_index/intel/log_index05.dbf' to '/ocfs_index/intel/log_index05.dbf',
datafile '/ocfs_index/intel/log_index06.dbf' to '/ocfs_index/intel/log_index06.dbf',
datafile '/ocfs_data/intel/track_data01.dbf' to '/ocfs_data/intel/track_data01.dbf',
datafile '/ocfs_data/intel/track_data02.dbf' to '/ocfs_data/intel/track_data02.dbf',
datafile '/ocfs_data/intel/track_data03.dbf' to '/ocfs_data/intel/track_data03.dbf',
datafile '/ocfs_data/intel/track_data04.dbf' to '/ocfs_data/intel/track_data04.dbf',
datafile '/ocfs_index/intel/track_index01.dbf' to '/ocfs_index/intel/track_index01.dbf',
datafile '/ocfs_index/intel/track_index02.dbf' to '/ocfs_index/intel/track_index02.dbf',
datafile '/ocfs_index/intel/track_index03.dbf' to '/ocfs_index/intel/track_index03.dbf',
datafile '/ocfs_index/intel/track_index04.dbf' to '/ocfs_index/intel/track_index04.dbf',
datafile '/ocfs_data/intel/sn_data01.dbf' to '/ocfs_data/intel/sn_data01.dbf',
datafile '/ocfs_data/intel/sn_data02.dbf' to '/ocfs_data/intel/sn_data02.dbf',
datafile '/ocfs_data/intel/sn_data03.dbf' to '/ocfs_data/intel/sn_data03.dbf',
datafile '/ocfs_data/intel/sn_data04.dbf' to '/ocfs_data/intel/sn_data04.dbf',
datafile '/ocfs_data/intel/sn_data05.dbf' to '/ocfs_data/intel/sn_data05.dbf',
datafile '/ocfs_data/intel/sn_data06.dbf' to '/ocfs_data/intel/sn_data06.dbf',
datafile '/ocfs_data/intel/sn_data07.dbf' to '/ocfs_data/intel/sn_data07.dbf',
datafile '/ocfs_data/intel/sn_data08.dbf' to '/ocfs_data/intel/sn_data08.dbf',
datafile '/ocfs_data/intel/sn_data09.dbf' to '/ocfs_data/intel/sn_data09.dbf',
datafile '/ocfs_data/intel/sn_data10.dbf' to '/ocfs_data/intel/sn_data10.dbf',
datafile '/ocfs_data/intel/sn_data11.dbf' to '/ocfs_data/intel/sn_data11.dbf',
datafile '/ocfs_data/intel/sn_data12.dbf' to '/ocfs_data/intel/sn_data12.dbf',
datafile '/ocfs_data/intel/sn_data13.dbf' to '/ocfs_data/intel/sn_data13.dbf',
datafile '/ocfs_data/intel/sn_data14.dbf' to '/ocfs_data/intel/sn_data14.dbf',
datafile '/ocfs_data/intel/sn_data15.dbf' to '/ocfs_data/intel/sn_data15.dbf',
datafile '/ocfs_data/intel/sn_data16.dbf' to '/ocfs_data/intel/sn_data16.dbf',
datafile '/ocfs_data/intel/sn_data17.dbf' to '/ocfs_data/intel/sn_data17.dbf',
datafile '/ocfs_data/intel/sn_data18.dbf' to '/ocfs_data/intel/sn_data18.dbf',
datafile '/ocfs_index/intel/sn_idx01.dbf' to '/ocfs_index/intel/sn_idx01.dbf',
datafile '/ocfs_index/intel/sn_idx02.dbf' to '/ocfs_index/intel/sn_idx02.dbf',
datafile '/ocfs_index/intel/sn_idx03.dbf' to '/ocfs_index/intel/sn_idx03.dbf',
datafile '/ocfs_index/intel/sn_idx04.dbf' to '/ocfs_index/intel/sn_idx04.dbf',
datafile '/ocfs_index/intel/sn_idx05.dbf' to '/ocfs_index/intel/sn_idx05.dbf',
datafile '/ocfs_index/intel/sn_idx06.dbf' to '/ocfs_index/intel/sn_idx06.dbf',
datafile '/ocfs_index/intel/sn_idx07.dbf' to '/ocfs_index/intel/sn_idx07.dbf',
datafile '/ocfs_index/intel/sn_idx08.dbf' to '/ocfs_index/intel/sn_idx08.dbf',
datafile '/ocfs_index/intel/sn_idx09.dbf' to '/ocfs_index/intel/sn_idx09.dbf',
datafile '/ocfs_index/intel/sn_idx10.dbf' to '/ocfs_index/intel/sn_idx10.dbf',
datafile '/ocfs_index/intel/sn_idx11.dbf' to '/ocfs_index/intel/sn_idx11.dbf',
datafile '/ocfs_index/intel/sn_idx12.dbf' to '/ocfs_index/intel/sn_idx12.dbf',
datafile '/ocfs_index/intel/sn_idx13.dbf' to '/ocfs_index/intel/sn_idx13.dbf',
datafile '/ocfs_index/intel/sn_idx14.dbf' to '/ocfs_index/intel/sn_idx14.dbf',
datafile '/ocfs_index/intel/sn_idx15.dbf' to '/ocfs_index/intel/sn_idx15.dbf',
datafile '/ocfs_index/intel/sn_idx16.dbf' to '/ocfs_index/intel/sn_idx16.dbf',
datafile '/ocfs_index/intel/sn_idx17.dbf' to '/ocfs_index/intel/sn_idx17.dbf',
datafile '/ocfs_data/intel/ict_data01.dbf' to '/ocfs_data/intel/ict_data01.dbf',
datafile '/ocfs_data/intel/ict_data02.dbf' to '/ocfs_data/intel/ict_data02.dbf',
datafile '/ocfs_data/intel/ict_data03.dbf' to '/ocfs_data/intel/ict_data03.dbf',
datafile '/ocfs_data/intel/ict_data04.dbf' to '/ocfs_data/intel/ict_data04.dbf',
datafile '/ocfs_data/intel/ict_data05.dbf' to '/ocfs_data/intel/ict_data05.dbf',
datafile '/ocfs_index/intel/ict_idx01.dbf' to '/ocfs_index/intel/ict_idx01.dbf',
datafile '/ocfs_index/intel/ict_idx02.dbf' to '/ocfs_index/intel/ict_idx02.dbf',
datafile '/ocfs_index/intel/ict_idx03.dbf' to '/ocfs_index/intel/ict_idx03.dbf',
datafile '/ocfs_index/intel/ict_idx04.dbf' to '/ocfs_index/intel/ict_idx04.dbf',
datafile '/ocfs_index/intel/ict_idx05.dbf' to '/ocfs_index/intel/ict_idx05.dbf',
datafile '/ocfs_data/intel/rec_data01.dbf' to '/ocfs_data/intel/rec_data01.dbf',
datafile '/ocfs_data/intel/rec_data02.dbf' to '/ocfs_data/intel/rec_data02.dbf',
datafile '/ocfs_index/intel/rec_idx01.dbf' to '/ocfs_index/intel/rec_idx01.dbf',
datafile '/ocfs_index/intel/rec_idx02.dbf' to '/ocfs_index/intel/rec_idx02.dbf',
datafile '/ocfs_data/intel/wiplog_data01.dbf' to '/ocfs_data/intel/wiplog_data01.dbf',
datafile '/ocfs_data/intel/wiplog_data02.dbf' to '/ocfs_data/intel/wiplog_data02.dbf',
datafile '/ocfs_data/intel/wiplog_data03.dbf' to '/ocfs_data/intel/wiplog_data03.dbf',
datafile '/ocfs_data/intel/wiplog_data04.dbf' to '/ocfs_data/intel/wiplog_data04.dbf',
datafile '/ocfs_data/intel/wiplog_data05.dbf' to '/ocfs_data/intel/wiplog_data05.dbf',
datafile '/ocfs_data/intel/wiplog_data06.dbf' to '/ocfs_data/intel/wiplog_data06.dbf',
datafile '/ocfs_data/intel/wiplog_data07.dbf' to '/ocfs_data/intel/wiplog_data07.dbf',
datafile '/ocfs_index/intel/wiplog_idx01.dbf' to '/ocfs_index/intel/wiplog_idx01.dbf',
datafile '/ocfs_index/intel/wiplog_idx02.dbf' to '/ocfs_index/intel/wiplog_idx02.dbf',
datafile '/ocfs_index/intel/wiplog_idx03.dbf' to '/ocfs_index/intel/wiplog_idx03.dbf',
datafile '/ocfs_index/intel/wiplog_idx04.dbf' to '/ocfs_index/intel/wiplog_idx04.dbf',
datafile '/ocfs_index/intel/wiplog_idx05.dbf' to '/ocfs_index/intel/wiplog_idx05.dbf',
datafile '/ocfs_index/intel/wiplog_idx06.dbf' to '/ocfs_index/intel/wiplog_idx06.dbf',
datafile '/ocfs_index/intel/wiplog_idx07.dbf' to '/ocfs_index/intel/wiplog_idx07.dbf',
datafile '/ocfs_data/intel/undotbs01_1.dbf' to '/ocfs_data/intel/undotbs01_1.dbf',
datafile '/ocfs_data/intel/undotbs01_2.dbf' to '/ocfs_data/intel/undotbs01_2.dbf',
datafile '/ocfs_data/intel/undotbs02_1.dbf' to '/ocfs_data/intel/undotbs02_1.dbf',
datafile '/ocfs_data/intel/ict_data06.dbf' to '/ocfs_data/intel/ict_data06.dbf',
datafile '/ocfs_data/intel/undotbs02_2.dbf' to '/ocfs_data/intel/undotbs02_2.dbf',
datafile '/ocfs_data/intel/ict_data07.dbf' to '/ocfs_data/intel/ict_data07.dbf',
datafile '/ocfs_index/intel/wiplog_idx08.dbf' to '/ocfs_index/intel/wiplog_idx08.dbf',
datafile '/ocfs_data/intel/ict_data08.dbf' to '/ocfs_data/intel/ict_data08.dbf',
datafile '/ocfs_index/intel/sn_idx18.dbf' to '/ocfs_index/intel/sn_idx18.dbf',
datafile '/ocfs_index/intel/track_index05.dbf' to '/ocfs_index/intel/track_index05.dbf',
datafile '/ocfs_data/intel/ict_data09.dbf' to '/ocfs_data/intel/ict_data09.dbf' ;
RELEASE CHANNEL XXXX;}
假设脚本文件保存为 rman.txt 文件 .
說明:
需要先将将要成为dataguard服务器的文件存放目錄使用NFS映像至目标服务器(Primary DB Server ) 相关目錄.
具体步骤如下:
Linux下NFS的配置
2.3. NFS server端(在此处为Data Guard服务器)及客户端(Primary DB Server)设置:
2.3.1 在/etc/exports 发布挂载的目錄.
如: /data *(rw,no_root_squash)
/data为data 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
在Copy datafile
`/data/xx/xx.dbf' to `/backup/data/xx/xx.dbf'中.
第一个'/data/xx/xx.dbf'是目标服务器的數据文件地址. `/backup/data/xx/xx.dbf'是挂载到目标服务器上的dataguard的相应目錄.
2.4在目錄服务器(Data Guard Server) RMAN环境下执行以上的脚本
先rman連接目标服务器与目錄服务器 .
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-84420/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/35489/viewspace-84420/