Showing posts with label transport. Show all posts
Showing posts with label transport. Show all posts

Monday, June 9, 2008

Transporting Database

1. Check if the database can be transported to destination platform. Put the DB in read only mode and use DBMS_TDB.CHECK_DB for this. It can be called without arguments to see if any condition at the source database prevents transport. It can also be called with one or both of the following arguments
target_platform_name : The name of the destination platform, as it appears in V$DB_TRANSPORTABLE_PLATFORM.

skip_option : Specifies which, if any, parts of the database to skip when checking whether the database can be transported.
* SKIP_NONE (or 0), which checks all tablespaces
* SKIP_OFFLINE (or 2), which skips checking datafiles in offline tablespaces
* SKIP_READONLY (or 3), which skips checking datafiles in read-only tablespaces

If SERVEROUTPUT is ON, and DBMS_TDB.CHECK_DB returns FALSE, then the output includes the reason why the database cannot be transported.
If you call DBMS_TDB.CHECK_DB and no messages are displayed indicating conditions preventing transport before the PL/SQL procedure successfully completed message, then your database is ready for transport.

set serveroutput on
declare
db_ready boolean;
begin
db_ready := dbms_tdb.check_db('Solaris Operating System (AMD64)',dbms_tdb.skip_readonly);
end;
/


2. Use DBMS_TDB.CHECK_EXTERNAL to identify any external tables, directories or BFILEs. RMAN cannot automate the transport of such files. BMS_TDB.CHECK_EXTERNAL takes no parameters. With SERVEROUTPUT set to ON, the output of DBMS_TDB.CHECK_EXTERNAL lists the external tables, directories and BFILEs of your database.

set serveroutput on
declare
external boolean;
begin
external := dbms_tdb.check_external;
end;
/


3. To convert the database at the source
CONVERT DATABASE NEW DATABASE 'newdb' transport script '/home/oracle/dump/tranport.sql' to platform 'Solaris Operating System (AMD64)' db_file_name_convert '/orace/oradata/test','/home/oracle/dump';

This will generate datafiles at /home/oracle/dump ready for transport, a PFile at $ORACLE_HOME/dbs and a transport.sql used to create the DB at the target.

4. Copy the datafiles, PFile and transport sql file to the target host.

5. At the target edit the pfile to reflect the new directory structure. control_files, *dump_dest, and recovery area are some of the things to consider. If the pfile is renamed from the original system generated name edit the transport sql to reflect the changes.

6. Once all the changes are done set the oracle sid to new DB and run the transport sql

7. At the end of the script DB is created and opened. Towards the end of the script utlirp.sql and utlrp.sql are run. IF utlrp.sql gives out errors then manually open the DB in upgrade mode and run utlirp and utlrp to compile the packages.

8. Create a password file for the database.

9. To generate a new SID for the database use the DBNEWID utility.
nid target=sys/newdb

10. After the new id is generated database is shutdown. open it with resetlogs.
alter database open resetlogs;

11. Create new directory objects in the target
select directory_path from dba_directories;
update dba_directories set directory_path='new path' where directory_path='old path';


Sunday, June 8, 2008

Transporting Tablespaces

1. Select the endian format of source DB and target DB
To list all OS and their endian formats
SELECT * FROM V$TRANSPORTABLE_PLATFORM;

To find the endian format of the target and source DB
SELECT d.PLATFORM_NAME, ENDIAN_FORMAT
FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d
WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME;

If the endian formats are different then datafiles need to be converted to target DB version before transporting.

2. Check if the tablespaces that are transported are self contained with referential integrity constraints taken into consideration (indicated by TRUE).
exec DBMS_TTS.TRANSPORT_SET_CHECK('dumps',TRUE);

Any violations are listed in the TRANSPORT_SET_VIOLATIONS view.
SELECT * FROM TRANSPORT_SET_VIOLATIONS;

If the set of tablespaces is self-contained, this view is empty.

3. Generate a Transportable Tablespace Set with the following steps.

1. put the source tablespaces in read only mode.
alter tablespace dumps read only;

2. Invoke the Data Pump export utility on the host system and specify which tablespaces are in the transportable set.

expdp uname/pw directory=dumpdir dumpfile=tbs.dmp logfile=tbs.log TRANSPORT_TABLESPACES =dumps

3. convert the tablespace for transport using rman if the endian types are different. If compressed backupset is enabled disable it before converting.

convert tablespace dumps to platform 'Linux 64-bit for AMD' format '/home/orace/dump%U';



4. Transport the tablespace set which includes the datafile and the expdp dumpfile to the target DB host.

5. Import the tablespace metadata using impdp
impdp system/testdb directory=dumpdir dumpfile=tbs.dmp logfile=tbs.log TRANSPORT_DATAFILES=/oracle/oradata/test/dump.dbf


6. After the import tablespace will be in read only mode.
select tablespace_name,status from dba_tablespaces;
DUMPS READ ONLY


7. Make the tablespace read write if needed.
alter tablespace dumps read write;



Instead of convert tablespace which does the conversion at the source DB convert datafile can be used to do the conversion at the target DB.

All the steps are similar to above except for the fact the step 3.3 convert tablespace ... is omitted.

Instead after the export copy the datafiles which are in read only mode to the target DB. Before doing the import use datafile convert
convert datafile '/oracle/oradata/test/dump.dbf' from platform 'Solaris Operating System (AMD64)';



Restrictions on CONVERT TABLESPACE and CONVERT DATAFILE

* Both source and destination databases must be running with the COMPATIBLE initialization parameter set to 10.0 or higher.

* Not all combinations of source and destination platforms are supported. To determine whether your source and destination platforms are supported, query V$TRANSPORTABLE_PLATFORM. If both the source and destination platforms are listed in this view, then CONVERT can be used to prepare datafiles from one platform for use on the other.

* A tablespace must be made read-write at least once in release 10g before it can be transported to another platform using CONVERT. Hence, any read-only tablespaces (or previously transported tablespaces) from a previous release must first be made read-write before they can be transported to another platform.

* RMAN does not process user datatypes that require endian conversions.

* Prior to release 10g, CLOBs were created with a variable-width character set and stored in an endian-dependent format. The CONVERT command does not perform conversions on these CLOBs. Instead, RMAN captures the endian format of each LOB column and propagates it to the target database. Subsequent reads of this data by the SQL layer interpret the data correctly based upon either endian format, and write the data out in an endian-independent format if the tablespace is writeable.

CLOBs created in Oracle Database Release 10g are stored in character set AL16UTF16, which is platform-independent.