新聞中心
要使用RMAN增量備份來更新傳輸表空間需要了解傳輸表空間與RMAN的增量備份。這里主要介紹使用增量備份來更新傳輸表空間,就不介紹傳輸表空間與RMAN增量備份。下面是使用RMAN增量備份來更新傳輸表空間的操作。目標(biāo)主機是weblogic29,原主機是weblogic28。

在揭西等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都做網(wǎng)站、成都網(wǎng)站制作 網(wǎng)站設(shè)計制作按需搭建網(wǎng)站,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計,成都全網(wǎng)營銷,成都外貿(mào)網(wǎng)站建設(shè)公司,揭西網(wǎng)站建設(shè)費用合理。
1.在兩臺數(shù)據(jù)庫服務(wù)器上配置NFS
配置/etc/exports
nfs允許掛載的目錄及權(quán)限需在文件/etc/exports中進行定義。例如,我們要將數(shù)據(jù)文件所在目錄
/u01/app/[Oracle](https://www.linuxidc.com/topicnews.aspx?tid=12)/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服務(wù)
[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文件夾并執(zhí)行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.在源數(shù)據(jù)庫中創(chuàng)建一個表空間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.將原數(shù)據(jù)庫的jytest表空間設(shè)置為只讀模式
SQL> alter tablespace jytest read only;
Tablespace altered.
4.對原數(shù)據(jù)庫中的表空間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,因為這里不存在表空間數(shù)據(jù)文件jytest01.dbf的0級增量副本,因此會創(chuàng)建一個0級增量副本文件。
SQL> alter tablespace jytest read write;
Tablespace altered.
5.將表空間jytest附加到目標(biāo)數(shù)據(jù)庫
SQL> create or replace directory test_dump as '/backup/';
Directory created.
SQL> grant read,write on directory test_dump to public;
Grant succeeded.
' SQL> create public database link dblink_jytest 2 connect to jytest identified by "jytest" 3 using '(DESCRIPTION =
4 (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.28)(PORT = 1521))
5 (CONNECT_DATA =
6 (SERVICE_NAME = jytest)
7 )
8 )'; Database link created. SQL> select count(*) from t1@dblink_jytest; COUNT(*) \---------- 12856 [oracle@weblogic29 jytest]$ impdp jytest/jytest directory=test_dump network_link=dblink_jytest transport_tablespaces=jytest transport_full_check=n transport_datafiles=\'/u01/app/oracle/oradata/jytest/jytest01.dbf\' Import: Release 10.2.0.5.0 - 64bit Production on Wednesday, 13 April, 2016 14:47:43 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "JYTEST"."SYS_IMPORT_TRANSPORTABLE_01": jytest/******** directory=test_dump network_link=dblink_jytest transport_tablespaces=jytest transport_full_check=n transport_datafiles='/u01/app/oracle/oradata/jytest/jytest01.dbf' Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "JYTEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 14:47:48 SQL> show parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 10.2.0.3.0 SQL> select count(*) from jytest.t1; COUNT(*) \---------- 12856
6.將表空間jytest從目標(biāo)數(shù)據(jù)庫中刪除,但保留數(shù)據(jù)文件
SQL> drop tablespace jytest including contents;
Tablespace dropped.
7.將原數(shù)據(jù)庫中的表空間jytest聯(lián)機,繼續(xù)向表t1插入記錄
SQL> alter tablespace jytest read write;
Tablespace altered.
SQL> insert into t1 select * from t1;
insert into t1 select * from t1
*
ERROR at line 1:
ORA-01653: unable to extend table JYTEST.T1 by 128 in tablespace JYTEST
由于表空間jytest沒有空間了,如是向表這僮jytest增加一個數(shù)據(jù)文件jytest02.dbf來增加表空間
SQL> alter tablespace jytest add datafile '/u01/app/oracle/oradata/jytest/jytest02.dbf' size 5M;
Tablespace altered.
SQL> insert into t1 select * from t1;
12856 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from t1;
COUNT(*)
\----------
25712
8.如果自上次增量備份以后原數(shù)據(jù)庫表空間jytest增加了新的數(shù)據(jù)文件,因此執(zhí)行以下命令來為新增加的數(shù)據(jù)文件創(chuàng)建鏡像副本。
SQL> alter tablespace jytest read only;
Tablespace altered.
SQL> select file#,name from v$datafile;
FILE# NAME
---------- -------------------------------------------------------------------------
1 /u01/app/oracle/oradata/jytest/system01.dbf
2 /u01/app/oracle/oradata/jytest/undotbs01.dbf
3 /u01/app/oracle/oradata/jytest/sysaux01.dbf
4 /u01/app/oracle/oradata/jytest/users01.dbf
5 /u01/app/oracle/oradata/jytest/example01.dbf
6 /u01/app/oracle/oradata/jytest/tspitr01.dbf
7 /u01/app/oracle/oradata/jytest/test01.dbf
8 /u01/app/oracle/oradata/jytest/jytest01.dbf
9 /u01/app/oracle/oradata/jytest/jytest02.dbf
9 rows selected.
RMAN> run
2> {
3> allocate channel c1 type disk format '/jytest_data/jytest02.dbf';
4> backup incremental level 1 tag "INCR_JYTEST" for recover of copy with tag "INCR_JYTEST" datafile 9;
5> }
allocated channel: c1
channel c1: sid=141 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 9 found
channel c1: starting datafile copy
input datafile fno=00009 name=/u01/app/oracle/oradata/jytest/jytest02.dbf
output filename=/jytest_data/jytest02.dbf tag=INCR_JYTEST recid=4 stamp=909069392
channel c1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 13-APR-16
released channel: c1
9.對原數(shù)據(jù)庫執(zhí)行RMAN增量備份并使用目標(biāo)數(shù)據(jù)庫文件目錄中的數(shù)據(jù)文件與其合并,因些創(chuàng)建一組 新的數(shù)據(jù)文件
RMAN> run
2> {
3> allocate channel c1 type disk format '/jytest_data/jytest01_%t.dbf';
4> allocate channel c2 type disk format '/jytest_data/jytest02_%t.dbf';
5> backup incremental level 1 tag "INCR_JYTEST" for recover of copy with tag "INCR_JYTEST" tablespace jytest;
6> recover copy of tablespace jytest with tag "INCR_JYTEST";
7> }
allocated channel: c1
channel c1: sid=141 devtype=DISK
allocated channel: c2
channel c2: sid=139 devtype=DISK
Starting backup at 13-APR-16
WARNING: TAG INCR_JYTEST option is ignored; backups will be tagged with INCR_JYTEST
channel c1: starting incremental level 1 datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00008 name=/u01/app/oracle/oradata/jytest/jytest01.dbf
channel c1: starting piece 1 at 13-APR-16
channel c2: starting incremental level 1 datafile backupset
channel c2: specifying datafile(s) in backupset
input datafile fno=00009 name=/u01/app/oracle/oradata/jytest/jytest02.dbf
skipping datafile 00009 because it has not changed
channel c2: backup cancelled because all files were skipped
channel c1: finished piece 1 at 13-APR-16
piece handle=/jytest_data/jytest01_909069660.dbf tag=INCR_JYTEST comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-APR-16
Starting recover at 13-APR-16
channel c1: starting incremental datafile backupset restore
channel c1: specifying datafile copies to recover
recovering datafile copy fno=00008 name=/jytest_data/jytest01.dbf
channel c1: reading from backup piece /jytest_data/jytest01_909069660.dbf
channel c1: restored backup piece 1
piece handle=/jytest_data/jytest01_909069660.dbf tag=INCR_JYTEST
channel c1: restore complete, elapsed time: 00:00:02
Finished recover at 13-APR-16
released channel: c1
released channel: c2
10.將表空間jytest重新附加到目標(biāo)數(shù)據(jù)庫中
[oracle@weblogic29 jytest]$ impdp jytest/jytest directory=test_dump network_link=dblink_jytest transport_tablespaces=jytest transport_full_check=n transport_datafiles=\'/u01/app/oracle/oradata/jytest/jytest01.dbf\',\'/u01/app/oracle/oradata/jytest/jytest02.dbf\'
Import: Release 10.2.0.5.0 - 64bit Production on Wednesday, 13 April, 2016 15:50:37
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "JYTEST"."SYS_IMPORT_TRANSPORTABLE_01": jytest/******** directory=test_dump network_link=dblink_jytest transport_tablespaces=jytest transport_full_check=n transport_datafiles='/u01/app/oracle/oradata/jytest/jytest01.dbf','/u01/app/oracle/oradata/jytest/jytest02.dbf'
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "JYTEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 15:50:42
SQL> select count(*) from jytest.t1;
COUNT(*)
\----------
25712
SQL> alter tablespace jytest read write;
Tablespace altered.
與原數(shù)據(jù)庫中表t1記錄數(shù)一樣,說明增量更新傳輸表空間成功。
總結(jié):使用增量備份來前更新數(shù)據(jù)文件要比復(fù)制整個數(shù)據(jù)文件所花的時間少。這里使用了NFS來執(zhí)行數(shù)據(jù)文件的傳輸避免了使用ftp等方式傳輸文件,使用impdp network_link避免了導(dǎo)入和導(dǎo)出元數(shù)據(jù)與傳輸元數(shù)據(jù)這也能節(jié)省了時間。
新聞標(biāo)題:通過RMAN增量備份來更新傳輸表空間
分享地址:http://fisionsoft.com.cn/article/cooosei.html


咨詢
建站咨詢
