使用RMAN增量备份来更新传输表空间

要使用RMAN增量备份来更新传输表空间需要了解传输表空间与RMAN的增量备份。这里主要介绍使用增量备份来更新传输表空间,就不介绍传输表空间与RMAN增量备份。下面是使用RMAN增量备份来更新传输表空间的操作。目标主机是weblogic29,原主机是weblogic28。

1.在两台数据库服务器上配置NFS
配置/etc/exports
 nfs允许挂载的目录及权限需在文件/etc/exports中进行定义。例如,我们要将数据文件所在目录
/u01/app/Oracle/oradata/jytest/与/backup目录共享出来,那么我们需要编辑/etc/exports文件,追加两行
/u01/app/oracle/oradata/jytest/ *(rw,sync)
/backup/ *(rw,sync)

[root@weblogic29 oracle]# vi /etc/exports
/u01/app/oracle/oradata/jytest/ *(rw,sync)
/backup/ *(rw,sync)


启动nfs服务
[root@weblogic29 oracle]# service portmap start
Starting portmap: [ OK ]
[root@weblogic29 oracle]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]


在客户端主机上挂载共享目录
[root@weblogic28 ~]# service portmap start
Starting portmap: [ OK ]

[root@weblogic28 ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]


在客户端使用showmount -e IP 查看nfs主机共享情况:
[root@weblogic28 ~]# showmount -e 10.138.130.29
Export list for 10.138.130.29:
/backup *
/u01/app/oracle/oradata/jytest *


在客户端建立NFS文件夹并执行mount挂载命令:
[root@weblogic28 ~]# mkdir /jytest_data
[root@weblogic28 ~]# mkdir /backup
[root@weblogic28 ~]# chown -R oracle:oinstall /jytest_data
[root@weblogic28 ~]# chown -R oracle:oinstall /backup
[root@weblogic28 ~]# chmod -R 777 /jytest_data
[root@weblogic28 ~]# chmod -R 777 /backup

[root@weblogic28 ~]# mount -t nfs 10.138.130.29:/u01/app/oracle/oradata/jytest /jytest_data
[root@weblogic28 ~]# mount -t nfs 10.138.130.29:/backup /backup

[root@weblogic28 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 240G 158G 71G 70% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 16G 0 16G 0% /dev/shm
10.138.130.29:/u01/app/oracle/oradata/jytest
240G 22G 206G 10% /jytest_data
10.138.130.29:/backup
240G 22G 206G 10% /backup


2.在源数据库中创建一个表空间jytest与用户jytest
SQL> create tablespace jytest datafile '/u01/app/oracle/oradata/jytest/jytest01.dbf' size 5M autoextend off extent management local segment space management auto;

Tablespace created.

SQL> create user jytest identified by "jytest" default tablespace jytest temporary tablespace temp;

User created.

SQL> grant connect,dba,resource to jytest;

Grant succeeded.

SQL> conn jytest/jytest
Connected.
SQL> create table t1 as select * from dba_tables;

Table created.

SQL> select count(*) from t1;

COUNT(*)
----------
1607
SQL> insert into t1 select * from t1;

1607 rows created.

SQL> insert into t1 select * from t1;

3214 rows created.

SQL> insert into t1 select * from t1;

6428 rows created.

SQL> commit;

Commit complete.


3.将原数据库的jytest表空间设置为只读模式
SQL> alter tablespace jytest read only;

Tablespace altered.


4.对原数据库中的表空间jytest使用rman生成镜像副本并存储在NFS所挂载的/jytest_data目录中
[oracle@weblogic28 ~]$ rman target/

Recovery Manager: Release 10.2.0.5.0 - Production on Wed Apr 13 12:36:05 2016

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

connected to target database: JYTEST (DBID=3911337604)

RMAN> run
2> {
3> allocate channel c1 type disk format '/jytest_data/jytest01.dbf';
4> backup incremental level 1 tag "INCR_JYTEST" for recover of copy with tag "INCR_JYTEST" tablespace jytest;
5> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=157 devtype=DISK

Starting backup at 13-APR-16
WARNING: TAG INCR_JYTEST option is ignored; backups will be tagged with INCR_JYTEST
no parent backup or copy of datafile 8 found
channel c1: starting datafile copy
input datafile fno=00008 name=/u01/app/oracle/oradata/jytest/jytest01.dbf
output filename=/jytest_data/jytest01.dbf tag=INCR_JYTEST recid=2 stamp=909059896
channel c1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 13-APR-16
released channel: c1


虽然这里使用的是incremental level 1,因为这里不存在表空间数据文件jytest01.dbf的0级增量副本,因此会创建一个0级增量副本文件。
SQL> alter tablespace jytest read write;

Tablespace altered.


5.将表空间jytest附加到目标数据库
SQL> create or replace directory test_dump as '/backup/';

Directory created.

SQL> grant read,write on directory test_dump to public;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/eff86780a02c35749be7955f97528067.html