Search This Blog

Monday, January 31, 2011

Create a database using the ASM storage

Tested environment : Oracle Linux 5 64 bits
Oracle 10.2.0.4 64bits for Linux

Create the database files init and password file

initorcl.ora

audit_file_dest='/oracle/admin/orcl/adump'
background_dump_dest='/oracle/admin/orcl/bdump'
compatible='10.2.0.4.0'
core_dump_dest='/oracle/admin/orcl/cdump'
db_block_size=8192
db_file_multiblock_read_count=32
db_name='orcl'
job_queue_processes=10
open_cursors=300
pga_aggregate_target=128M
processes=150
remote_login_passwordfile='EXCLUSIVE'
sga_target=512M
undo_management='AUTO'
undo_tablespace='UNDOTBS1'
user_dump_dest='/oracle/admin/orcl/udump'
db_create_file_dest='+DGROUP1'
control_files='+DGROUP1'
log_archive_dest="LOCATION='+DGROUP1'"
db_create_online_log_dest_1='+DGROUP1'
db_create_online_log_dest_2='+DGROUP1'
db_recovery_file_dest='+DGROUP1'
db_recovery_file_dest_size=6G
LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'

Password file

orapwd file=orapworcl password=oracle entries=5

Create the dumps directories as described in initorcl.ora


mkdir -p /oracle/admin/orcl/adump
mkdir -p /oracle/admin/orcl/cdump
mkdir -p /oracle/admin/orcl/bdump
mkdir -p /oracle/admin/orcl/udump

chmod 755 /oracle/admin







Start the instance using the nomount startup option

export ORACLE_SID=orcl
sqlplus / as sysdba
sql> startup nomount

Create the database

sql>CREATE DATABASE orcl
MAXDATAFILES 100
MAXLOGFILES 6
MAXLOGHISTORY 100
MAXINSTANCES 1
ARCHIVELOG
LOGFILE
GROUP 1 ('+DGROUP1') size 10M,
GROUP 2 ('+DGROUP1') size 10M
DATAFILE '+DGROUP1'
SYSAUX DATAFILE '+DGROUP1'
DEFAULT TEMPORARY TABLESPACE TEMP tempfile '+DGROUP1'
UNDO TABLESPACE UNDOTBS1 DATAFILE '+DGROUP1'
CHARACTER SET UTF8
NATIONAL CHARACTER SET UTF8;

Create the data dictionary and the catalog


@?/rdbms/admin/catalog
@?/rdbms/admin/catproc
@?/rdbms/admin/utlrp

connect system/manager
@?/sqlplus/admin/pupbld

Important Note:
When you restart the database , the instance will not recognize the control file path ,since in init.ora this parameter is defined with ASM's incomplete name. Thus in order to start the database you need to replace it with an ASM qualified name or ASM numeric name or ASM alias . Thus , Open the asmcmd and find the control file qualifies name and use it your database's initorcl.ora file. Alternate , select the group_name,file and incarnation from v$ASM_FILE from ASM instance and use this format as my second example.

control_files="+DGROUP1/controlfile/current.256.740948485"
control_files="+DGROUP1.256.740948485

create spfile='+dgroup1(PARAMETERFILE)' from pfile;

ASM Files after database creation

ASMCMD>cd +DGROUP1/orcl
ASMCMD> ls
ARCHIVELOG/
CONTROLFILE/
DATAFILE/
ONLINELOG/
TEMPFILE/
flash_recovery_area/
ASMCMD>
ASMCMD> cd ONLINELOG
ASMCMD> ls
group_1.257.740948489
group_2.258.740948491
ASMCMD> cd ../CONTROLFILE
ASMCMD> ls
Current.256.740948485
ASMCMD> cd ../DATAFILE
ASMCMD> ls
SYSAUX.261.740948525
SYSTEM.259.740948495
UNDOTBS1.260.740948513
ASMCMD> cd ../TEMPFILE
ASMCMD> ls
TEMP.262.740948535
ASMCMD> pwd
+DGROUP1/orcl/ARCHIVELOG/2011_01_21
ASMCMD> ls
thread_1_seq_43.264.741044093
thread_1_seq_44.265.741044381

Backup the database using RMAN , the only way to backup Oracle database having ASM files.

rman TARGET sys/oracle@orcl NOCATALOG

change archivelog all crosscheck;
run
{
allocate channel ch1 type disk;
backup incremental level 1 as backupset tag=orcl_L1 (database);
sql 'alter system archive log current';
release channel ch1;
allocate channel ch1 type disk;
backup
archivelog all
delete all input;
release channel ch1;
}


Find all ASM aliases files

set heading off
select '+'||dg.name||'/'||al.name
from v$asm_diskgroup dg,v$asm_alias al
where dg.group_number=al.group_number
/

-- Create an alias using the fully qualified filename.
ALTER DISKGROUP disk_group_1 ADD ALIAS '+disk_group_1/my_dir/my_file.dbf'
FOR '+disk_group_1/mydb/datafile/my_ts.342.3';

-- Create an alias using the numeric form filename.
ALTER DISKGROUP disk_group_1 ADD ALIAS '+disk_group_1/my_dir/my_file.dbf'
FOR '+disk_group_1.342.3';

-- Rename an alias.
ALTER DISKGROUP disk_group_1 RENAME ALIAS '+disk_group_1/my_dir/my_file.dbf'
TO '+disk_group_1/my_dir/my_file2.dbf';

-- Delete an alias.
ALTER DISKGROUP disk_group_1 DELETE ALIAS '+disk_group_1/my_dir/my_file.dbf';



My system aliases
+DGROUP1/orcl
+DGROUP1/utilities.dbf
+DGROUP1/ARCHIVELOG
+DGROUP1/2011_01_21
+DGROUP1/thread_1_seq_43.264.741044093
+DGROUP1/thread_1_seq_44.265.741044381
+DGROUP1/thread_1_seq_45.268.741045337
+DGROUP1/thread_1_seq_46.269.741045341
+DGROUP1/thread_1_seq_47.272.741045529
+DGROUP1/thread_1_seq_48.273.741045531
+DGROUP1/thread_1_seq_49.274.741046177
+DGROUP1/thread_1_seq_50.275.741046187
+DGROUP1/thread_1_seq_51.276.741046197

+DGROUP1/thread_1_seq_52.277.741046205
+DGROUP1/thread_1_seq_53.278.741046213
+DGROUP1/thread_1_seq_54.279.741046223
+DGROUP1/thread_1_seq_55.280.741046231
+DGROUP1/thread_1_seq_56.281.741046243
+DGROUP1/thread_1_seq_57.282.741046257
+DGROUP1/thread_1_seq_58.283.741046279
+DGROUP1/2011_01_22
+DGROUP1/thread_1_seq_59.285.741053405
+DGROUP1/CONTROLFILE
+DGROUP1/Current.256.740948485
+DGROUP1/ONLINELOG
+DGROUP1/group_1.257.740948489

+DGROUP1/group_2.258.740948491
+DGROUP1/DATAFILE
+DGROUP1/SYSTEM.259.740948495
+DGROUP1/UNDOTBS1.260.740948513
+DGROUP1/SYSAUX.261.740948525
+DGROUP1/USERS.263.740964343
+DGROUP1/UTILITIES.284.741048253
+DGROUP1/TEMPFILE
+DGROUP1/TEMP.262.740948535
+DGROUP1/BACKUPSET
+DGROUP1/2011_01_21
+DGROUP1/nnndn1_ORCL_L1_0.266.741045261
+DGROUP1/ncsnn1_ORCL_L1_0.267.741045327

+DGROUP1/nnndn1_ORCL_L1_0.270.741045483
+DGROUP1/ncsnn1_ORCL_L1_0.271.741045519
+DGROUP1/control01.ctl
+DGROUP1/flash_recovery_area


alter diskgroup DGROUP1 add alias '+DGROUP1/users.dbf' for '+DGROUP1/orcl/datafile/users.263.740964343';