Tuesday 28 October 2014

Manual Installation of Oracle Database on (ASM)

Configure raw devices to create ASM see ASM Configuration
NOTE: I am assuming that you have installed ORACLE software already. If not then install Oracle Software. We will see how to create Oracle Database on ASM Manually (without GUI).

Check the raw disk:

# ls /dev/raw/*

Check the Ownership and permission of Raw devices:

# ls -ltr /dev/raw/raw*
crwxrwxrwx 1 oracle dba 162, 1 Oct 28 19:38 /dev/raw/raw1
crwxrwxrwx 1 oracle dba 162, 2 Oct 28 19:38 /dev/raw/raw2
crwxrwxrwx 1 oracle dba 162, 3 Oct 28 19:38 /dev/raw/raw3
crwxrwxrwx 1 oracle dba 162, 4 Oct 28 19:38 /dev/raw/raw4

Starting the css service:

Go to ORACLE_HOME/bin directory and execute the following script as a ROOT user.
# cd /oradata/oracle/product/11.1.0.7/db_1/bin
# ./localconfig add

Creating the parameter pfile for asm instance:

$ cd $ORACLE_HOME/dbs
$ vi init+asm1.ora

And paste the following parameters. You can change it as per your specifications.

instance_type=asm
instance_name=+asm1
asm_diskstring='/dev/raw/raw*'
shared_pool_size=64m
asm_power_limit=2
asm_diskgroups='DG1'

Starting the ASM instance and creating the diskgroup:

$ export ORACLE_SID=+asm
$ sqlplus "/ as sysdba"
Sql> startup nomount
Sql> select name,path from v$asm_disk;
Note: I dont need mirroring of disks so I am creating diskgroup with "external redundancy" option for utilizing all rawdevices.

Creating of the diskgroup:

Sql> create diskgroup dg1 external redundancy disk                  '/dev/raw/raw1’,’/dev/raw/raw2','/dev/raw/raw3','/dev/raw/raw4';

Check the name and status of Diskgroup:

Sql> select name,state from v$asm_diskgroup;
NAME       STATE
------------------------------ -----------
DG1        MOUNTED

Diskgroup is created now its time to create database.
For creating database manually follow the steps:

Step 1:Create Directory structure with Oracle ownership and permission as below:

# cd /oradata
# mkdir /oradata/dev
# mkdir adump diag flash_recovery_area
# chmod -R 777 /oradata/dev
# chown -R oracle:dba /oradata/dev

Step 2:Create Parameter file in $ORACLE_HOME/dbs location:

$ cd $ORACLE_HOME/dbs
$ vi initdev.ora
And paste the following parameters. You can change it as per your specifications.

db_name='dev' #you can give whatever db_name you want
db_block_size=8192
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
control_files= '+DG1/dev/control/control01.ctl','+DG1/dev/control/control02.ctl', '+DG1/dev/control/control03.ctl'
compatible='11.1.0'
diagnostic_dest='/oradata/oracle/product/11.1.0.7/dign'
log_buffer=10485760
log_checkpoints_to_alert=TRUE
max_dump_file_size='20480'
shared_pool_reserved_size=40M
shared_pool_size=400M
timed_statistics=true
db_block_buffers=100# SMALL
db_file_multiblock_read_count=8# SMALL
db_files=80# SMALL
global_names=TRUE
log_checkpoint_interval=10000
parallel_max_servers=5# SMALL
processes=50# SMALL
undo_management='AUTO'
undo_tablespace='UNDOTBS1'

Step 3:Prepare Create Database script:

$ vi createdb.sql

CREATE DATABASE dev
USER sys IDENTIFIED BY sys
USER system IDENTIFIED BY system
MAXLOGFILES 5
MAXLOGMEMBERS 3
MAXDATAFILES 200
MAXINSTANCES 8
MAXLOGHISTORY 500
LOGFILE 
GOUP 1 (
'+dg1/dev/redologs/redo01_1.log',
'+dg1/dev/redologs/redo01_2.log'
) SIZE 10M,
GROUP 2 (
'+dg1/dev/redologs/redo02_1.log',
'+dg1/dev/redologs/redo02_2.log'
) SIZE 10M,
GROUP 3 (
'+dg1/dev/redologs/redo03_1.log',
'+dg1/dev/redologs/redo03_2.log'
) SIZE 10M
DATAFILE
'+dg1/dev/datafiles/system01.dbf' SIZE 100M
SYSAUX DATAFILE '+dg1/dev/datafiles/sysaux01.dbf' SIZE 50M
UNDO TABLESPACE UNDOTBS1 DATAFILE '+dg1/dev/datafiles/undotbs01.dbf' SIZE 100M
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '+dg1/dev/datafiles/temp01.dbf' SIZE 40M
CHARACTER SET UTF8;

Step 4: Check ASM instance is Up or not if not then start the ASM instance:

$ ps -ef | grep AMS
oracle 30827 1 0 19:57 ? 00:00:00 asm_pmon_+ASM
oracle 30829 1 0 19:57 ? 00:00:00 asm_vktm_+ASM
oracle 30833 1 0 19:57 ? 00:00:00 asm_diag_+ASM
oracle 30835 1 0 19:57 ? 00:00:00 asm_psp0_+ASM
oracle 30839 1 0 19:57 ? 00:00:00 asm_dia0_+ASM
oracle 30841 1 0 19:57 ? 00:00:00 asm_mman_+ASM
oracle 30843 1 0 19:57 ? 00:00:00 asm_dbw0_+ASM
oracle 30845 1 0 19:57 ? 00:00:00 asm_lgwr_+ASM
oracle 30847 1 0 19:57 ? 00:00:00 asm_ckpt_+ASM
oracle 30849 1 0 19:57 ? 00:00:00 asm_smon_+ASM
oracle 30851 1 0 19:57 ? 00:00:01 asm_rbal_+ASM
oracle 30853 1 0 19:57 ? 00:00:00 asm_gmon_+ASM
oracle 31686 31443 0 22:04 pts/1 00:00:00 grep ASM

Step 5:Set the Oracle ENVIRONMENT and SID of Database in the Operating System:

Go to Oracle users Home directory
$ cd /home/oracle
Edit the .bash_profile file
$ vi .bash_profile
export ORACLE_HOME=/oradata/oracle/product/11.1.0.7/db_1
export ORACLE_SID=dev
PATH=$PATH:$ORACLE_HOME/bin
Save it and run the bash_profile
$ . .bash_profile
This will set the Oracle Environment variables in Unix-based operating system.

Step 6: Start up database in nomount stage

$ sqlplus " / as sysdba"
SQL> startup nomount
ORACLE instance started.
Total System Global Area 464556032 bytes
Fixed Size 1300492 bytes
Variable Size 444598260 bytes
Database Buffers 4194304 bytes
Redo Buffers 14462976 bytes
SQL>

Step 7:Execute Create Database script created in Step 3

SQL>@/oradata/createdb.sql
Database created

Step 8:Execute the catalog.sql,catproc.sql and pupbld.sql scripts:

a) catalog.sql =>Creates dictionary tables and views
b) catproc.sql =>Creates PL/SQL procedures,functions and packages necessary.
c) pupbld.sql =>Creates user profiles.
You will find catalog.sql and catproc.sql in $ORACLE_HOME/rdbms/admin path and pupbld.sql
in $ORACLE_HOME/sqlplus/admin path.