Wednesday, 9 September 2015

How to install ASM 11gr2 with Role separation (GRID & ORACLE user)

Installing ASM 11gr2 with Role separation (GRID & ORACLE user)

Create the grid & oracle OS users and oinstall, asmadmin, asmdba, asmoper, dba & oracle groups and create base directories ( Connect as ROOT user):

groupadd -g 1000 oinstall
groupadd -g 1100 asmadmin
groupadd -g 1200 dba
groupadd -g 1201 oper
groupadd -g 1300 asmdba
groupadd -g 1301 asmoper

grep oinstall /etc/group
grep asmadmin /etc/group
grep dba /etc/group
grep oper /etc/group
grep asmdba /etc/group
grep asmoper /etc/group

useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash -c "Ur in GRID" grid

useradd -u 1101 -g oinstall -G dba,asmdba,oper -d /home/oracle -s /bin/bash -c "Ur in ORACLE" oracle

usermod -a -G dba grid

Note : If you omit this step, You will get ORA-01031: insufficient privileges” during the database creation.


          Set shell limits for the oracle and grid user:

To improve the performance of the software on Linux systems, you must increase the shell limits for the
oracle user. (Do this in ROOT user)

vi  /etc/security/limits.conf

grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536


Connect as root user and execute the next commands:

id oracle
id grid
mkdir -p /u01/app/grid/product/11.2.0/grid
chown -R grid:oinstall /u01
mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
chown oracle:oinstall /u01
chmod -R 775 /u01

Creating .bash_profiles

#For Oracle user

su – oracle
vi .bash_profile

ORACLE_SID=ORCL; export ORACLE_SID
ORACLE_UNQNAME=ORCL; export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT=”DD-MON-YYYY HH24:MI:SS”
export NLS_DATE_FORMAT
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=${PATH}:/u01/app/common/oracle/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
stty erase ^H
umask 022

#For Grid user

su – grid

vi .bash_profile

ORACLE_SID=+ASM; export ORACLE_SID
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
ORACLE_HOME=/u01/app/grid/product/11.2.0/grid; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT=”DD-MON-YYYY HH24:MI:SS”; export NLS_DATE_FORMAT
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=${PATH}:/u01/app/common/oracle/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
stty erase ^H
umask 022

Install the ASMLIB RPMs (Linux only):

Get the Kernel Version

[root@somoraasm /]# uname -r
2.6.18-164.el5PAE

Get these 3 ASMLib RPMs as per your OS kernel Version

oracleasm-support-2.1.3-1.el5.i386.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-2.6.18-164.el5PAE-2.0.5-1.el5.i686.rpm

Note : You can get RPMs in below Link

Validate oracleasm RPMs were installed:

[root@somoraasm ~]# rpm -qa | grep oracleasm-support-2.1.3-1.el5
oracleasm-support-2.1.3-1.el5
[root@ somoraasm ~]# rpm -qa | grep oracleasmlib-2.0.4-1.el5
oracleasmlib-2.0.4-1.el5
[root@ somoraasm ~]# rpm -qa | grep oracleasm-2.6.18-164.el5PAE-2.0.5- 1.el5
oracleasm-2.6.18-164.el5PAE-2.0.5-1.el5

 Installing the RPM Packages

rpm -Uvh oracleasm-support-2.1.3-1.el5.i386.rpm
rpm -Uvh oracleasmlib-2.0.4-1.el5.i386.rpm
rpm -Uvh oracleasm-2.6.18-164.el5PAE-2.0.5-1.el5.i686.rpm

Configure ASM

/etc/init.d/oracleasm configure -i
Default user to own the driver interface []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done

List the disks available for ASM:

Add 2 Hard disks. We will use 2 SCSI disks of 10 GB each.

Before adding 2 hard disks of 10GB

[root@oraasmprod grid]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1925    15358140   83  Linux
/dev/sda3            1926        2562     5116702+  83  Linux
/dev/sda4            2563        3916    10876005    5  Extended
/dev/sda5            2563        3916    10875973+  8e  Linux LVM

After adding 2 hard disks of 10GB

[root@oraasmprod grid]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1925    15358140   83  Linux
/dev/sda3            1926        2562     5116702+  83  Linux
/dev/sda4            2563        3916    10876005    5  Extended
/dev/sda5            2563        3916    10875973+  8e  Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

To avoid rebooting the machine to mount the hard disks

echo " - - - " >/sys/class/scsi_host/host0/scan

Note : You can restart the server or use the above command.

Now 2 Hard disks added:

fdisk /dev/sdb

[root@oraasmprod grid]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

2nd Disk

fdisk /dev/sdc

[root@oraasmprod grid]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Creating the ASM Disks

/etc/init.d/oracleasm start

Marking the 2 disks as ASM disks

/etc/init.d/oracleasm createdisk DATA /dev/sdb1

[root@oraasmprod grid]# /etc/init.d/oracleasm createdisk DATA /dev/sdb1
Marking disk "VOL1" as an ASM disk:                        [  OK  ]

/etc/init.d/oracleasm createdisk FRA /dev/sdc1

[root@oraasmprod grid]# /etc/init.d/oracleasm createdisk FRA /dev/sdc1
Marking disk "VOL2" as an ASM disk:                        [  OK  ]

Check the ASM disks

/etc/init.d/oracleasm listdisks
/etc/init.d/oracleasm querydisk DATA
/etc/init.d/oracleasm querydisk FRA

Copy the Oracle Database Software & Grid Infrastructure Software to location

[root@oraasmprod grid]# cd /u02
[root@oraasmprod u02]# ls
asm  linux_11gR2_database_1of2.zip  linux_11gR2_database_2of2.zip  linux_11gR2_grid.zip  lost+found

Unzip all RAR files:

[grid@oraasmprod u02]$ unzip linux_11gR2_grid.zip
[grid@oraasmprod u02]$ unzip linux_11gR2_database_1of2.zip
[grid@oraasmprod u02]$ unzip linux_11gR2_database_2of2.zip

Installing Grid Infrastructure Software:

[grid@oraasmprod ~]$ cd /u02
[grid@oraasmprod u02]$ ls
asm  grid  linux_11gR2_database_1of2.zip  linux_11gR2_database_2of2.zip  lost+found
[grid@oraasmprod u02]$ cd grid/
[grid@oraasmprod grid]$ ls
doc  install  response  rpm  runcluvfy.sh  runInstaller  sshsetup  stage  welcome.html
[grid@oraasmprod grid]$ ./runInstaller &
[1] 8980
[grid@oraasmprod grid]$ Starting Oracle Universal Installer...

Checking Temp space: must be greater than 80 MB.   Actual 3651 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2783 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
[grid@oraasmprod grid]$ You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2015-08-10_01-54-41AM.log

Running 2 mandatory scripts

[root@oraasmprod u02]# /u01/app/oraInventory/orainstRoot.sh
[root@oraasmprod u02]# /u01/app/grid/product/11.2.0/grid/root.sh [Enter/y/y/y]

Installing Oracle Software and Database:

[oracle@oraasmprod ~]$ cd /u02/database/
[oracle@oraasmprod database]$ ls
doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[oracle@oraasmprod database]$ ./runInstaller &
[1] 16459
[oracle@oraasmprod database]$ Starting Oracle Universal Installer...

Checking Temp space: must be greater than 80 MB.   Actual 3302 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2634 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
[oracle@oraasmprod database]$ You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2015-08-10_02-53-54AM.log

Running 1 mandatory scripts

[root@oraasmprod u02]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/11.2.0/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin.  Overwrite it? (y/n)
[n]:
The file "oraenv" already exists in /usr/local/bin.  Overwrite it? (y/n)
[n]:
The file "coraenv" already exists in /usr/local/bin.  Overwrite it? (y/n)
[n]:

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.


Add a disk and create a mount point in linux

How to create mount point in Oracle Enterprise Linux

This section shows you that how to create mount point for a newly attached hard disk in OELinux/Linux

1. Check the file system

[root@chromepro ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3263    10747485    5  Extended
/dev/sda5            1926        3263    10747453+  8e  Linux LVM

2. Add a new hard disk

Now add a new hard disk or a disk in system. (Ignore this if you already added & go to Step:4)

3. restart the system to scan the newly added disk to add
                       
Restart the system to scan the new hard disk or a disk by OS level. (Ignore this if you already added & go to Step:4)

[root@chromepro ~]# init 6

Note : If you don’t want to restart the System, enter following command..

echo " - - - " >/sys/class/scsi_host/host0/scan

4. Check the new disk is added or not

[root@chromepro ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3263    10747485    5  Extended
/dev/sda5            1926        3263    10747453+  8e  Linux LVM
                                                                 
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

[root@chromepro ~]# cat /proc/partitions

major minor  #blocks  name

   8     0   26214400 sda
   8     1     104391 sda1
   8     2   10241437 sda2
   8     3    5116702 sda3
   8     4          1 sda4
   8     5   10747453 sda5
   8    16   10485760 sdb
 253     0    8486912 dm-0
 253     1    2228224 dm-1

5. Create Partition for new disk

[root@chromepro ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

6. Check it is successfully partitioned

[root@chromepro ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3263    10747485    5  Extended
/dev/sda5            1926        3263    10747453+  8e  Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   83  Linux

7. Check file is created or not in “/dev” location

[root@chromepro ~]# ls /dev/sd*

/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sda5  /dev/sdb  /dev/sdb1

8. Format the disk as per linux file system with block allocation

[root@chromepro ~]# mkfs.ext3 -b 4096 /dev/sdb

mke2fs 1.39 (29-May-2006)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

9. Enter in “/etc/fstab” for automatic mount

[root@chromepro ~]# cat /etc/fstab

/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/u02              /u02                    ext3    defaults        1 2
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0

[root@chromepro ~]# vi /etc/fstab

/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/u02              /u02                    ext3    defaults        1 2
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/sdb                /u03                    ext3    defaults        1 1

[root@chromepro ~]# cat /etc/fstab

/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/u02              /u02                    ext3    defaults        1 2
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/sdb                /u03                    ext3    defaults        1 1

10. Make directory for mount point

[root@chromepro ~]# mkdir -p /u03

11. Mount the new file to “/u03”

[root@chromepro ~]# mount /dev/sdb /u03

12. Check the mount point is working or not

[root@chromepro ~]# df -hk

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       8220860   3276888   4519628  43% /
/dev/sda3              4956316   3916068    784416  84% /u02
/dev/sda2              9920624   5827120   3581436  62% /u01
/dev/sda1               101086     12145     83722  13% /boot
tmpfs                   556160         0    556160   0% /dev/shm
/dev/sdb              10321208    154236   9642684   2% /u03