Wednesday 24 February 2016

Migrate oracle 11.2.0.1.0(Windows 32-bit) TO linux (64-bit);

Migrate oracle 11.2.0.1.0(Windows 32-bit) TO linux (64-bit);

Source: Windows 32-bit

Target Linux 64-bit

Small guide what I am going to do:

Steps:
1. Check platform compatibility between Source and target OS
2. Start the database in read only mode
3. Check database readiness for transport from Windows to Linux using DBMS_TDB.CHECK_DB
4. Check if there are any external objects
5. Execute the RMAN Convert database command
6. Copy Converted datafiles, Generated Script and Pfile to Linux
7. Edit the Pfile for the new database (Linux)
8. Edit the Transport Script and Pfile changing the windows paths to Linux Paths.
9. Execute the Transport Script on Linux
10. Change the DBID
11. Run utlirp.sql and utlrp.sql for recompile all Pl/SQL modules.
12. Verify & Compare the database on Linux

Source:
Step 1:
====

SQL> Select * from v$transportable_platform order by platform_id;

Here both will (Windows and Linux endian format is little only)
Check the Version of database:
SQL> select * from v$version;
SQL> Select * from v$transportable_platform order by platform_id;
Check the Version of database:
SQL> Select * from v$transportable_platform order by platform_id;
Check the Version of database:
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 – Production

Note: Kindly check it Target server pre-requesite install software only




Step 2:

2. Start the database in read only mode

> shut immediate;
>startup mount;

> alter database open read only;



Step 3:

3. Check database readiness for transport from Windows to Linux using DBMS_TDB.CHECK_DB

Note:
Before converting the database, we have to be make sure that whether a database can be transported to a desired destination platform, and whether the current state of the database permits transport. We check this using "DBMS_TDB.CHECK_DB" procedure.
If this procedure returns "FALSE" then the output includes the reason why the database cannot be transported like target platform has a different endian format, database is not open read-only, there are active transactions in the database, database compatibility version is below 10 etc.

set serveroutput on
declare
db_ready boolean;
begin
db_ready := dbms_tdb.check_db('Linux x86 64-bit');
end;
/
PL/SQL procedure successfully completed.
Note: If database is not open in read-only mode, then the above procedure may return error like Database is not open READ ONLY. Please open database READ ONLY and retry.

Step 4:

Check if there are any external objects:

Note:

If there is any external objects take note of them, they will need to be taken care manually because RMAN cannot automate the transport of such objects. "DBMS_TDB.CHECK_EXTERNAL" must be used to identify any external tables, directories or BFILEs.

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

The following directories exist in the database:
SYS.ORACLE_OCM_CONFIG_DIR, SYS.DATA_PUMP_DIR, SYS.XMLDIR

Note:

No need to worry its automatically taking when we start using pfile in Target

Step 5

5. Using the RMAN CONVERT DATABASE:
After all the pre-requisites have been performed successfully, we can use the RMAN CONVERT DATABASE command to generate the output files for the target database. While executing the CONVERT DATABASE command, we need to specify the new database name, the destination platform, path to save the transport script and optionally a path, where to save the output files.
Note: If you omit the "DB_FILE_NAME_CONVERT" clause, the output files are created in

"C:\ORACLE_HOME\database" folder.
C:\>rman target /


CONVERT DATABASE NEW DATABASE 'migra'
transport script 'd:\app\mig\script.sql'
to platform 'Linux x86 64-bit'
db_file_name_convert 'D:\app\kumar\oradata\prod500\' 'D:\app\mig\';

output:

Starting conversion at source at 23-JUL-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK

Directory SYS.ORACLE_OCM_CONFIG_DIR found in the database
Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.XMLDIR found in the database

User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00001 name=D:\APP\KUMAR\ORADATA\PROD500\SYSTEM01.DBF
converted datafile=D:\APP\TRANS\SYSTEM01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00002 name=D:\APP\KUMAR\ORADATA\PROD500\SYSAUX01.DBF
converted datafile=D:\APP\TRANS\SYSAUX01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00003 name=D:\APP\KUMAR\ORADATA\PROD500\UNDOTBS01.DBF

converted datafile=D:\APP\TRANS\UNDOTBS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00005 name=D:\APP\KUMAR\ORADATA\PROD500\UNDOTBS02.DBF

converted datafile=D:\APP\TRANS\UNDOTBS02.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=D:\APP\KUMAR\ORADATA\PROD500\USERS01.DBF
converted datafile=D:\APP\TRANS\USERS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Edit init.ora file D:\APP\KUMAR\PRODUCT\11.2.0\DBHOME_1\DATABASE\INIT_00PE587E_1
_0.ORA. This PFILE will be used to create the database on the target platform
Run SQL script D:\APP\TRANS\SCRIPT.SQL on the target platform to create database

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 conversion at source at 23-JUL-14



Note:

I all my converting datafiles,scripts file,exe file will store in this location


=D:\app\mig\

But my Init.ora file store in at $ORACLE_HOME take copy of this file also.

Move this Mig file to Linux server:


Note:

Source completed copy all the move to Window server to linux server

Phase -II – Target server (Linux):


6. Copy Converted Datafiles, Generated Script and Pfile to the Linux Machine:
Now copy these converted datafiles, transport script and Pfile on the Linux server. Do not forget to create necessary folder on linux machine such as adump, bdump, udump, cdump, flash_recovery_area.

Note:
Since we are those parameter in not ther in migrate init.ora parameter

c:/app/mig/ move to Linux /oracle/u01/oradata/


Phase -II – Target server (Linux)

7. Edit init.ora or pfile for new database:
Open the init.ora file generated by RMAN. The first section of pfile must be updated, others are optional. Change all the absolute path of windows environment to absolute path of Linux environment.

Note:
Since we are those parameter in not ther in migrate init.ora parameter
control_files = "/oracle/u01/oradata/mig/CF_D-MIGRA_ID-2500231993_01PEOM3D"

db_recovery_file_dest = "/oracle/u01/oradata/mig/flash_recovery_area"

db_recovery_file_dest_size= 4039114752

audit_file_dest = "/oracle/u01/oradata/mig/ADUMP"

db_name = "MIGRA"

oracle_base = "/oracle/u01/

remote_login_passwordfile= "EXCLUSIVE"

db_domain = ""

dispatchers = "(PROTOCOL=TCP) (SERVICE=migra500XDB)"

__pga_aggregate_target = 318767104



# The values of the following parameters are from source database:

processes = 150

memory_target = 855638016
diagnostic_dest = "/oracle/u01"

Once Completed editing Init.ora file:

8. Edit The Script:
Before running the transport script on the target Linux server we need to edit it to set the correct paths for pfile, datafiles, logfiles and tempfiles. Update all the paths as per your Linux environment.

STARTUP NOMOUNT PFILE='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA'
CREATE CONTROLFILE REUSE SET DATABASE "MIGRA" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-34_T-1_A-850908222_03PEOM3D' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-32_T-1_A-850908222_04PEOM3D' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-33_T-1_A-850908222_05PEOM3D' SIZE 50M BLOCKSIZE 512
DATAFILE
'/oracle/u01/oradata/mig/SYSTEM01.DBF',
'/oracle/u01/oradata/mig/SYSAUX01.DBF',
'/oracle/u01/oradata/mig/UNDOTBS01.DBF',
'/oracle/u01/oradata/mig/USERS01.DBF',
'/oracle/u01/oradata/mig/UNDOTBS02.DBF'
CHARACTER SET WE8MSWIN1252
;
9. Execute the Script:

Set Environment:

export PATH=/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/oradb/bin:/oracle/u01/product/11.2.0/dbhome_1/bin:/oracle/u01/product/11.2.0/dbhome_1/OPatch

export ORACLE_SID=MIGRA
export ORACLE_HOME=/oracle/u01/product/11.2.0/dbhome_1


> sqlplus / as sysdba

>@/oracle/u01/mig/SCRIPT.sql

Crated database

>alter database open resetlogs;


ii) once this completed as per SCRIPT.SQL add temporary tablespace since RMAN
didn;t take covert this temp tablespace.

CREATE TEMPORARY TABLESPACE temp_mig TEMPFILE '/oracle/u01/oradata/mig/temp_mig1.dbf' size 5m;
SIZE 20M REUSE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;
(or)
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/u01/oradate/mig/DATA_D-MIGRA_I-2500231993_TS-TEMP_FNO-1_06PEOM3D'
2 size 5m;
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/u01/oradate/mig/DATA_D-MIGRA_I-2500231993_TS-TEMP_FNO-1_06PEOM3D'
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]

Cause:


There no temp file and sql statement not getting executed,
since this problem for packege file so we have to run = utlirp.sql


solve:
=====

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup upgrade pfile='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA';
ORACLE instance started.

Total System Global Area 851808256 bytes
Fixed Size 2218112 bytes
Variable Size 641730432 bytes
Database Buffers 201326592 bytes
Redo Buffers 6533120 bytes
Database mounted.
Database opened.
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL> select logins from v$instance;

LOGINS
----------
RESTRICTED

SQL> select status from v$instance;

STATUS
------------
OPEN MIGRATE

>@$ORACLE_HOME/rdbms/admin/utlirp.sql

Once comeplete


Once its completed create temporary tablespace since I am going to run utlrp.sql so
that time should need temp tablespace.

CREATE TEMPORARY TABLESPACE temp_mig TEMPFILE '/oracle/u01/oradata/mig/temp_mig1.dbf' size 5m;
SIZE 20M REUSE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;


iii) Run utlrp.sql for compile invalid object:

> shut immediate
>startup pfile='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA';
>@$ORACLE_HOME/rdbms/admin/utlrp.sql

Error:
====

RROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 6923
Session ID: 201 Serial number: 165

ERROR:
ORA-03114: not connected to ORACLE

Chacking alert.log file need to extend temporay tablespace

solve:

Add new datafile in the temporary tablespace


iv) Error:
======

> shut immediate;

ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist

solution:

Creating Tnsname.ora entry

MIGRA =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dev186.chainsys.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = migra)
)
)

cross-check:

]$tnsping migra
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = dev186.chainsys.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = migra)))
OK (10 msec)

=====================================

What is UTLIRP.SQL ?
This is a SQL script which first Invalidates & then recompiles PL/SQL modules viz.,
procedures, functions, packages, types, triggers, views in a database
This script expects standard.sql, dbmsstdx.sql files to be available in the current directory.
There should be no other DDL on the database while running the script.

Note: mostly this run it at database in upgrade mode only, only migration time or cross-platform time we run this one.

+ What UTLIRP.SQL does?
The utlirp.sql script recompiles existing PL/SQL modules in the FORMAT required
by the NEW DATABASE with the below steps:
=======================================

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production


SQL> select * From dba_directories;

OWNER DIRECTORY_NAME
------------------------------ ------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
SYS ORACLE_OCM_CONFIG_DIR
D:\app\kumar\product\11.2.0\dbhome_1\ccr\state

SYS DATA_PUMP_DIR
D:\app\kumar\admin\prod500\dpdump\

SYS XMLDIR
c:\ade\aime_dadvfm0254\oracle\rdbms\xml


SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
TEMP_MIG

6 rows selected.

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/oracle/u01/oradata/mig/UNDOTBS02.DBF
/oracle/u01/oradata/mig/USERS01.DBF
/oracle/u01/oradata/mig/UNDOTBS01.DBF
/oracle/u01/oradata/mig/SYSAUX01.DBF
/oracle/u01/oradata/mig/SYSTEM01.DBF

SQL> SELECT COMP_NAME,STATUS FROM DBA_REGISTRY;


Successfully Migration Done :



Thanks & Regards

Kumaresan Nethaji


Follow Document:



Youtube.com--> converting oracle database windows to Linux

1 comment:

  1. I am glad to find amazing information from the blog. Thanks for sharing the information. Wireshark Training | Block Chain | F5 LTM Training

    ReplyDelete