Use RMAN Incremental backup to update the transmitted tablespace

Source: Internet
Author: User

Use RMAN Incremental backup to update the transmitted tablespace

To use RMAN Incremental backup to update the transmitted tablespace, you need to understand the Incremental backup of the transmitted tablespace and RMAN. Here we will mainly introduce how to use Incremental backup to update the transmitted tablespace. We will not introduce the transmission tablespace and RMAN Incremental backup. The following describes how to use RMAN Incremental backup to update the tablespace for transmission. The target host is weblogic29, and the original host is weblogic28.

1. Configure NFS on two database servers
Configure/etc/exports
The directories and permissions that nfs allows to be mounted must be defined in the file/etc/exports. For example
/U01/app/Oracle/oradata/jytest/is shared with the/backup directory. Edit the/etc/exports file and append two lines.
/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)


Start nfs service
[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]


Mount the shared directory on the client host
[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]


Use showmount-e IP address on the client to view nfs host sharing information:
[Root @ weblogic28 ~] # Showmount-e 10.138.130.29
Export list for 10.138.130.29:
/Backup *
/U01/app/oracle/oradata/jytest *


Create an NFS folder on the client and run the mount command:
[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

[Root @ weblogic28 ~] # Df-h
Filesystem Size Used Avail Use % Mounted on
/Dev/sda3 240G 158G 71G 70%/
/Dev/sda1 190 M 12 M 169 M 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. Create a tablespace jytest and user jytest in the source database.
SQL> create tablespace jytest datafile '/u01/app/oracle/oradata/jytest/jytest01.dbf' size 5 M 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. Set the jytest tablespace of the original database to read-only.
SQL> alter tablespace jytest read only;

Tablespace altered.


4. Use rman to generate an image copy of The tablespace jytest in the original database and store it in the/jytest_data directory mounted to NFS.
[Oracle @ weblogic28 ~] $ Rman target/

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

Copyright (c) 1982,200 7, 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


Although incremental level 1 is used here, because there is no level 0 incremental copy of The tablespace data file jytest01.dbf, a level 0 incremental copy file will be created.
SQL> alter tablespace jytest read write;

Tablespace altered.


5. Attach the tablespace jytest to the target database.
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 instances = n transport_datafiles = \ '/u01/app/oracle/oradata/jytest/logs \'

Import: Release 10.2.0.5.0-64bit Production on Wednesday, 13 then l, 2016 14:47:43

Copyright (c) 2003,200 7, 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/Shanghai'
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. Delete the table space jytest from the target database, but keep the data file.
SQL> drop tablespace jytest including contents;

Tablespace dropped.


7. Bring the tablespace jytest in the original database online and continue to insert records to table 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


Because the tablespace jytest has no space, add a data file jytest02.dbf to the tablespace jytest to increase the tablespace.
SQL> alter tablespace jytest add datafile '/u01/app/oracle/oradata/jytest/jytest02.dbf' size 5 M;

Tablespace altered.

SQL> insert into t1 select * from t1;

12856 rows created.

SQL> commit;

Commit complete.

SQL> select count (*) from t1;

COUNT (*)
----------
25712


8. If a new data file is added to the original database tablespace jytest after the last Incremental backup, run the following command to create an image copy for the newly added data file.
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. Perform incremental RMAN backup for the original database and merge the data files in the target database file directory.
New data file
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 canceled 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. re-attach the tablespace jytest to the target database.
[Oracle @ weblogic29 jytest] $ impdp jytest/jytest directory = test_dump network_link = dblink_jytest transport_tablespaces = jytest instances = n transport_datafiles = \ '/u01/app/oracle/oradata/jytest/logs \ ', \ '/u01/app/oracle/oradata/jytest/jytest02.dbf \'

Import: Release 10.2.0.5.0-64bit Production on Wednesday, 13 then l, 2016 15:50:37

Copyright (c) 2003,200 7, 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/Shanghai ', '/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.


The same as the number of table t1 records in the original database, it indicates that the incremental update of the transferred tablespace is successful.

Summary: it takes less time to update a data file before using Incremental backup than to copy the entire data file. NFS is used to transmit data files, avoiding file transmission through ftp and other methods. impdp network_link avoids importing and exporting metadata and transmitting metadata, which also saves time.

-------------------------------------- Recommended reading --------------------------------------

ORA-19571 for RMAN backup

RMAN: Configure an archive log deletion policy

Basic Oracle tutorial-copying a database through RMAN

Reference for RMAN backup policy formulation

RMAN backup learning notes

Oracle Database Backup encryption RMAN Encryption

ORA-19588 encountered during RMAN backup

-------------------------------------- Split line --------------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.