Tuesday, November 24, 2015

Step by Step configuration Oracle Grid Infrastructure for a standalone server (11gR2) into the existing Database System.





Scenario: Oracle (11gR2 11.2.0.3) RDBMS had already been installed on Linux 5.4, After some times, Management decided that ASM should be included (GI installation and configuration ) without disturbing the current environment.


Steps to setup action plan:

1.      RDBMS setup(already installed)
2.      Creating virtual hard disks in VMware for ASM disks
3.      Creating recommended OS groups and user for Grid Infrastructure(GI)
4.      Edit the basic files from root user
5.      Installing Oracle ASM packages, Configuring and load the ASM kernel module (as the “root” user)
6.      Creating ASM disk Volume
7.      Download and Install the GI software only
8.      Configuring the Software Binaries
9.      Creating the ASM instance using ASMCA and Create the ASM disk Group
10.  Create Database Instance




Step-1: RDBMS setup
RDBMS had already been installed. If any DB instance exists, then delete that first if not needed.  In case of Production, data backup must be ensured for restoration purpose.
Step-2: Creating virtual hard disks in VMware for ASM disks

1. CRSDISK1 (2 GB) – for CRSVOL1 disk where Cluster Ready Services (CRS) files will be stored. CRS provides many system management services and interacts with the vendor clusterware to coordinate cluster membership information.
2. DATADISK1 (20 GB) – disk for DATAVOL1 disk. Here database will keep all datafiles, control files, log files …
3. FRADISK1 (10 GB)  disk for FRAVOL1 disk for database Fast Recovery Area (FRA) files. For example: database backup files, copy of database control files.

Open virtual machine properties window and use wizard to create new virtual hard disks:
Step-3: Creating recommended OS groups and user for Grid Infrastructure(GI)

Create user grid and directories

User oracle, group oinstall, dba are ready created by oracle-rdbms-server-11gr2-preinstall:

[root@asmdb ~]# id oracle
uid=500(oracle) gid=501(oinstall) groups=501(oinstall),500(dba),502(oper)
[root@asmdb ~]# id grid
id: grid: No such user
[root@asmdb ~]#

Add this new groups:

 [root@asmdb ~]# groupadd asmadmin
[root@asmdb ~]# groupadd asmdba
[root@asmdb ~]# groupadd asmoper

Create new user grid:
[root@asmdb ~]# useradd -g oinstall -G asmadmin,asmdba,asmoper,dba -c "Grid Infrastructure Owner" grid

Modify user oracle:
 [root@asmdb ~]# usermod -G dba,oper,asmdba -c "Database Owner" oracle

Result:
[root@asmdb ~]# id grid
uid=501(grid) gid=501(oinstall) groups=501(oinstall),500(dba),503(asmadmin),504(asmdba),505(asmoper)
[root@asmdb ~]# id oracle
uid=500(oracle) gid=501(oinstall) groups=501(oinstall),500(dba),502(oper),504(asmdba)

Note: User grid must be put on secondary group dba and user oracle must be put on secondary group asmdba 

Create directories for grid:

*** Oracle software binaries and GI software binaries may be installed into separate mount point.
[root@asmdb ~]# mkdir -p /u01/app/grid
[root@asmdb ~]# mkdir -p /u01/app/grid/product/11.2.0/grid
[root@asmdb ~]# chown -R grid:oinstall /u01/app/grid
[root@asmdb ~]# chmod -R 775 /u01

[root@asmdb ~]# mkdir -p /softgrid
[root@asmdb ~]# chown -R grid:oinstall /softgrid
[root@asmdb ~]# chmod -R 775 /softgrid

Step-4: Edit the basic files from root user

 

Add the following lines to the "/etc/security/limits.conf" file.

[root@asmdb softgrid]# vi  /etc/security/limits.conf
oracle   soft   nofile    131072
oracle   hard   nofile    131072
oracle   soft   nproc    131072
oracle   hard   nproc    131072
oracle   soft   core    unlimited
oracle   hard   core    unlimited
oracle   soft   memlock    50000000
oracle   hard   memlock    50000000
oracle   soft    stack   10240

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

For the Bourne, Bash, or Korn shell, add the following lines to the /etc/profile file by running the following command:


[root@asmdb softgrid]# cat  /etc/profile

if [ \$USER = "oracle" ] || [ \$USER = "grid" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi

Step-5: Installing Oracle ASM packages, Configuring and load the ASM kernel module (as the “root” user)

Install the following RPM for ASM
[root@asmdb Desktop]# rpm -Uvh oracleasm-support-2.1.7-1.el5.x86_64.rpm
[root@asmdb Desktop]# rpm -Uvh oracleasm-2.6.18-238.el5-2.0.5-1.el5.x86_64.rpm
[root@asmdb Desktop]# rpm -Uvh oracleasmlib-2.0.4-1.el5.x86_64.rpm

Configuring and load the ASM kernel module (as the “root” user):
[root@asmdb Desktop]# /usr/sbin/oracleasm configure -i
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting <ENTER> without typing an
answer will keep that current value.  Ctrl-C will abort.

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

The script completes the following tasks:
Creates the /etc/sysconfig/oracleasm configuration file
Creates the /dev/oracleasm mount point
Mounts the ASMLib driver file system

Enter the following command to load the oracleasm kernel module:

[root@asmdb Desktop]# /usr/sbin/oracleasm init
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module "oracleasm": oracleasm
Mounting ASMlib driver filesystem: /dev/oracleasm
Step-6: Creating ASM Disk Volume

Let’s take a look at the available disks in Oracle Linux (remember we have created three additional disks for ASM)

[root@asmdb Desktop]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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        5221    41833260   8e  Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         261     2096451   83  Linux

Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        2610    20964793+  83  Linux

Disk /dev/sdd: 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/sdd1               1        1305    10482381   83  Linux


We’ve got three new disks available for ASM disks:

Disk /dev/sdb: 2147 MB
Disk /dev/sdc: 21.4 GB
Disk /dev/sdd: 10.7 GB

First we have to create partitions to be able to use those disks as ASM disks;

[root@asmdb ~]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb  /dev/sdc  /dev/sdd
[root@asmdb ~]#
[root@asmdb ~]# fdisk /dev/sdb

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

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

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

Same  command should be run for /dev/sdc and /dev/sdd

Creating ASM disks:

 [root@asmdb Desktop]# /usr/sbin/oracleasm createdisk CRSVOL1 /dev/sdb1
Writing disk header: done
Instantiating disk: done
[root@asmdb Desktop]# /usr/sbin/oracleasm createdisk DATAVOL1 /dev/sdc1
Writing disk header: done
Instantiating disk: done
 [root@asmdb Desktop]# /usr/sbin/oracleasm createdisk FRAVOL1 /dev/sdd1
Writing disk header: done
Instantiating disk: done

List ASM disks:
 [root@asmdb Desktop]# /usr/sbin/oracleasm listdisks
CRSVOL1
DATAVOL1
FRAVOL1

Test disks discovery (oracle-discovery is being used by the oracle database creation assistant (dbca))

[root@asmdb Desktop]# oracleasm-discover

Using ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so
[ASM Library - Generic Linux, version 2.0.4 (KABI_V2)]
Discovered disk: ORCL:CRSVOL1 [4192902 blocks (2146765824 bytes), maxio 512]
Discovered disk: ORCL:DATAVOL1 [41929587 blocks (21467948544 bytes), maxio 512]
Discovered disk: ORCL:FRAVOL1 [20964762 blocks (10733958144 bytes), maxio 512]

Step-7: Download and Install the GI software only

Download Oracle Database 11g R 2 Grid Infrastructure (11.2.0.3.0) for Linux x86 –
Linux_11gR2_grid.zip
Copy linux.x64_11gR2_grid.zip to oracle server into /softgrid directory using, for example WinSCP
[grid@asmdb /]$ unzip /softgrid/linux.x64_11gR2_grid.zip

[grid@asmdb /]$ cd /softgrid/grid_11.2.3.0

[grid@asmdb  grid_11.2.3.0]$ ./runInstaller
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 15673 MB Passed
Checking swap space: must be greater than 150 MB. Actual 3999 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2022-01-11_10-65-27AM. Please wait ...

Select the Grid Infrastructure only and follow the wizard, finally finish the installation.



Step-8: Configuring the Software Binaries
To configure and activate a software-only Oracle Grid Infrastructure installation for Oracle Restart, complete the following tasks:
    Login as root and run the roothas.pl script from Grid_home using the following syntax:
    Grid_home/perl/bin/perl -I Grid_home/perl/lib -I Grid_home/crs/install
    Grid_home/crs/install/roothas.pl
    For example, if your Oracle Grid Infrastructure home is /u01/app/oracle/product/11.2.0/grid, then run the following script:
    # /u01/app/oracle/product/11.2.0/grid/perl/bin/perl -I /u01/app/oracle/product/11.2.0/grid/perl/lib -I /u01/app/oracle/product/11.2.0/grid/crs/install  /u01/app/oracle/product/11.2.0/grid/crs/install/roothas.pl
    Change the directory to Grid_home/oui/bin, where Grid_home is the path of the Oracle Grid Infrastructure home.
    Login as the Oracle Restart software owner user and enter the following command:
    ./runInstaller -updateNodeList ORACLE_HOME=Grid_home -defaultHomeName CLUSTER_NODES= CRS=TRUE
    For example:
    $ ./runInstaller -updateNodeList ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid
    -defaultHomeName CLUSTER_NODES= CRS=TRUE
Step-9: Creating the ASM instance using ASMCA and the desired ASM disk groups

Use the SRVCTL utility along with Network Configuration Assistant and Oracle ASMCA to add the listener, the Oracle ASM instance, and all Oracle ASM disk groups to the Oracle Restart configuration.
Now run ASMCA and create ASM instance, provide proper information and using the ASMCA create the desired ASM disk groups.
Step-10: Create Database Instance

Create the DB instance using DBCA and provide proper information like ASM file system with ASM disk groups. For FRA use the FRA disk group.