Tuesday, 16 January 2018

Configuring ASM for single Instance DB

Automatic Storage Management (ASM)

ASM is advance feature provided by Oracle for management of storage devices and data placed on it form 10g ownwards. ASM combines the storage disks to form a disk groups, used
for storing of Data. It is automatic in the sense that you can add disks and remove disks from Disk group even its online and data is written on it live. Other features are stripping
mirroring of data across different disks. There are other storage management tool as well but Oracle ASM is best of them all is because it provides you with
Oracle Automatic Storage Management Cluster File System (Oracle ACFS).

ASM can be implemented in 2 ways: i.e ASMLib drivers and through Raw Devices

 1) ASM configuration through ASMLib: (Below method is use to configure ASM in all most all environments)

--First of All you'll Install rpm, 3 rpms

1) oracleasm-support-2.1.7-1.el5.i386.rpm
2) oracleasm-2.6.18-92.el5-2.0.4-1.el5.i686.rpm
3) oracleasmlib-2.0.4-1.el5.i386.rpm

-- Partition Harddisk

#fdisks -l


#fdisk /dev/sda

n for new partition
P for primary partition
1 starts
enter
enter
wq to write quite

similarly you'll partition all the disks

--Now configure ASM 

#/etc/init.d/oracleasm configure

than will ask for user : oracle
                       : oinstall
                       : y
                       : y 

-- Naming ASM Disks

/etc/init.d/oracleasm createdisk vol1 /dev/sda1
/etc/init.d/oracleasm createdisk vol2 /dev/sda2
/etc/init.d/oracleasm createdisk vol3 /dev/sda3
/etc/init.d/oracleasm createdisk vol4 /dev/sda4
/etc/init.d/oracleasm createdisk vol4 /dev/sda5

--Listing all the diks created

/etc/init.d/oracleasm listdisks
vol1
vol2
vol3
vol4
vol4

Once the formating is done execute runinstaller


2)  Raw Device Configuration: (These days its not configured but one should have knowledge)

In linux disk are partitioned but not formated for raw formate

# fdisk -l 

/dev/sda1
/dev/sda2
/dev/sda3 etc...

In some release of linux raw devices configuration are depreciated
If you don't have raw devices attached to  than you can check it by command:


(i)  service rawdevices start
     (unrecognised command)
(ii) ll /etc/sysconfig/raw*
      (no such file or directory)
 
  You above commands didn't return any result please follow the below procedure:
 

cd /etc/udev/rules.d
(rules file are executed when machine startups )
these are called udev rules

vi 60-raw.rules
paste :

ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc1", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdf1", RUN+="/bin/raw /dev/raw/raw5 %N"
KERNEL=="raw[1-2]*", OWNER="root", GROUP="oinstall", MODE="640"
KERNEL=="raw[3-5]*", OWNER="oracle", GROUP="oinstall", MODE="644"

if you want that it will be effected immediate use this command :

/bin/raw /dev/raw/raw1 /dev/sdb1
/bin/raw /dev/raw/raw2 /dev/sdc1
/bin/raw /dev/raw/raw3 /dev/sdd1
/bin/raw /dev/raw/raw4 /dev/sde1
/bin/raw /dev/raw/raw5 /dev/sdf1

keep in mind that this is the drawback of rawdevices that after restart these permisstion reset to root but keeping the 2 lines in 60-raw files keep it static.

chown oracle:oinstall /dev/raw/raw*
chmod 640 /dev/raw/*

Now Run the runinstaller  

Moving Data from one ASM DG with EXTERNAL redundancy to another ASM DG with NORMAL redundancy (Offline approach)

Moving Data from one ASM DG to another ASM DG Offline approach.

If we are having diskgroup with redundancy EXTERNAL and want to configure another ASM DG with redundancy Level NORMAL, so its no other way to create new Disk group and move all your
from old ASM DG wiht EXTERNAL to New ASM DG with NORMAL redundancy.

--Check all the datafiles of the DB and their location:

select file_id,bytes/1024/1024 MB,tablespace_name,file_name from dba_data_files;

File Size(MB) Tablespace            Datafile Name
---- -------- --------------------  ------------------------
1    3072     SYSTEM                +PRE_TEST_DATA/dbTESTq/datafile/system.266.864839123
2    3072     SYSAUX                +PRE_TEST_DATA/dbTESTq/datafile/sysaux.265.864839135
3    4470     UNDOTBS1              +PRE_TEST_DATA/dbTESTq/datafile/undotbs1.258.864839143
4    5445     UNDOTBS2              +PRE_TEST_DATA/dbTESTq/datafile/undotbs2.264.864839153
5    5        USERS                 +PRE_TEST_DATA/dbTESTq/datafile/users.263.864839157
6    1024     vr_TEST_DATA          +PRE_TEST_DATA/dbTESTq/datafile/vr_TEST_data.dbf
7    1024     TS_DATA_TESTIKMS       +PRE_TEST_DATA/dbTESTq/datafile/ts_data_TESTikms.dbf
8    1024     TS_INDEX_TESTIKMS      +PRE_TEST_DATA/dbTESTq/datafile/ts_index_TESTikms.dbf
9    1024     TS_KSA_TEST_DAT        +PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_dat_1.dbf
10   1024     TS_KSA_TEST_IDX        +PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_idx_1.dbf
11   1024     TS_KSA_TEST_LOB        +PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_lob_1.dbf
12   1024     TS_KSA_TEST_LOG        +PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_log_1.dbf
13   1024     TS_KSA_TEST_LOG_LOB    +PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_log_lob_1.dbf

-- Checking all Temp files location

select file_id,bytes/1024/1024 MB,tablespace_name,maxbytes/1024/1024 Maxsize(MB),file_name from dba_temp_files;

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    73       TEMP                 32767       +PRE_TEST_DATA/dbTESTq/tempfile/temp.257.864839147

-- Check Controlfile Location

SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      +PRE_TEST_DATA/dbTESTq/controlfi
                                                 le/current.267.864839117, +PRE
                                                 _TEST_FRA/dbTESTq/controlfile/cu
                                                 rrent.256.864839117
control_management_pack_access       string      DIAGNOSTIC+TUNING
SQL>

-- Check below parameters if any of them pointing to Old disk group

Show parameter DB_CREATE_FILE_DEST
Show parameter DB_CREATE_ONLINE_LOG_DEST_n
Show parameter DB_RECOVERY_FILE_DEST
Show parameter LOG_ARCHIVE_DEST_n
Show parameter LOG_ARCHIVE_DEST
Show parameter STANDBY_ARCHIVE_DEST

-- Changing location of backup controlfile to new ASM DG having normal redundancy

sql> alter database backup controlfile to '+PRE_TEST_DATA_01';

Database altered.

SQL> alter system set control_files='+PRE_TEST_DATA_01/DBTESTQ/CONTROLFILE/Backup.256.912776299' scope=spfile;

System altered.

--Now restoring current Controlfile status to newly move controlfile (offline so that it should be synced with original one)

rman target TESTqrman/RmanTEST11q catalog catqrman/Rmanora11q@dboemq1

rman target /
shutdown immediate;

RMAN> restore controlfile from '+PRE_TEST_DATA/dbTESTq/controlfile/current.267.864839117';

Starting restore at 25-MAY-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=122 instance=DBTESTQ1 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+PRE_TEST_DATA_01/dbTESTq/controlfile/backup.256.912776299
Finished restore at 25-MAY-16

--Moving Datafiles thorugh RMAN to new ASM Disk Group through RMAN backup as copy

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> backup as copy database format '+PRE_TEST_DATA_01';

Starting backup at 25-MAY-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=152 instance=DBTESTQ1 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+PRE_TEST_DATA/dbTESTq/datafile/undotbs2.264.864839153
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/undotbs2.257.912777743 tag=TAG20160525T132222 RECID=4 STAMP=912777794
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+PRE_TEST_DATA/dbTESTq/datafile/undotbs1.258.864839143
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/undotbs1.258.912777797 tag=TAG20160525T132222 RECID=5 STAMP=912777835
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+PRE_TEST_DATA/dbTESTq/datafile/system.266.864839123
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/system.259.912777843 tag=TAG20160525T132222 RECID=6 STAMP=912777869
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+PRE_TEST_DATA/dbTESTq/datafile/sysaux.265.864839135
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/sysaux.260.912777877 tag=TAG20160525T132222 RECID=7 STAMP=912777910
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=+PRE_TEST_DATA/dbTESTq/datafile/vr_TEST_data.dbf
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/vr_TEST_data.261.912777913 tag=TAG20160525T132222 RECID=8 STAMP=912777926
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=+PRE_TEST_DATA/dbTESTq/datafile/ts_data_TESTikms.dbf
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/ts_data_TESTikms.262.912777929 tag=TAG20160525T132222 RECID=9 STAMP=912777937
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=+PRE_TEST_DATA/dbTESTq/datafile/ts_index_TESTikms.dbf
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/ts_index_TESTikms.263.912777943 tag=TAG20160525T132222 RECID=10 STAMP=912777950
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00009 name=+PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_dat_1.dbf
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_dat.264.912777959 tag=TAG20160525T132222 RECID=11 STAMP=912777964
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00010 name=+PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_idx_1.dbf
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_idx.265.912777965 tag=TAG20160525T132222 RECID=12 STAMP=912777972
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00011 name=+PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_lob_1.dbf
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_lob.266.912777981 tag=TAG20160525T132222 RECID=13 STAMP=912777990
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00012 name=+PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_log_1.dbf
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_log.267.912777995 tag=TAG20160525T132222 RECID=14 STAMP=912778003
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00013 name=+PRE_TEST_DATA/dbTESTq/datafile/ts_TEST_log_lob_1.dbf
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_log_lob.268.912778011 tag=TAG20160525T132222 RECID=15 STAMP=912778017
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=+PRE_TEST_DATA_01/dbTESTq/controlfile/backup.269.912778019 tag=TAG20160525T132222 RECID=16 STAMP=912778019
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+PRE_TEST_DATA/dbTESTq/datafile/users.263.864839157
output file name=+PRE_TEST_DATA_01/dbTESTq/datafile/users.270.912778021 tag=TAG20160525T132222 RECID=17 STAMP=912778020
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 25-MAY-16
channel ORA_DISK_1: finished piece 1 at 25-MAY-16
piece handle=+PRE_TEST_DATA_01/dbTESTq/backupset/2016_05_25/nnsnf0_tag20160525t132222_0.271.912778021 tag=TAG20160525T132222 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-MAY-16

--Updating location of all DATAFILES in controlfile from old ASM DG to new ASM DG

RMAN> switch database to copy;

datafile 1 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/system.259.912777843"
datafile 2 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/sysaux.260.912777877"
datafile 3 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/undotbs1.258.912777797"
datafile 4 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/undotbs2.257.912777743"
datafile 5 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/users.270.912778021"
datafile 6 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/vr_TEST_data.261.912777913"
datafile 7 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/ts_data_TESTikms.262.912777929"
datafile 8 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/ts_index_TESTikms.263.912777943"
datafile 9 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_dat.264.912777959"
datafile 10 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_idx.265.912777965"
datafile 11 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_lob.266.912777981"
datafile 12 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_log.267.912777995"
datafile 13 switched to datafile copy "+PRE_TEST_DATA_01/dbTESTq/datafile/ts_ksa_TEST_log_lob.268.912778011"

RMAN>

RMAN> exit

--Opening the DATABASE from new ASM DG

[oracle@TESTQDB09 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed May 25 13:28:16 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters and Automatic Storage Management options

SQL>
SQL> alter database open;

Database altered.

SQL> select open_mode from v$database;

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

SQL>

--Setting location to NEW FRA Disk group wiht normal redundancy

SQL> alter system set db_recovery_file_dest='+PRE_TEST_FRA_01' scope=both;

System altered.

SQL>
-- Creating new temp file as it is not backup through Rman


SQL> create temporary tablespace temp01 tempfile '+PRE_TEST_DATA_01' size 32767M;

Tablespace created.

SQL> alter database default temporary tablespace temp01;

Database altered.

--Droping Old Temporary TABLESPACE

SQL> DROP TABLESPACE TEMP INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

SQL> exit


[oracle@TESTQDB09 ~]$ cd /u01/app/oracle/product/11.2.0/dbs/
[oracle@TESTQDB09 dbs]$ ls -ltr
total 47540

-rw-r----- 1 oracle oinstall       47 Nov 28  2014 initDBTESTQ1.ora

-- Moving Spfile from Current ASM Disk Group and Updating Spfile location to NEW ASM DG


[oracle@TESTQDB09 dbs]$ cat initDBTESTQ1.ora
SPFILE='+PRE_TEST_DATA/DBTESTQ/spfileDBTESTQ.ora'
[oracle@TESTQDB09 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbs
[oracle@TESTQDB09 dbs]$
SQL> create pfile='/u01/app/oracle/product/11.2.0/dbs/initMIGTESTq.ora' from spfile;

File created.

SQL>
oracle@TESTQDB09 dbs]$ ls -ltr /u01/app/oracle/product/11.2.0/dbs/initMIGTESTq.ora
-rw-r--r-- 1 oracle asmadmin 1987 May 25 15:08 /u01/app/oracle/product/11.2.0/dbs/initMIGTESTq.ora
[oracle@TESTQDB09 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed May 25 15:10:25 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters and Automatic Storage Management options

SQL> create spfile='+PRE_TEST_DATA_01' from pfile='/u01/app/oracle/product/11.2.0/dbs/initMIGTESTq.ora';

File created.

SQL> exit

[[oracle@TESTQDB09 dbs]$ cat initDBTESTQ1.ora
SPFILE='+PRE_TEST_DATA_01/DBTESTQ/spfileDBTESTQ.ora'

-- Moving Redo Log files

If your redo log group are having 2 members drop 1 from each group

select * from v$logfile;

select * from v$log;

alter database drop logfile member '+PRE_TEST_FRA/dbTESTq/onlinelog/group_2.259.864839121';
alter database drop logfile member '+PRE_TEST_FRA/dbTESTq/onlinelog/group_3.258.864840619';
alter database drop logfile member '+PRE_TEST_FRA/dbTESTq/onlinelog/group_1.260.864839119';
alter database drop logfile member '+PRE_TEST_FRA/dbTESTq/onlinelog/group_4.257.864840621';

-- Now creating new redo log Group at new ASM DG having NORMAL redundancy

alter database add logfile member '+PRE_TEST_DATA_01' to group 1;
alter database add logfile member '+PRE_TEST_DATA_01' to group 2;
alter database add logfile member '+PRE_TEST_DATA_01' to group 3;
alter database add logfile member '+PRE_TEST_DATA_01' to group 4;


-- Drop Second log member from group and also drop the old redo log group as well

alter database drop logfile member '+PRE_TEST_DATA/dbTESTq/onlinelog/group_1.256.864839119';
alter database drop logfile member '+PRE_TEST_DATA/dbTESTq/onlinelog/group_2.262.864839121';
alter database drop logfile member '+PRE_TEST_DATA/dbTESTq/onlinelog/group_3.261.864840617';
alter database drop logfile member '+PRE_TEST_DATA/dbTESTq/onlinelog/group_4.260.864840619';


-- updating configuration at in Services

  ./srvctl config database -d DBTESTQ
  ./srvctl modify database -d DBTESTQ -a 'PRE_TEST_DATA_01,PRE_TEST_FRA_01'
 ./srvctl start instance -d dbTESTq -i DBTESTQ1

Monday, 15 January 2018

Converting the DB to archive Log and Non Archive Log Mode

Archivelog is necessary in recovery of full database and complete backup, Database can be converted to archive log as below:
SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /data/archive_sn
Oldest online log sequence     31
Current log sequence           33
SQL>
Change location of Archive Log List:
SQL> ALTER SYSTEM SET log_archive_dest_2='LOCATION=/u01/archivelog2' scope=both;
Enable Archive log mode
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /data/archive_sn
Oldest online log sequence     31
Next log sequence to archive   33
Current log sequence           33
/************************ Converting Archive Log to Non Archive Log *******************/
Below are steps:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Total System Global Area 1207959552 bytes
Fixed Size                  8620080 bytes
Variable Size             771753936 bytes
Database Buffers          419430400 bytes
Redo Buffers                8155136 bytes
Database mounted.
SQL> alter database noarchivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /data/archive_sn
Oldest online log sequence     31
Current log sequence           33
SQL>

Multiplexing the Controlfile

Controlfile is multiplexed to avoid single point of failure as Controlfille is brain of DB:

SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string       u01/app/oracle/oradata/MYDB/control01.ctl',                                                      'u01/app/oracle/flash_recovery_area/MYDB/control02.ctl
                                                 control_management_pack_access                                                                                                     string      DIAGNOSTIC+TUNING
SQL>

Now we will set location for 3rd Controlfile by below command:


SQL> ALTER SYSTEM SET 
control_files='/u01/app/oracle/oradata/MYDB/control01.ctl','/u01/app/oracle/flash_recovery_area/MYDB/control02.ctl','/u01/multiplexing/control03.ctl' 
SCOPE=SPFILE;

Now manually/physically copy controlfile to that location:

cp /u01/app/oracle/oradata/MYDB/control01.ctl /u01/multiplexing/control03.ctl


SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string       u01/app/oracle/oradata/MYDB/control01.ctl',                                                      'u01/app/oracle/flash_recovery_area/MYDB/control02.ctl',
                                                '/u01/multiplexing/control03.ctl'
                                                 control_management_pack_access                                                                                                     string      DIAGNOSTIC+TUNING


Shutting Down Oracle Database

Oracle Database shutdown in 3 phases as below:

1- Close the DB- By close all new transaction acceptance are stopped, current transaction are complete depends upon command issue.

SQL> alter database close;
Database altered.
SQL>

2- Database Dismount

SQL> alter database dismount;
Database altered.
SQL> 

3- Shutdown Instance- As there is nothing running so we can abort it.

SQL> shutdown abort;
ORACLE instance shut down.
SQL>

Starting Up Oracle Database

Oracle Database starts in 3 below steps:

1- No Mount (where it read server parameter (spfile) file).

Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1207959552 bytes
Fixed Size                  8620080 bytes
Variable Size             771753936 bytes
Database Buffers          419430400 bytes
Redo Buffers                8155136 bytes

2- Mount (It reads controlfile)

SQL> alter database mount;
Database altered.

3- Open (Also know as read-write mode, where the Database is ready for performing operations)

SQL> alter database open;
Database altered.

SQL> select open_mode from v$database;

Installing Oracle 11g on Linux

Unpack Files
Unzip the files.
# 11.2.0.1
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
#11.2.0.2
unzip p10098816_112020_Linux-x86-64_1of7.zip
unzip p10098816_112020_Linux-x86-64_2of7.zip
#11.2.0.3
unzip p10404530_112030_Linux-x86-64_1of7.zip
unzip p10404530_112030_Linux-x86-64_2of7.zip
You should now have a single directory called “database” containing installation files.
Hosts File
The “/etc/hosts” file must contain a fully qualified name for the server.
<IP-address> <fully-qualified-machine-name> <machine-name>
For example.
127.0.0.1 localhost.localdomain localhost
192.168.1.20 tauseef.com
Oracle-Validated Setup
If you plan to use the “oracle-validated” package to perform all your prerequisite setup, follow the instructions at http://public-yum.oracle.com to setup the yum repository for OL, then perform the following command.
# yum install oracle-validated
All necessary prerequisites will be performed automatically.
Manual Setup
If you have not used the “oracle-validated” package to perform all prerequisites, you will need to manually perform the following setup tasks.
Oracle recommend the following minimum parameter settings.
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
The current values can be tested using the following command.
/sbin/sysctl -a | grep <param-name>
Add or amend the following lines in the “/etc/sysctl.conf” file.
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586
Run the following command to change the current kernel parameters.
/sbin/sysctl -p
Add the following lines to the “/etc/security/limits.conf” file.
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 4096
oracle hard nofile 65536
oracle soft stack 10240
Install the following packages if they are not already present.
# From Oracle Linux 5 DVD
cd /media/cdrom/Server
rpm -Uvh –force –nodeps binutils-2.*
rpm -Uvh –force –nodeps compat-libstdc++-33*
rpm -Uvh –force –nodeps compat-libstdc++-33*.i386.rpm
rpm -Uvh –force –nodeps elfutils-libelf*
rpm -Uvh –force –nodeps glibc-2.*
rpm -Uvh –force –nodeps glibc-common-2.*
rpm -Uvh –force –nodeps glibc-devel-2.*
rpm -Uvh –force –nodeps glibc-headers-2.*
rpm -Uvh –force –nodeps gcc-4.*
rpm -Uvh –force –nodeps gcc-c++-4.*
rpm -Uvh –force –nodeps ksh*
rpm -Uvh –force –nodeps libaio-0.*
rpm -Uvh –force –nodeps libaio-devel-0.*
rpm -Uvh –force –nodeps libgomp-4.*
rpm -Uvh –force –nodeps libgcc-4.*
rpm -Uvh –force –nodeps libstdc++-4.*
rpm -Uvh –force –nodeps libstdc++-devel-4.*
rpm -Uvh –force –nodeps make-3.*
rpm -Uvh –force –nodeps sysstat-7.*
rpm -Uvh –force –nodeps unixODBC-2.*
rpm -Uvh –force –nodeps unixODBC-devel-2.*
rpm -Uvh –force –nodeps numactl-devel-*
cd /
eject
Create the new groups and users.
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
useradd -g oinstall -G dba,oper,asmadmin oracle
passwd oracle
Note. We are not going to use the “asmadmin” group, since this installation will not use ASM.
AdditionalSetup
The following setup tasks must be performed regardless of which setup method you used previously.
Disable secure linux by editing the “/etc/selinux/config” file, making sure the SELINUX flag is set as follows.
SELINUX=disabled
Alternatively, this alteration can be done using the GUI tool (Applications > System Settings > Security Level). Click on the SELinux tab and disable the feature. If SELinux is disabled after installation, the server will need a reboot for the change to take effect.
Create the directories in which the Oracle software will be installed.
mkdir -p /u01/app/oracle/product/11.2.0/db11g
chown -R oracle:oinstall /u01
chmod -R 775 /u01
Login as root and issue the following command.
xhost +<machine-name>
Login as the oracle user and add the following lines at the end of the “.bash_profile” file, remembering to adjust them for your specific installation.
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=tauseef.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db11g; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
Installation
Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable.
DISPLAY=<machine-name>:0.0; export DISPLAY
Start the Oracle Universal Installer (OUI) by issuing the following command in the database directory.
./runInstaller
Proceed with the installation of your choice. You can see the type of installation I performed by clicking on the links below to see screen shots of each stage.
Configure Security Updates
Select Install Option
System Class
Node Selection
Select Install Type
Typical Install Configuration
Create Inventory
Perform Prerequisite Checks
Summary
Install Product
Database Configuration Assistant
Database Configuration Assistant 2
Execute Configuration Scripts
Finish
Post Installation
Edit the “/etc/oratab” file setting the restart flag for each instance to ‘Y’.
DB11G:/u01/app/oracle/product/11.2.0/db_1:Y

Installing Oracle 11g on Linux

Unpack Files Unzip the files. # 11.2.0.1 unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip #11.2.0.2 u...