Thursday, March 14, 2013

Migration of Database from Windows to Linux



1. Check platform compatibility between source and target OS

SQL> select * from V$DB_TRANSPORTABLE_PLATFORM where PLATFORM_NAME='Microsoft Windows IA (32-bit)' or PLATFORM_NAME like 'Linux%'
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- --------------------------------------------- --------------
7 Microsoft Windows IA (32-bit) Little
10 Linux IA (32-bit) Little
11 Linux IA (64-bit) Little
13 Linux x86 64-bit Little

2. Start the database in read only mode

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1295608 bytes
Variable Size 71305992 bytes
Database Buffers 88080384 bytes
Redo Buffers 7090176 bytes
Database mounted.

SQL> alter database open read only;
Database altered.

3. Check database readiness for transport from Windows to Linux

SQL> set serveroutput on
SQL> declare
      begin
      db_ready := dbms_tdb.check_db('Linux IA (32-bit)');
end;
      /

PL/SQL procedure successfully completed.

4. Check if there are any external objects. If there is any external objects take note of them, they will need to be taken care manually.

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

The following directories exist in the database:
SYS.DATA_PUMP_DIR, SYS.ADMIN_DIR, SYS.WORK_DIR

PL/SQL procedure successfully completed.


5. Using the RMAN CONVERT DATABASE Command
Having executed successfully the checkup steps, the database is open in read only mode, then the convert database command can be executed with Rman.

RMAN> CONVERT DATABASE NEW DATABASE 'orcllnx' transport script 'D:\oracle\transportscript' to platform 'Linux IA (32-bit)';

Output

Starting convert at 06-MAR-09
using channel ORA_DISK_1

Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.ADMIN_DIR found in the database
Directory SYS.WORK_DIR found in the database

User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00001 name=D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF
converted datafile=D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DATA_D-ORCL_I-12085703
36_TS-SYSTEM_FNO-1_05K98BG5
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00003 name=D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF
converted datafile=D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DATA_D-ORCL_I-12085703
36_TS-SYSAUX_FNO-3_06K98BGU
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00002 name=D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF
converted datafile=D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DATA_D-ORCL_I-12085703
36_TS-UNDOTBS1_FNO-2_07K98BHE
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00004 name=D:\ORACLE\ORADATA\ORCL\USERS01.DBF
converted datafile=D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DATA_D-ORCL_I-12085703
36_TS-USERS_FNO-4_08K98BHH
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Run SQL script D:\ORACLE\TRANSPORTSCRIPT on the target platform to create database
Edit init.ora file D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00K98BG5_1_0.ORA.
 This PFILE will be used to create the database on the target platform
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target plat
form
To change the internal database identifier, use DBNEWID Utility
Finished backup at 06-MAR-09

6. Copy Converted Data files, Generated Transport Script and Parameter File to the Linux

The Transport script will be generated where we mentioned in RMAN command in our case and the data files converted and the pfile will be in Oracle home the database directory

7. Edit init.ora for new database

INIT_00K98BG5_1_0 (This will be the format of the pfile Generated by RMAN, in Linux. Rename to “initorcllnx.ora”).

Parameters to be edited in pfile

  control_files            = "D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\CF_D-ORCLLNX_ID-1208570336_00K98BG5"
  db_recovery_file_dest    = "D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\flash_recovery_area"
  db_recovery_file_dest_size= 2147483648
  audit_file_dest          = "D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\ADUMP"
  background_dump_dest     = "D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\BDUMP"
  user_dump_dest           = "D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UDUMP"
  core_dump_dest           = "D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\CDUMP"
  dispatchers           = '(PROTOCOL=TCP) (SERVICE=orcllnxXDB)'


8. Edit and run Transport Script on Linux

STARTUP NOMOUNT
PFILE='/oradisk/oracle/app/oracle/product/10.2.0/db_1/dbs/initORCLLNX.ORA' (The Location of Pfile)

Provide the location for creating Log files
Provide the location of the converted data files copied from windows
Output of Transport script in Linux

SQL> @transport
SQL> STARTUP NOMOUNT
PFILE='/oradisk/oracle/app/oracle/product/10.2.0/db_1/dbs/initORCLLNX.ora';
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1266368 bytes
Variable Size 71306560 bytes
Database Buffers 88080384 bytes
Redo Buffers 7118848 bytes
SQL> CREATE CONTROLFILE REUSE SET DATABASE "ORCLLNX" RESETLOGS NOARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 SIZE 50M,
9 GROUP 2 SIZE 50M,
10 GROUP 3 SIZE 50M
11 DATAFILE
12 '/oradisk/database/ORCLLNX/O1_MF_SYSTEM_44TM3OPF_.DBF',
13 '/oradisk/database/ORCLLNX/O1_MF_UNDOTBS1_44TM5F98_.DBF',
14 '/oradisk/database/ORCLLNX/O1_MF_SYSAUX_44TM6JTB_.DBF',
15 '/oradisk/database/ORCLLNX/O1_MF_USERS_44TM7BD5_.DBF'
16 CHARACTER SET AL32UTF8
17 ;

Control file created.
SQL>
SQL> -- Database can now be opened zeroing the online logs.
SQL> ALTER DATABASE OPEN RESETLOGS;
Database altered.
SQL>
SQL> -- Commands to add tempfiles to temporary tablespaces.
SQL> -- Online tempfiles have complete space information.
SQL> -- Other tempfiles may require adjustment.
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE
2 SIZE 20971520 AUTOEXTEND ON NEXT 655360 MAXSIZE 33554431M;
Tablespace altered.
SQL> -- End of tempfile additions.
SQL> --
SQL>
SQL> set echo off
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Your database has been created successfully!
* There are many things to think about for the new database. Here
* is a checklist to help you stay on track:
* 1. You may want to redefine the location of the directory objects.
* 2. You may want to change the internal database identifier (DBID)
* or the global database name for this database. Use the
* NEWDBID Utility (nid).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1266368 bytes
Variable Size 71306560 bytes
Database Buffers 88080384 bytes
Redo Buffers 7118848 bytes
Database mounted.
Database opened.

9. Execute UTLIRP and UTLRP Scripts

If you encounter error ORA-01722: invalid number, execute "SHUTDOWN", "STARTUP UPGRADE" and re-execute utlirp.sql

SQL> SELECT TO_NUMBER('MUST_BE_OPEN_UPGRADE') FROM v$instance WHERE status != 'OPEN MIGRATE';
no rows selected

--Rem Store object numbers of all valid PL/SQL-based functional indexes
SQL> DROP TABLE utlirp_enabled_func_indexes;
Table dropped.

SQL> CREATE TABLE utlirp_enabled_func_indexes AS SELECT obj# FROM ind$ WHERE bitand(property, 2048) != 0 AND bitand(flags, 1024) = 0;
Table created.

Check these final lines of the logfile:

PL/SQL procedure successfully completed.
SQL>
SQL> DOC
DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
SQL> select COUNT(*) "OBJECTS WITH ERRORS" from obj$ where status = 3;
OBJECTS WITH ERRORS
-------------------
0
SQL>
SQL>
SQL> DOC
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
SQL> select COUNT(*) "ERRORS DURING RECOMPILATION" from utl_recomp_errors;
ERRORS DURING RECOMPILATION
---------------------------
0
SQL>
SQL>
SQL> Rem =====================================================================
SQL> Rem Run component validation procedure
SQL> Rem =====================================================================
SQL>
SQL> SET serveroutput on
SQL> EXECUTE dbms_registry_sys.validate_components;
PL/SQL procedure successfully completed.
SQL> SET serveroutput off
SQL>
SQL>
SQL> Rem
===========================================================================
SQL> Rem END utlrp.sql
SQL> Rem
===========================================================================
SQL> set feedback 6;


10. Check database integrity

SQL> select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS

Checking component status after transport:
SQL> SELECT COMP_NAME,STATUS FROM DBA_REGISTRY;
COMP_NAME STATUS
-------------------------------------- ------
Oracle XML Database VALID
Oracle Expression Filter VALID
Oracle Rules Manager VALID
Oracle Workspace Manager VALID
Oracle interMedia VALID
Oracle Database Catalog Views VALID
Oracle Database Packages and Types VALID
JServer JAVA Virtual Machine VALID
Oracle XDK VALID
Oracle Database Java Packages VALID

No comments:

Post a Comment