Friday, August 28, 2009

Oracle 10g Database Migration from Windows to Linux

Both Windows and Linux platforms have the same endian format, which makes possible to transfer the database in easier way.


I have taken following into assumption.

RDBMS with same version is already there in Linux server. If it's not there then Install oracle10g same version as we have at windows machine. Although up gradation is also possible.

  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

In order to execute dbms_tdb.check_db the database must be opened on read only mode.

SQL> shutdown immediate;

SQL> startup mount;

SQL> alter database open read only;


  1. Check database readiness for transport from Windows to Linux

Successful execution of dbms_tdb.check_db means the database is ready for transport to the target platform (here Linux).


SQL> set serveroutput on

SQL> declare

2 db_ready boolean;

3 begin

4 db_ready := dbms_tdb.check_db('Linux IA (32-bit)');

5 end;

6 /

PL/SQL procedure successfully completed.


  1. Check if there are any external objects

If there are any external objects, we will have to take care manually

dbms_tdb.check_external displays report of external objects on console


SQL> set serveroutput on

SQL> declare

2 external boolean;

3 begin

4 external := dbms_tdb.check_external;

5 end;

6 /

The following directories exist in the database:

SYS.DATA_PUMP_DIR, SYS.ORACLE_OCM_CONFIG_DIR, SYS.ADMIN_DIR, SYS.WORK_DIR

PL/SQL procedure successfully completed.


  1. 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.


I am changing my database name from "WIN1" to "LIN1".There are 2 options suggested you can follow any one of them as per your requirement.


C:\Documents and Settings\ssethia>rman target / nocatalog


First option is


RMAN> CONVERT DATABASE NEW DATABASE 'LIN1'

2> transport script 'F:\transportscript'

3> to platform 'Linux IA (32-bit)';


Your datafiles and Initfile will copy to $ORACLE_HOME/database Like..


At location "F:\oracle\product\10.2.0\db_1\database"

You will find datafiles with name like

"DATA_D-WIN1_I-3182306851_TS-SYSTEM_FNO-1_01KK4H9T"

And initfile like

"INIT_00KK4H9T_1_0.ORA"

Importantly you will find transport script 'F:\transportscript'


Second option is

CONVERT DATABASE NEW DATABASE 'LIN1'

transport script 'F:\transportscript_sum1.sql'

to platform 'Linux IA (32-bit)'

db_file_name_convert 'F:\oracle\product\10.2.0\oradata\Win1','F:\LIN1_data'; ;


In this command you can define the target location.like "F:\LIN1_data"


I am using first option.


PLEASE don't run "transportscript" at this point.


-- The following commands will create a new control file and use it

-- to open the database.

-- Data used by Recovery Manager will be lost.

-- The contents of online logs will be lost and all backups will

-- be invalidated. Use this only if online logs are damaged.


-- After mounting the created controlfile, the following SQL

-- statement will place the database in the appropriate

-- protection mode:

-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE


STARTUP NOMOUNT PFILE='/vol2/oracle/product/10.2.0/db_1/database/INIT_00KK4H9T_1_0.ORA'


-- Create SPFILE

CREATE SPFILE FROM PFILE = '/vol2/oracle/product/10.2.0/db_1/database/INIT_00KK4H9T_1_0.ORA';


STARTUP FORCE NOMOUNT

CREATE CONTROLFILE REUSE SET DATABASE 'LIN1' RESETLOGS NOARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 292

LOGFILE

GROUP 1 '/vol2/oracle/product/10.2.0/db_1/database/ARCH_D-LIN1_ID-3182306851_S-2_T-1_A-692205924_00KK4H9T' SIZE 50M,

GROUP 2 '/vol2/oracle/product/10.2.0/db_1/database/ARCH_D-LIN1_ID-3182306851_S-0_T-1_A-692205924_00KK4H9T' SIZE 50M,

GROUP 3 '/vol2/oracle/product/10.2.0/db_1/database/ARCH_D-LIN1_ID-3182306851_S-1_T-1_A-692205924_00KK4H9T' SIZE 50M

DATAFILE

'/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-SYSTEM_FNO-1_01KK4H9T',

'/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-UNDOTBS1_FNO-2_04KK4HBC',

'/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-SYSAUX_FNO-3_02KK4HAM',

'/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-USERS_FNO-4_05KK4HBG',

'/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-EXAMPLE_FNO-5_03KK4HB5'

CHARACTER SET WE8MSWIN1252

;


-- Database can now be opened zeroing the online logs.

ALTER DATABASE OPEN RESETLOGS;


-- Commands to add tempfiles to temporary tablespaces.

-- Online tempfiles have complete space information.

-- Other tempfiles may require adjustment.

ALTER TABLESPACE TEMP ADD TEMPFILE '/vol2/oracle/product/10.2.0/db_1/database/DATA_D-LIN1_I-3182306851_TS-TEMP_FNO-1_00KK4H9T' SIZE 20M;

-- End of tempfile additions.

--


set echo off

prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

prompt * Your database has been created successfully!

prompt * There are many things to think about for the new database. Here

prompt * is a checklist to help you stay on track:

prompt * 1. You may want to redefine the location of the directory objects.

prompt * 2. You may want to change the internal database identifier (DBID)

prompt * or the global database name for this database. Use the

prompt * NEWDBID Utility (nid).

prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


SHUTDOWN IMMEDIATE

STARTUP UPGRADE

@@ ?/rdbms/admin/utlirp.sql

SHUTDOWN IMMEDIATE

STARTUP

-- The following step will recompile all PL/SQL modules.

-- It may take serveral hours to complete.

@@ ?/rdbms/admin/utlrp.sql

set feedback 6;


  1. Copy Converted Datafiles, Generated Transport Script and Parameter File to the Linux

We need to copy over the generated files to the Linux server, they include all converted datafiles, the transport

script and the generated pfile.

If needed create at this point the directories you will need on the Linux server, for dump destination and flash

recovery area i.e.:


mkdir –p /vol2/database/LIN1/FRA

mkdir -p /vol2/oracle/app/admin/LIN1/adump

mkdir -p /vol2/oracle/app/admin/LIN1/bdump

mkdir -p /vol2/oracle/app/admin/LIN1/cdump

mkdir -p /vol2/oracle/app/admin/LIN1/udump


  1. Copy/FTP the files to the required LINUX server


You can use ftp to copy the required files to the Linux server.


[sumit::/vol2/oracle/product/10.2.0/db_1/database] $ ls -lrt

total 1227560

-rw-rw-r-- 1 sumit sumit 3088 2009-07-14 16:16 TRANSPORTSCRIPT

-rw-rw-r-- 1 sumit sumit 1456 2009-07-14 16:39 INIT_00KK4H9T_1_0.ORA

-rw-rw---- 1 sumit sumit 52429312 2009-07-14 22:40 ARCH_D-LIN1_ID-3182306851_S-2_T-1_A-692205924_00KK4H9T

-rw-rw---- 1 sumit sumit 52429312 2009-07-14 22:44 ARCH_D-LIN1_ID-3182306851_S-0_T-1_A-692205924_00KK4H9T

-rw-rw-r-- 1 sumit sumit 5251072 2009-07-14 22:50 DATA_D-WIN1_I-3182306851_TS-USERS_FNO-4_05KK4HBG

-rw-rw-r-- 1 sumit sumit 104865792 2009-07-14 22:50 DATA_D-WIN1_I-3182306851_TS-EXAMPLE_FNO-5_03KK4HB5

-rw-rw---- 1 sumit sumit 20979712 2009-07-14 22:51 DATA_D-LIN1_I-3182306851_TS-TEMP_FNO-1_00KK4H9T

-rw-rw-r-- 1 sumit sumit 241180672 2009-07-15 00:18 DATA_D-WIN1_I-3182306851_TS-SYSAUX_FNO-3_02KK4HAM

-rw-rw-r-- 1 sumit sumit 225452032 2009-07-15 00:20 DATA_D-WIN1_I-3182306851_TS-UNDOTBS1_FNO-2_04KK4HBC

-rw-rw-r-- 1 sumit sumit 513810432 2009-07-15 00:21 DATA_D-WIN1_I-3182306851_TS-SYSTEM_FNO-1_01KK4H9T

-rw-rw---- 1 sumit sumit 52429312 2009-07-15 00:21 ARCH_D-LIN1_ID-3182306851_S-1_T-1_A-692205924_00KK4H9T

-rw-rw---- 1 sumit sumit 7389184 2009-07-15 00:21 CF_D-LIN1_ID-3182306851_00KK4H9T


  1. Edit init.ora and Transport Script for new database

You need to make directory structure related changes and replace " " " double codes with " ' " single code.


  1. Execute the Transport Script

SQL> @transport

Script will perform followings:-


CREATE CONTROLFILE

DATABASE OPEN RESETLOGS

ADD TEMPFILES

And

SHUTDOWN IMMEDIATE

STARTUP UPGRADE

@@ ?/rdbms/admin/utlirp.sql

SHUTDOWN IMMEDIATE

STARTUP

-- The following step will recompile all PL/SQL modules.

-- It may take serveral hours to complete.

@@ ?/rdbms/admin/utlrp.sql


  1. Change database identifier

To change the database identifier you need to use the NEWDBID utility "nid". It is run from within Sqlplus having

the database mounted:

sqlplus "/ as sysdba"

startup mount

exit

To change the DBID

cd $ORACLE_HOME/bin

./nid target=/


  1. Check database integrity

SQL> select tablespace_name from dba_tablespaces;


TABLESPACE_NAME

------------------------------

SYSTEM

UNDOTBS1

SYSAUX

TEMP

USERS

EXAMPLE


6 rows selected.


SQL> select file_name from dba_data_files;


FILE_NAME

--------------------------------------------------------------------------------

/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-EXAMPLE_FNO-5_03KK4HB5

/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-USERS_FNO-4_05KK4HBG

/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-SYSAUX_FNO-3_02KK4HAM

/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-UNDOTBS1_FNO-2_04KK4HBC

/vol2/oracle/product/10.2.0/db_1/database/DATA_D-WIN1_I-3182306851_TS-SYSTEM_FNO-1_01KK4H9T


SQL> SELECT COMP_NAME, STATUS FROM DBA_REGISTRY;


COMP_NAME STATUS

-------------------------------------------------- -----------

Oracle Database Catalog Views VALID

Oracle Database Packages and Types VALID

Oracle Workspace Manager VALID

JServer JAVA Virtual Machine VALID

Oracle XDK VALID

Oracle Database Java Packages VALID

Oracle Expression Filter VALID

Oracle Data Mining VALID

Oracle Text VALID

Oracle XML Database VALID

Oracle Rules Manager VALID

Oracle interMedia VALID

OLAP Analytic Workspace VALID

Oracle OLAP API VALID

OLAP Catalog VALID

Spatial VALID

Oracle Enterprise Manager VALID


17 rows selected.


Wednesday, June 10, 2009

Install Oracle Database 10g on AIX-5.3

Install Oracle Database 10g on AIX-5.3

UNIX server details:

Version – AIX 5.3
Disk space – 6 GB
Temp space – 580 MB
Swap space – 2304 MB

STEP 1 - Pre installation check script

Download pre-installation check script from
https://metalink.oracle.com and save as validate.tar
Ftp file on unix server and untar the file using command tar xvf validate.tar
“tar" file, which consists of the following:
validate - Shell script that executes the engine - Unix platforms
validate.pl - Actual rule engine
filename.txt - Rule text file. This file will be different for each rule set
Execute validate filename.txt from the command line, as in the following examples:# validate 10gr2_rdbms_aix_hcve_100705.txtOR# perl validate.pl 10gr2_rdbms_aix_hcve_100705.txt
Below is the ouput of script in log dir.

ID NAME RESULT C VALUE
----------------------------------- ----------------------- ------------------------------
10 OS Certified? PASSED = Certified with 10g RDBMS
20 User in /etc/passwd? FAILED = Can not read /etc/passwd
30 Group in /etc/group? PASSED = GroupOK
40 Input ORACLE_HOME RECORD $ORACLE_HOME
50 ORACLE_HOME valid? PASSED = OHNotSpecified
60 O_H perms OK? PASSED = OHNotSpecified
70 Umask set to 022? PASSED = UmaskOK
80 LDLIBRARYPATH unset? PASSED = UnSet
90 LIBPATH unset? PASSED = UnSet
100 Other O_Hs in PATH? PASSED = NoneFound
110 oraInventory perms PASSED = oraInventoryNotFound
120 /tmp adequate? FAILED = TMPDIRTooSmall
130 Swap (in Mb) RECORD 1280
140 RAM (in Mb) PASSED > 2048
150 SwapToRAM OK? FAILED = InsufficientSwap
160 Disk Space OK? PASSED = OHNotSpecified
170 AIXTHREAD_SCOPE=S? FAILED = AIXTHREADNotSet
175 LINK_CNTRL is unset? PASSED = LINK_CNTRLunset
180 Got ld,nm,ar,make? PASSED = ld_nm_ar_make_found
190 ulimits OK? FAILED = FileTooSmall
NoFilesTooSmall
MemoryTooSmall
200 Got OS packages? FAILED = bos.adt.libmNotInstalled
210 Got OS patches? PASSED = PatchesFound
220 other OUI up? PASSED = NoOtherOUI




Below modifications has been performed on the basis of above results.

STEP 2 – Action performed on pre-installation check report

1) User oracle and groups dba & oinstall has been created and added user in groups.
2) Swap memory increased from 1280MB to 2304MB.
3) Added one line “export AIXTHREAD_SCOPE=S” in .profile file using oracle login.
4) Previously ulimit for file was set to 1GB now it has been set to “unlimited”.
5) One OS package file was not found (bos.adt.libm ), Installed by requesting unix administrator.
6) Rerun the script and verified the results after changes.

STEP 3 – Software download

Download oracle 10g installation software from oracle download site and extract on server.
File : 10gr2_aix5l64_database.cpio.gz

Created one new dir by name “software” and copied setup files.
Extracted cpio file on server using below command:

cpio -idcmv < 10gr2_aix5l64_database.cpio

STEP 4 – Xmanager configuration

In order to do GUI based installation below are some setting needed to be done:
1) Installed Xmanager software on local computer.
2) Click on xstart and create new profile for our server with login details.
3) Check for xterm services running on server if not please get it start from AIX administrator.
4) Enter x display location details under x11 tab in putty ( Your desktop IP : 0.0 )
5) Check the same with running xclock command on server. ( Graphical clock should display )

STEP 5 – Oracle 10g installation

Create two directories under home dir.

1) /home/oracle/app
2) /home/oracle/orainventory


Go to install dir:
Start installation using script: runInstaller

Script asks for one script to be executed from root login before going ahead.



So executed rootpre.sh with the help of AIX administrator.

Continue with the “Basic Installation”



Ignored with below error:



In next window changed dir path for inventory directory.


/home/oracle/orainventory dir already created before starting of installation.

Select “Enterprise Edition” type of installation.



Please make sure once again for available free space on oracle home dir.

Please specify name of installation and location where software to be installed.

/home/oracle/app directory already created before starting of installation.



Click on checkbox “Checking recommended operating system patches”
And check the report generated.



Select “install database software only”.
Database will be created manually after installation gets finished.



Installation started ………..



Required below two scripts to be execute through root login.



Unix administrator executed above two scripts.

Oracle 10g installation on AIX – 5.3 finished successfully.



Added below two lines in .profile file by oracle login:

export ORACLE_HOME=/home/oracle/app/ora10g
export ORACLE_SID=ORCL10G


Name has given to instance is “ORCL10G”.

So created dir by the name : /u01/oracle/oradata/ORCL10G

STEP 6 – Oracle Database Creation

Created below seven directories under /u01/oracle/oradata/ORCL10G

bdump
udump
cdump
controlfile
datafile
logfile

Create password file for sys password on OS command line

orapwd file=$ORACLE_HOME/dbs/orapwORCL10G password=sysdba entries=5

Create initORCL10G.ora file at $ORACLE_HOME/dbs directory. Set appropriate parameters as per requirement.

Connect to sqlplus using sqlplus “/ as sysdba” command on OS command line

startup nomunt
execute create database command which is written below:

create database ORCL10G
logfile
group 1 ('/u01/oracle/oradata/ORCL10G/logfile/redo1.log') size 10M,
group 2 ('/u01/oracle/oradata/ORCL10G/logfile/redo2.log') size 10M,
group 3 ('/u01/oracle/oradata/ORCL10G/logfile/redo3.log') size 10M
character set WE8ISO8859P1
national character set utf8
datafile '/u01/oracle/oradata/ORCL10G/datafile/system01.dbf'
size 50M
autoextend on
next 10M maxsize unlimited
extent management local
sysaux datafile '/u01/oracle/oradata/ORCL10G/datafile/sysaux01.dbf'
size 10M
autoextend on
next 10M
maxsize unlimited
undo tablespace undotbs01
datafile '/u01/oracle/oradata/ORCL10G/datafile/undotbs01.dbf'
size 10M
default temporary tablespace temp
tempfile '/u01/oracle/oradata/ORCL10G/datafile/temp01.dbf'
size 10M;

Please execute below mention PL/SQL to create dictionary for that particular database only.
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql

The user system might also want to run ?/sqlplus/admin/pupbld.sql. pupbld.sql creates a table that allows to block someone from using sql plus.
SQL> connect system/manager
SQL> @?/sqlplus/admin/pupbld
Installation & Database creation completes.

Wednesday, April 29, 2009

Install Oracle Database 10g on LINUX (RHEL 4)

Installing Oracle 10g (10.2.0.1) on RHEL 4

This part is need to be done by root user only.

create groups
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba

create OS user oracle with group permissions and home /home/oracle
/usr/sbin/useradd -g oinstall -G dba -d /home/oracle oracle

set user oracle's password
/usr/bin/passwd oracle
give the password you need.

Append user oracle's bash profile with PATH and ORACLE:BASE,HOME and SID information vi /opt/oracle/.bash_profile
umask 022
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
LD_LIBRARY_PATH=/usr/lib:/usr/X11R6/lib
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10gR2
ORACLE_SID=orcl
PATH=$ORACLE_HOME/bin:$PATH
export PATH LD_LIBRARY_PATH ORACLE_BASE ORACLE_HOME ORACLE_SID

Create the directory for the software installation and assign ownership to oracle:oinstall
chown -R oracle:oinstall /u01
chmod -R 775 /u01

Make sure the correct kernel parmeters are added to sysctl.conf

vi /etc/sysctl.conf (these can be easily copied from the Quick Installation Guide for Linux x86 doc on the Oracle10g CD)
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000

reboot to apply the changes made to kernel parameter, or
/sbin/sysctl -p

Login in to xwindows session as user oracle

Download the Oracle 10g appropriate software from download.oracle.com website.

Unzip the software using 'unzip' Linux command. It will create a directory.

Please go through the readme first. There are some rpm (RedHat Package Manager) files that needs to be installed first.
Download the appropriate packages.
http://rpm.pbone.net/
http://rpmfind.net/

Install those packages as following (OS user must be 'root' user)
# rpm -Uvh (RPM package name)

@@ Here 'U' stand for upgrading an RPM package. 'i' is used to install & 'q' is used to query.

Now login to GUI as OS user 'oracle', go to unzipped folder and execute
$ ./runInstaller

Continue the steps & create the database.