当前位置:Gxlcms > mysql > RMAN传输表空间迁移数据

RMAN传输表空间迁移数据

时间:2021-07-01 10:21:17 帮助过:15人阅读

实验环境: 源数据库:oracle 10g(Release 10.2.0.1.0) 目标数据库:oracle 10g(Release 10.2.0.1.0) 待传输的表空间:TEST 1.在test(默认表空间是TEST)用户下面创建一张test表。 SQL select * from tab; no rows selected SQL create table test (id

实验环境:
源数据库:oracle 10g(Release 10.2.0.1.0)
目标数据库:oracle 10g(Release 10.2.0.1.0)
待传输的表空间:TEST
1.在test(默认表空间是TEST)用户下面创建一张test表。
SQL> select * from tab;

no rows selected

SQL> create table test (id int primary key)
2 ;

Table created.

SQL> insert into test values(1);

1 row created.

SQL> insert into test values(2);

1 row created.

SQL> insert into test values(3);

1 row created.

SQL> show user;
USER is "TEST"
SQL> commit;

Commit complete.
在传输之前:
(1)确认平台是否支持:若是不同平台需要检查平台版本及Endian Format。
SQL> exec DBMS_TTS.TRANSPORT_SET_CHECK('test',true);
BEGIN DBMS_TTS.TRANSPORT_SET_CHECK('test',true); END;

*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_TTS.TRANSPORT_SET_CHECK' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored


SQL> conn sys/oracle as sysdba
Connected.
SQL> exec DBMS_TTS.TRANSPORT_SET_CHECK('test',true);

PL/SQL procedure successfully completed.

SQL> select * from transport_set_violations;

no rows selected
严格方式验证:
SQL> exec DBMS_TTS.TRANSPORT_SET_CHECK('test',true,true);

PL/SQL procedure successfully completed.

SQL> select * from transport_set_violations;

no rows selected

3.
(1)
SQL> conn test/oracle
Connected.

SQL> select username,default_tablespace from user_users;

USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
TEST TEST

SQL> conn sys/oracle as sysdba
Connected.
SQL> alter tablespace test read only;

Tablespace altered.
(2)
[oracle@linux5 dpdump]$ expdp system/oracle dumpfile=test.dmp directory=data_pump_dir transport_tablespaces=test nologfile=y

Export: Release 10.2.0.1.0 - Production on Sunday, 13 April, 2014 20:01:58

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01": system/******** dumpfile=test.dmp directory=data_pump_dir transport_tablespaces=test nologfile=y
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TRANSPORTABLE_01 is:
/u01/app/oracle/10.2.0/db_1/rdbms/log/test.dmp
Job "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 20:03:05
[oracle@linux5 dpdump]$ cd /u01/app/oracle/10.2.0/db_1/rdbms/log
[oracle@linux5 log]$ ls
dp.log test.dmp
(3)
4.
SQL> select * from dba_directories where directory_name='DUMP_DIR';

OWNER DIRECTORY_NAME
------------------------------ ------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
SYS DUMP_DIR
/u01/dmp

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS ONLINE
EXAMPLE ONLINE
RMANTBS ONLINE
TEST READ ONLY

8 rows selected.

SQL> alter tablespace test read write;

Tablespace altered.

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS ONLINE
EXAMPLE ONLINE
RMANTBS ONLINE
TEST ONLINE

8 rows selected.

5.
SQL> select block_size from dba_tablespaces where tablespace_name='TEST';

BLOCK_SIZE
----------
8192

SQL> show parameter BLOCK_SIZE

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_block_size integer 8192
[oracle@localhost orclstd]$ scp oracle@192.168.1.222:/u01/app/oracle/oradata/orcl/test.dbf /u01/dmp
oracle@192.168.1.222's password:
test.dbf 100% 50MB 5.6MB/s 00:09
[oracle@localhost orclstd]$ impdp test/oracle dumpfile=test.dmp directory=dump_dir nologfile=y transport_datafiles=/u01/dmp/test.dbf remap_schema=test:test

Import: Release 10.2.0.1.0 - Production on Sunday, 13 April, 2014 20:36:05

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "TEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Starting "TEST"."SYS_IMPORT_TRANSPORTABLE_01": test/******** dumpfile=test.dmp directory=dump_dir nologfile=y transport_datafiles=/u01/dmp/test.dbf remap_schema=test:test
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
ORA-39123: Data Pump transportable tablespace job aborted
ORA-19721: Cannot find datafile with absolute file number 7 in tablespace TEST

Job "TEST"."SYS_IMPORT_TRANSPORTABLE_01" stopped due to fatal error at 20:38:33


返回查看:
SQL> select file_name,tablespace_name from dba_data_files where tablespace_name='TEST';

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
/u01/app/oracle/oradata/orcl/tests.dbf
TEST

看来是拷贝错了数据文件,重头再来:
SQL> alter tablespace test read only;

Tablespace altered.
[oracle@linux5 orcl]$ expdp system/oracle dumpfile=test.dmp directory=dump_file_dir transport_tablespaces=test nologfile=y

Export: Release 10.2.0.1.0 - Production on Monday, 14 April, 2014 1:27:00

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01": system/******** dumpfile=test.dmp directory=dump_file_dir transport_tablespaces=test nologfile=y
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TRANSPORTABLE_01 is:
/u01/imp_exp/dmp/test.dmp
Job "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 01:27:26
[oracle@localhost dmp]$ scp oracle@192.168.1.222:/u01/imp_exp/dmp/test.dmp /u01/dmp
oracle@192.168.1.222's password:
test.dmp 100% 64KB 64.0KB/s 00:01
[oracle@localhost dmp]$ scp oracle@192.168.1.222:/u01/app/oracle/oradata/orcl/tests.dbf /u01/dmp
oracle@192.168.1.222's password:
tests.dbf 100% 50MB 2.1MB/s 00:24
SQL> alter tablespace test read write;

Tablespace altered.
应该没问题可以……
[oracle@localhost dmp]$ impdp test/oracle dumpfile=test.dmp directory=dump_dir nologfile=y transport_datafiles=/u01/dmp/tests.dbf

Import: Release 10.2.0.1.0 - Production on Monday, 14 April, 2014 1:33:15

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "TEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Starting "TEST"."SYS_IMPORT_TRANSPORTABLE_01": test/******** dumpfile=test.dmp directory=dump_dir nologfile=y transport_datafiles=/u01/dmp/tests.dbf
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "TEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 01:33:53
SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS ONLINE
EXAMPLE ONLINE
RMANTBS ONLINE
TEST READ ONLY

8 rows selected.

SQL> alter tablespace test read write;

Tablespace altered.

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS ONLINE
EXAMPLE ONLINE
RMANTBS ONLINE
TEST ONLINE

8 rows selected.
OK :::::::::::::::

SQL> conn test/oracle
Connected.
SQL> select * from tab;

TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
TEST TABLE

SQL> select * from test;

ID
----------
1
2
3
RMAN::::::::::::::::::::::
有效的全库备份:
1.
RMAN> backup database format '/u01/full_back/orcl_full_bak';

Starting backup at 14-APR-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00006 name=/u01/rec_catalog/rmantbs.dbf
input datafile fno=00007 name=/u01/app/oracle/oradata/orcl/tests.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 14-APR-14
channel ORA_DISK_1: finished piece 1 at 14-APR-14
piece handle=/u01/full_back/orcl_full_bak tag=TAG20140414T180413 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:38
Finished backup at 14-APR-14

Starting Control File and SPFILE Autobackup at 14-APR-14
piece handle=/u01/scripts/controlfile_c-1368292794-20140414-08 comment=NONE
Finished Control File and SPFILE Autobackup at 14-APR-14
2.
SQL> conn test
Enter password:
Connected.
SQL> select username,default_tablespace from user_users;

USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
TEST TEST
3.RMAN> TRANSPORT TABLESPACE TEST tablespace destination '/u01/tts_test/td' auxiliary destination '/u01/tts_test/ad';

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "test": expecting one of: "double-quoted-string, identifier, single-quoted-string"
RMAN-01007: at line 1 column 22 file: standard input

RMAN> TRANSPORT TABLESPACE "TEST" tablespace destination '/u01/tts_test/td' auxiliary destination '/u01/tts_test/ad';

RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time

List of tablespaces expected to have UNDO segments
tablespace SYSTEM
tablespace UNDOTBS1

Creating automatic instance, with SID='wmoB'

initialization parameters used for automatic instance:
db_name=ORCL
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_ORCL_wmoB
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=/u01/tts_test/ad
control_files=/u01/tts_test/ad/cntrl_tspitr_ORCL_wmoB.f


starting up automatic instance ORCL

Oracle instance started

Total System Global Area 201326592 bytes
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of tranport tablespace command at 04/14/2014 18:13:52
RMAN-06136: ORACLE error from auxiliary database: ORA-02122: Message 2122 not found; product=RDBMS; facility=ORA

ORA-16009: remote archive log destination must be a STANDBY database
Mon Apr 14 20:17:34 2014
PING[ARC1]: Heartbeat failed to connect to standby 'orcls_192.168.1.223'. Error is 16009.


****************************************************************************************************************************
RMAN> transport tablespace example
2> tablespace destination '/u01/td'
3> auxiliary destination '/u01/ad';

using target database control file instead of recovery catalog
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time

List of tablespaces expected to have UNDO segments
tablespace SYSTEM
tablespace UNDOTBS1

Creating automatic instance, with SID='osxd'

initialization parameters used for automatic instance:
db_name=ORCLLDG
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_ORCLLDG_osxd
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=/u01/ad
control_files=/u01/ad/cntrl_tspitr_ORCLLDG_osxd.f


starting up automatic instance ORCLLDG

Oracle instance started

Total System Global Area 201326592 bytes

Fixed Size 1218508 bytes
Variable Size 146802740 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
Automatic instance created

contents of Memory Script:
{
# set the until clause
set until scn 1441931;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log for tspitr to a resent until time
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script

executing command: SET until clause

Starting restore at 14-APR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=37 devtype=DISK

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/scripts/controlfile_c-939793073-20140414-08
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/scripts/controlfile_c-939793073-20140414-08 tag=TAG20140414T204122
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/ad/cntrl_tspitr_ORCLLDG_osxd.f
Finished restore at 14-APR-14

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
released channel: ORA_AUX_DISK_1

contents of Memory Script:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until scn 1441931;
# set an omf destination filename for restore
set newname for clone datafile 1 to new;
# set an omf destination filename for restore
set newname for clone datafile 2 to new;
# set an omf destination filename for restore
set newname for clone datafile 3 to new;
# set an omf destination tempfile
set newname for clone tempfile 1 to new;
# set a destination filename for restore
set newname for datafile 5 to
"/u01/td/example01.dbf";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile 1, 2, 3, 5;
switch clone datafile all;
#online the datafiles restored or flipped
sql clone "alter database datafile 1 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 2 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 3 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 5 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace "EXAMPLE", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
# PLUG HERE the creation of a temporary tablespace if export fails due to lack
# of temporary space.
# For example in Unix these two lines would do that:
#sql clone "create tablespace aux_tspitr_tmp
# datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K";
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed temporary file 1 to /u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 14-APR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=40 devtype=DISK

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_system_%u_.dbf
restoring datafile 00002 to /u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_undotbs1_%u_.dbf
restoring datafile 00003 to /u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_sysaux_%u_.dbf
restoring datafile 00005 to /u01/td/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCLLDG/backupset/2014_04_14/o1_mf_nnndf_TAG20140414T200614_9ns8k7rm_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCLLDG/backupset/2014_04_14/o1_mf_nnndf_TAG20140414T200614_9ns8k7rm_.bkp tag=TAG20140414T200614
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:10
Finished restore at 14-APR-14

datafile 1 switched to datafile copy
input datafile copy recid=5 stamp=844894555 filename=/u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_system_9nscb9cf_.dbf
datafile 2 switched to datafile copy
input datafile copy recid=6 stamp=844894557 filename=/u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_undotbs1_9nscb9kv_.dbf
datafile 3 switched to datafile copy
input datafile copy recid=7 stamp=844894557 filename=/u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_sysaux_9nscb9ft_.dbf
datafile 5 switched to datafile copy
input datafile copy recid=8 stamp=844894558 filename=/u01/td/example01.dbf

sql statement: alter database datafile 1 online

sql statement: alter database datafile 2 online

sql statement: alter database datafile 3 online

sql statement: alter database datafile 5 online

Starting recover at 14-APR-14
using channel ORA_AUX_DISK_1

starting media recovery

archive log thread 1 sequence 17 is already on disk as file /u01/arch_ldg/archive_1_17_843071181.arclog
archive log thread 1 sequence 18 is already on disk as file /u01/arch_ldg/archive_1_18_843071181.arclog
archive log filename=/u01/arch_ldg/archive_1_17_843071181.arclog thread=1 sequence=17
archive log filename=/u01/arch_ldg/archive_1_18_843071181.arclog thread=1 sequence=18
media recovery complete, elapsed time: 00:00:05
Finished recover at 14-APR-14

database opened

contents of Memory Script:
{
#mark read only the tablespace that will be exported
sql clone "alter tablespace EXAMPLE read only";
# create directory for datapump export
sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as ''
/u01/td''";
# export the tablespaces in the recovery set
host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db_1/bin/oracle\)\(ARGV0=oracleosxd\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=osxd^'\)\)\(CONNECT_DATA=\(SID=osxd\)\)\) as sysdba\" transport_tablespaces=
EXAMPLE dumpfile=
dmpfile.dmp directory=
STREAMS_DIROBJ_DPDIR logfile=
explog.log';
}
executing Memory Script

sql statement: alter tablespace EXAMPLE read only

sql statement: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u01/td''


Export: Release 10.2.0.1.0 - Production on Monday, 14 April, 2014 20:56:52

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u01/app/oracle/10.2.0/db_1/bin/oracle)(ARGV0=oracleosxd)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=osxd))(CONNECT_DATA=(SID=osxd))) AS SYSDBA" transport_tablespaces= EXAMPLE dumpfile=dmpfile.dmp directory=STREAMS_DIROBJ_DPDIR logfile=explog.log
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TYPE/TYPE_SPEC
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TRANSPORTABLE_EXPORT/INDEX
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/COMMENT
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/TRIGGER
Processing object type TRANSPORTABLE_EXPORT/INDEX/FUNCTIONAL_AND_BITMAP/INDEX
Processing object type TRANSPORTABLE_EXPORT/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/DOMAIN_INDEX/INDEX
Processing object type TRANSPORTABLE_EXPORT/MATERIALIZED_VIEW
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PROCACT_INSTANCE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PROCDEPOBJ
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is:
/u01/td/dmpfile.dmp
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 20:58:18

host command complete
/*
The following command may be used to import the tablespaces.
Substitute values for and .
impdp directory= dumpfile= 'dmpfile.dmp' transport_datafiles= /u01/td/example01.dbf
*/
--------------------------------------------------------------
-- Start of sample PL/SQL script for importing the tablespaces
--------------------------------------------------------------
-- creating directory objects
CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u01/td/';
CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS '/u01/td';
/* PL/SQL Script to import the exported tablespaces */
DECLARE
-- the datafiles
tbs_files dbms_streams_tablespace_adm.file_set;
cvt_files dbms_streams_tablespace_adm.file_set;
-- the dumpfile to import
dump_file dbms_streams_tablespace_adm.file;
dp_job_name VARCHAR2(30) := NULL;
-- names of tablespaces that were imported
ts_names dbms_streams_tablespace_adm.tablespace_set;
BEGIN
-- dump file name and location
dump_file.file_name := 'dmpfile.dmp';
dump_file.directory_object := 'STREAMS$DIROBJ$DPDIR';
-- forming list of datafiles for import
tbs_files( 1).file_name := 'example01.dbf';
tbs_files( 1).directory_object := 'STREAMS$DIROBJ$1';
-- import tablespaces
dbms_streams_tablespace_adm.attach_tablespaces(
datapump_job_name => dp_job_name,
dump_file => dump_file,
tablespace_files => tbs_files,
converted_files => cvt_files,
tablespace_names => ts_names);
-- output names of imported tablespaces
IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN
FOR i IN ts_names.first .. ts_names.last LOOP
dbms_output.put_line('imported tablespace '|| ts_names(i));
END LOOP;
END IF;
END;
/
-- dropping directory objects
DROP DIRECTORY STREAMS$DIROBJ$1;
DROP DIRECTORY STREAMS$DIROBJ$DPDIR;
--------------------------------------------------------------
-- End of sample PL/SQL script
--------------------------------------------------------------

Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /u01/ad/cntrl_tspitr_ORCLLDG_osxd.f deleted
auxiliary instance file /u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_system_9nscb9cf_.dbf deleted
auxiliary instance file /u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_undotbs1_9nscb9kv_.dbf deleted
auxiliary instance file /u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_sysaux_9nscb9ft_.dbf deleted
auxiliary instance file /u01/ad/TSPITR_ORCLLDG_OSXD/datafile/o1_mf_temp_9nschf73_.tmp deleted
auxiliary instance file /u01/ad/TSPITR_ORCLLDG_OSXD/onlinelog/o1_mf_1_9nscgpy1_.log deleted
auxiliary instance file /u01/ad/TSPITR_ORCLLDG_OSXD/onlinelog/o1_mf_2_9nscgzkl_.log deleted
auxiliary instance file /u01/ad/TSPITR_ORCLLDG_OSXD/onlinelog/o1_mf_3_9nsch314_.log deleted
[oracle@localhost ~]$ cd /u01/td/
[oracle@localhost td]$ ls
dmpfile.dmp example01.dbf explog.log impscrpt.sql
[oracle@localhost td]$ cd ../ad/
[oracle@localhost ad]$ ls
TSPITR_ORCLLDG_OSXD

重新测试: 含有数据文件的备份和有效的归档文件
SQL> show user
USER is "SYS"
SQL> create tablespace TTS
2 datafile '/u01/app/oracle/oradata/orclstd/tts.dbf'
3 size 20m;

Tablespace created.

SQL> alter user test default tablespace TTS;

User altered.

SQL> conn test/oracle
Connected.
SQL> select username,default_tablespace from user_users;

USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
TEST TTS
SQL> create table tts as select * from test;

Table created.

SQL> commit;

Commit complete.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TTS TABLE
TEST TABLE
2.检查备份:
RMAN> configure controlfile autobackup on;

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
备份:
RMAN> backup database;

Starting backup at 14-APR-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orclstd/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orclstd/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orclstd/example01.dbf
input datafile fno=00007 name=/u01/dmp/tests.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orclstd/undotbs01.dbf
input datafile fno=00008 name=/u01/app/oracle/oradata/orclstd/tts.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orclstd/users01.dbf
channel ORA_DISK_1: starting piece 1 at 14-APR-14
channel ORA_DISK_1: finished piece 1 at 14-APR-14
piece handle=/u01/app/oracle/flash_recovery_area/ORCLLDG/backupset/2014_04_14/o1_mf_nnndf_TAG20140414T235610_9nsp0cbd_.bkp tag=TAG20140414T235610 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:06
Finished backup at 14-APR-14

Starting Control File and SPFILE Autobackup at 14-APR-14
piece handle=/u01/scripts/controlfile_c-939793073-20140414-0b comment=NONE
Finished Control File and SPFILE Autobackup at 14-APR-14

生成传输集:
RMAN> transport tablespace tts
2> tablespace destination '/u01/tts/td'
3> auxiliary destination '/u01/tts/ad';

RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time

List of tablespaces expected to have UNDO segments
tablespace SYSTEM
tablespace UNDOTBS1

Creating automatic instance, with SID='gmcj'

initialization parameters used for automatic instance:
db_name=ORCLLDG
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_ORCLLDG_gmcj
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=/u01/tts/ad
control_files=/u01/tts/ad/cntrl_tspitr_ORCLLDG_gmcj.f


starting up automatic instance ORCLLDG

Oracle instance started

Total System Global Area 201326592 bytes

Fixed Size 1218508 bytes
Variable Size 146802740 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
Automatic instance created

contents of Memory Script:
{
# set the until clause
set until scn 1449047;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log for tspitr to a resent until time
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script

executing command: SET until clause

Starting restore at 15-APR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=37 devtype=DISK

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/scripts/controlfile_c-939793073-20140414-0b
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/scripts/controlfile_c-939793073-20140414-0b tag=TAG20140414T235817
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/u01/tts/ad/cntrl_tspitr_ORCLLDG_gmcj.f
Finished restore at 15-APR-14

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
released channel: ORA_DISK_1
released channel: ORA_AUX_DISK_1

contents of Memory Script:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until scn 1449047;
# set an omf destination filename for restore
set newname for clone datafile 1 to new;
# set an omf destination filename for restore
set newname for clone datafile 2 to new;
# set an omf destination filename for restore
set newname for clone datafile 3 to new;
# set an omf destination tempfile
set newname for clone tempfile 1 to new;
# set a destination filename for restore
set newname for datafile 8 to
"/u01/tts/td/tts.dbf";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile 1, 2, 3, 8;
switch clone datafile all;
#online the datafiles restored or flipped
sql clone "alter database datafile 1 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 2 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 3 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 8 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace "TTS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
# PLUG HERE the creation of a temporary tablespace if export fails due to lack
# of temporary space.
# For example in Unix these two lines would do that:
#sql clone "create tablespace aux_tspitr_tmp
# datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K";
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed temporary file 1 to /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 15-APR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=39 devtype=DISK

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_system_%u_.dbf
restoring datafile 00002 to /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_undotbs1_%u_.dbf
restoring datafile 00003 to /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_sysaux_%u_.dbf
restoring datafile 00008 to /u01/tts/td/tts.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCLLDG/backupset/2014_04_14/o1_mf_nnndf_TAG20140414T235610_9nsp0cbd_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCLLDG/backupset/2014_04_14/o1_mf_nnndf_TAG20140414T235610_9nsp0cbd_.bkp tag=TAG20140414T235610
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:20
Finished restore at 15-APR-14

datafile 1 switched to datafile copy
input datafile copy recid=5 stamp=844906379 filename=/u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_system_9nspvcw5_.dbf
datafile 2 switched to datafile copy
input datafile copy recid=6 stamp=844906382 filename=/u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_undotbs1_9nspvd37_.dbf
datafile 3 switched to datafile copy
input datafile copy recid=7 stamp=844906383 filename=/u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_sysaux_9nspvcwv_.dbf
datafile 8 switched to datafile copy
input datafile copy recid=8 stamp=844906384 filename=/u01/tts/td/tts.dbf

sql statement: alter database datafile 1 online

sql statement: alter database datafile 2 online

sql statement: alter database datafile 3 online

sql statement: alter database datafile 8 online

Starting recover at 15-APR-14
using channel ORA_AUX_DISK_1

starting media recovery

archive log thread 1 sequence 21 is already on disk as file /u01/arch_ldg/archive_1_21_843071181.arclog
archive log filename=/u01/arch_ldg/archive_1_21_843071181.arclog thread=1 sequence=21
media recovery complete, elapsed time: 00:00:13
Finished recover at 15-APR-14

database opened

contents of Memory Script:
{
#mark read only the tablespace that will be exported
sql clone "alter tablespace TTS read only";
# create directory for datapump export
sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as ''
/u01/tts/td''";
# export the tablespaces in the recovery set
host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db_1/bin/oracle\)\(ARGV0=oraclegmcj\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=gmcj^'\)\)\(CONNECT_DATA=\(SID=gmcj\)\)\) as sysdba\" transport_tablespaces=
TTS dumpfile=
dmpfile.dmp directory=
STREAMS_DIROBJ_DPDIR logfile=
explog.log';
}
executing Memory Script

sql statement: alter tablespace TTS read only

sql statement: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u01/tts/td''


Export: Release 10.2.0.1.0 - Production on Tuesday, 15 April, 2014 0:14:52

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u01/app/oracle/10.2.0/db_1/bin/oracle)(ARGV0=oraclegmcj)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=gmcj))(CONNECT_DATA=(SID=gmcj))) AS SYSDBA" transport_tablespaces= TTS dumpfile=dmpfile.dmp directory=STREAMS_DIROBJ_DPDIR logfile=explog.log
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is:
/u01/tts/td/dmpfile.dmp
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 00:16:18

host command complete
/*
The following command may be used to import the tablespaces.
Substitute values for and .
impdp directory= dumpfile= 'dmpfile.dmp' transport_datafiles= /u01/tts/td/tts.dbf
*/
--------------------------------------------------------------
-- Start of sample PL/SQL script for importing the tablespaces
--------------------------------------------------------------
-- creating directory objects
CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u01/tts/td/';
CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS '/u01/tts/td';
/* PL/SQL Script to import the exported tablespaces */
DECLARE
-- the datafiles
tbs_files dbms_streams_tablespace_adm.file_set;
cvt_files dbms_streams_tablespace_adm.file_set;
-- the dumpfile to import
dump_file dbms_streams_tablespace_adm.file;
dp_job_name VARCHAR2(30) := NULL;
-- names of tablespaces that were imported
ts_names dbms_streams_tablespace_adm.tablespace_set;
BEGIN
-- dump file name and location
dump_file.file_name := 'dmpfile.dmp';
dump_file.directory_object := 'STREAMS$DIROBJ$DPDIR';
-- forming list of datafiles for import
tbs_files( 1).file_name := 'tts.dbf';
tbs_files( 1).directory_object := 'STREAMS$DIROBJ$1';
-- import tablespaces
dbms_streams_tablespace_adm.attach_tablespaces(
datapump_job_name => dp_job_name,
dump_file => dump_file,
tablespace_files => tbs_files,
converted_files => cvt_files,
tablespace_names => ts_names);
-- output names of imported tablespaces
IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN
FOR i IN ts_names.first .. ts_names.last LOOP
dbms_output.put_line('imported tablespace '|| ts_names(i));
END LOOP;
END IF;
END;
/
-- dropping directory objects
DROP DIRECTORY STREAMS$DIROBJ$1;
DROP DIRECTORY STREAMS$DIROBJ$DPDIR;
--------------------------------------------------------------
-- End of sample PL/SQL script
--------------------------------------------------------------

Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /u01/tts/ad/cntrl_tspitr_ORCLLDG_gmcj.f deleted
auxiliary instance file /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_system_9nspvcw5_.dbf deleted
auxiliary instance file /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_undotbs1_9nspvd37_.dbf deleted
auxiliary instance file /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_sysaux_9nspvcwv_.dbf deleted
auxiliary instance file /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/datafile/o1_mf_temp_9nsq2hbj_.tmp deleted
auxiliary instance file /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/onlinelog/o1_mf_1_9nsq1cmc_.log deleted
auxiliary instance file /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/onlinelog/o1_mf_2_9nsq1fq2_.log deleted
auxiliary instance file /u01/tts/ad/TSPITR_ORCLLDG_GMCJ/onlinelog/o1_mf_3_9nsq1jsw_.log deleted
[oracle@localhost ad]$ ls
TSPITR_ORCLLDG_GMCJ
[oracle@localhost ad]$ cd ..
[oracle@localhost tts]$ cd td/
[oracle@localhost td]$ ls
dmpfile.dmp explog.log impscrpt.sql tts.dbf

拷贝dmp文件和dbf数据文件:
[oracle@linux5 tts_test]$ scp oracle@192.168.1.223:/u01/tts/td/tts.dbf /u01/tts_test/tts.dbf
oracle@192.168.1.223's password:
tts.dbf 100% 20MB 4.0MB/s 00:05
[oracle@linux5 tts_test]$ scp oracle@192.168.1.223:/u01/tts/td/dmpfile.dmp /u01/tts_test/
oracle@192.168.1.223's password:
dmpfile.dmp 100% 68KB 68.0KB/s 00:00
导入:
SQL> select * from tab;

no rows selected

SQL> show user
USER is "TEST"
[oracle@linux5 dmp]$ impdp system/oracle dumpfile=dmpfile.dmp directory=DUMP_FILE_DIR nologfile=y transport_datafiles=/u01/tts_test/tts.dbf remap_schema=test:test

Import: Release 10.2.0.1.0 - Production on Tuesday, 15 April, 2014 1:05:34

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** dumpfile=dmpfile.dmp directory=DUMP_FILE_DIR nologfile=y transport_datafiles=/u01/tts_test/tts.dbf remap_schema=test:test
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 01:05:42
SQL> select * from tab;

TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TTS TABLE
检查貌似少了一张表,然后回忆以前做实验好像test默认表空间是test,后来改为了tts,传输的时候传的是默认表空间(只传输TTS)。
查看源数据库:
SQL> select table_name,tablespace_name from user_tables;

TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
TTS TTS
TEST TEST
SQL> select username,default_tablespace from user_users;

USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
TEST TTS


目标数据库:
SQL> select table_name,tablespace_name from user_tables;

TABLE_NAME TABLESPACE_NAME
------------------------------ -----------------------------
TTS TTS
把导入的表空间状态更改为READ WRITE

人气教程排行