Archives For installation

if you work with perl and want to connect to oracle you might want to DBD::Oracle. this is a oracle database driver for the perl DBI module.

there is no need to install this on a server which hosts an oracle instance. all you need from an oracle perspective is the oracle instant client.

to prepare the installation download the following files ( for your architecture ) from the above link:

  • instantclient-basic-linux.x64-11.2.0.3.0.zip
  • instantclient-sqlplus-linux.x64-11.2.0.3.0.zip
  • instantclient-sdk-linux.x64-11.2.0.3.0.zip

as I did a default mint install I additionally had to install the “Linux kernel AIO access library” package which is required for the instant client to work:

sudo apt-get install libaio1

all you need to do for getting the instant client to work is to unzip the downloaded files and setup your environment. in may case I unzipped the files to my home directory in a folder called oracle:

ls -la ~/oracle/instantclient_11_2/
total 185012
drwxr-xr-x 3 daniel daniel      4096 Aug 31 06:57 .
drwxr-xr-x 3 daniel daniel      4096 Aug 31 06:51 ..
-rwxrwxr-x 1 daniel daniel     25308 Sep 17  2011 adrci
-rw-rw-r-- 1 daniel daniel       437 Sep 17  2011 BASIC_README
-rwxrwxr-x 1 daniel daniel     46228 Sep 17  2011 genezi
-r--r--r-- 1 daniel daniel       368 Sep 17  2011 glogin.sql
lrwxrwxrwx 1 daniel daniel        56 Aug 31 06:57 libclntsh.so -> /home/daniel/oracle/instantclient_11_2/libclntsh.so.11.1
-rwxrwxr-x 1 daniel daniel  52761218 Sep 17  2011 libclntsh.so.11.1
-r-xr-xr-x 1 daniel daniel   7955322 Sep 17  2011 libnnz11.so
-rwxrwxr-x 1 daniel daniel   1971762 Sep 17  2011 libocci.so.11.1
-rwxrwxr-x 1 daniel daniel 118408281 Sep 17  2011 libociei.so
-r-xr-xr-x 1 daniel daniel    164836 Sep 17  2011 libocijdbc11.so
-r-xr-xr-x 1 daniel daniel   1503303 Sep 17  2011 libsqlplusic.so
-r-xr-xr-x 1 daniel daniel   1477446 Sep 17  2011 libsqlplus.so
-r--r--r-- 1 daniel daniel   2095661 Sep 17  2011 ojdbc5.jar
-r--r--r-- 1 daniel daniel   2714016 Sep 17  2011 ojdbc6.jar
drwxrwxr-x 4 daniel daniel      4096 Sep 17  2011 sdk
-r-xr-xr-x 1 daniel daniel      9352 Sep 17  2011 sqlplus
-rw-rw-r-- 1 daniel daniel       441 Sep 17  2011 SQLPLUS_README
-rwxrwxr-x 1 daniel daniel    191237 Sep 17  2011 uidrvci
-rw-rw-r-- 1 daniel daniel     66779 Sep 17  2011 xstreams.jar

for the environment I created a little file and sourced it:

echo"ORACLE_HOME=/home/daniel/oracle/instantclient_11_2
LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
PATH=$ORACLE_HOME:$PATH
TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_HOME LD_LIBRARY_PATH PATH TNS_ADMIN" > ~/ora_env.sh 
mkdir -p ~/oracle/instantclient_11_2/network/admin
. ./ora_env.sh

before going on you should test if you can execute sqlplus ( if this does not work something is wrong with your environment ):

sqlplus
SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 31 07:26:46 2012
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Enter user-name: 

as a final test create a tnsnames.ora file with the connection parameters for your database and check if you can establish a connection:

echo "my_oracle_db=
  (DESCRIPTION=
    (ADDRESS=
      (PROTOCOL=TCP)
      (HOST=192.168.10.39)
      (PORT=1530)
    )
    (CONNECT_DATA=
      (GLOBAL_NAME=dbs300.local)
      (SID=dbs300)
    )
  )" >> ~/oracle/instantclient_11_2/network/admin/tnsnames.ora

let’s see if it works:

sqlplus my_oracle_usr/oracle@my_oracle_db
SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 31 07:53:44 2012
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
|-----------------------------------------------------------------|
| This system is for the use of authorized users only.		  |
| Individuals using this computer system without authority, or in |
| excess of their authority, are subject to having all of their   |
| activities on this system monitored and recorded by system	  |
| personnel.							  |
|-----------------------------------------------------------------|
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

as expected.

so far for the oracle part. because DBD::Oracle is a driver for the DBI package you probably need to install it first. you should have cpan installed along with your perl distribution.

which cpan
/usr/local/bin/cpan

if it’s not there search with your package manager and install it. for ubuntu/debian based distributions:

apt search cpan

for rpm based distributions:

yum search cpan

cpan requires an initial setup, but as this is straight forward I’ll just mention the important questions/answers:

cpan
Would you like to configure as much as possible automatically? [yes] yes
What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib] sudo

that’s it. now we are ready to install the DBI module:

cpan
install DBI
quit

for the DBD::Oracle module I decided to just download the source file and to do a manual compilation/installation:

cpan
get DBD::Oracle
quit
cd ~/.cpan/build/DBD-Oracle-1.50*
perl Makefile.PL
make
sudo make install

easy, isn’t it ?

create a little perl script and see if you can execute a test-statement:

echo "#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my @results;
my $db = DBI->connect ( 'dbi:Oracle:host=192.168.10.39;sid=dbs300;port=1530', 'my_oracle_usr/oracle', '' )
         or die "Connection failed: ". DBI->errstr;
my $sql = $db->prepare('SELECT \'connected\' FROM DUAL' )
         or die "Statement preparation failed: ". $db->errstr;
$sql->execute()
      or die "Statement execution failed:".$sql->errstr;
while ( @results = $sql->fetchrow_array() ) {
   print "$results[0] \n";
}
1;" >> oracle_test.pl
chmod u+x oracle_test.pl
./oracle_test.pl 
connected 

time to have fun with perl and oracle :)

Advertisements

Before I start with the database creation, there remain some steps to be performed. Because I will place the files inside the ASM instance there is no need to create separate filesystems for datafiles, redologs, control-files. But still I want a custom location for the audit logs, pfile and diagnostic destination. Let’s prepare this:

su -
mkdir /oradata/DB112
chown oracle:dba /oradata/DB112
su - oracle
mkdir -p /oradata/DB112/admin/pfile
mkdir /oradata/DB112/admin/adump

The easiest, and probably the best way for most environments is to go with the defaults. Let’s start by creating a minimal pfile…

su - oracle
echo "*.audit_file_dest='/oradata/DB112/admin/adump'
*.control_files='+DB112_DATA_DG','+DB112_ARCH_DG'
*.db_block_size=8192
*.db_name='DB112'
*.instance_name='DB112'
*.sga_max_size=256M
*.sga_target=256M
*.undo_tablespace='undotbs1'
*.diagnostic_dest=/oradata/DB112/admin" > /oradata/DB112/admin/pfile/initDB112.ora

… check that we can initially start the instance…

sqlplus / as sysdba
startup force nomount pfile=/oradata/DB112/admin/pfile/initDB112.ora

… create the server parameter file:

create spfile='/oradata/DB112/admin/pfile/spfileDB112.ora' from pfile='/oradata/DB112/admin/pfile/initDB112.ora';

… create a link to the server parameter file ( for oracle to find the file )

!ln -s /oradata/DB112/admin/pfile/spfileDB112.ora $ORACLE_HOME/dbs/spfileDB112.ora

… restart without specifying a pfile to see if the spfile gets used:

startup force nomount
show parameter pfile;

… and create the database

create database DB112
logfile
group 1 ('+DB112_DATA_DG','+DB112_ARCH_DG') size 16M reuse,
group 2 ('+DB112_DATA_DG','+DB112_ARCH_DG') size 16M reuse,
group 3 ('+DB112_DATA_DG','+DB112_ARCH_DG') size 16M reuse
character set utf8
national character set AL16UTF16
datafile '+DB112_DATA_DG' size 512M reuse autoextend on next 8M maxsize 1024M extent management local
default temporary tablespace TEMP tempfile '+DB112_DATA_DG' size 64M reuse autoextend on next 8M maxsize 1024M
sysaux datafile '+DB112_DATA_DG' size 512M reuse autoextend on next 8M maxsize 1024M
default tablespace USERS datafile '+DB112_DATA_DG' size 4m reuse autoextend on next 8m maxsize 16M
undo tablespace UNDOTBS1 datafile '+DB112_DATA_DG' size 64M reuse autoextend on next 8M maxsize 1024M;

… create the dictionary:

@?/rdbms/admin/catalog.sql

… and the plsql stuff:

@?/rdbms/admin/catproc.sql

… create the help tables for sqlplus and populate it:

@?/sqlplus/admin/help/hlpbld.sql helpus.sql
shutdown immediate;
exit;

Done. Database created. What else ? Right, register the database with the Cluster Stack and create a listener:

srvctl add database -d DB112 -o $ORACLE_HOME -p $ORACLE_HOME/dbs/spfileDB112.ora
srvctl add listener -l listener_DB112 -p 1521 -o $ORACLE_HOME
touch chmod 770 /opt/oracle/product/base/11.2.0.3/network/admin/listener.ora
chmod 770 /opt/oracle/product/base/11.2.0.3/
chmod 770 /opt/oracle/product/base/11.2.0.3/dbs
chmod 770 /opt/oracle/product/base/11.2.0.3/network/
chmod 770 /opt/oracle/product/base/11.2.0.3/network/admin
chmod 770 /opt/oracle/product/base/11.2.0.3/network/admin/listener.ora
srvctl start listener -l listener_DB112
srvctl start database -d DB112

Please notice: The chmods are dirty tricks to avoid CRS-5010 issues. The reason for the CRS-5010 messages is that the cluster stack runs under a different user ( grid in this case ) and is not able to update the files. Maybe there is a fix in the future.

Let’s check the resources and do a reboot to check if all comes up again:

su - grid
crsctl status resource -t
su -
reboot
su - grid
crsctl status resource -t

You should see that the resources are up and running, something like:

+ASM@oracleplayground.fun grid:/home/grid $ crsctl status resource -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DB112_ARCH_DG.dg
ONLINE ONLINE oracleplayground
ora.DB112_DATA_DG.dg
ONLINE ONLINE oracleplayground
ora.LISTENER_ASM.lsnr
ONLINE ONLINE oracleplayground
ora.LISTENER_DB112.lsnr
ONLINE ONLINE oracleplayground
ora.asm
ONLINE ONLINE oracleplayground Started
ora.ons
OFFLINE OFFLINE oracleplayground
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE oracleplayground
ora.db112.db
1 ONLINE ONLINE oracleplayground Open
ora.diskmon
1 OFFLINE OFFLINE
ora.evmd
1 ONLINE ONLINE oracleplayground

For your convenience, here the complete database creation script:

echo "*.audit_file_dest='/oradata/DB112/admin/adump'
*.control_files='+DB112_DATA_DG','+DB112_ARCH_DG'
*.db_block_size=8192
*.db_name='DB112'
*.instance_name='DB112'
*.sga_max_size=256M
*.sga_target=256M
*.undo_tablespace='undotbs1'
*.diagnostic_dest=/oradata/DB112/admin" > /oradata/DB112/admin/pfile/initDB112.ora
sqlplus / as sysdba
startup force nomount pfile=/oradata/DB112/admin/pfile/initDB112.ora
create spfile='/oradata/DB112/admin/pfile/spfileDB112.ora' from pfile='/oradata/DB112/admin/pfile/initDB112.ora';
!ln -s /oradata/DB112/admin/pfile/spfileDB112.ora $ORACLE_HOME/dbs/spfileDB112.ora
startup force nomount
show parameter pfile;
create database DB112
logfile
group 1 ('+DB112_DATA_DG','+DB112_ARCH_DG') size 16M reuse,
group 2 ('+DB112_DATA_DG','+DB112_ARCH_DG') size 16M reuse,
group 3 ('+DB112_DATA_DG','+DB112_ARCH_DG') size 16M reuse
character set utf8
national character set AL16UTF16
datafile '+DB112_DATA_DG' size 512M reuse autoextend on next 8M maxsize 1024M extent management local
default temporary tablespace TEMP tempfile '+DB112_DATA_DG' size 64M reuse autoextend on next 8M maxsize 1024M
sysaux datafile '+DB112_DATA_DG' size 512M reuse autoextend on next 8M maxsize 1024M
default tablespace USERS datafile '+DB112_DATA_DG' size 4m reuse autoextend on next 8m maxsize 16M
undo tablespace UNDOTBS1 datafile '+DB112_DATA_DG' size 64M reuse autoextend on next 8M maxsize 1024M;
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/sqlplus/admin/help/hlpbld.sql helpus.sql
shutdown immediate;
exit;
srvctl add database -d DB112 -o $ORACLE_HOME -p $ORACLE_HOME/dbs/spfileDB112.ora
srvctl add listener -l listener_DB112 -p 1521 -o $ORACLE_HOME
touch chmod 770 /opt/oracle/product/base/11.2.0.3/network/admin/listener.ora
chmod 770 /opt/oracle/product/base/11.2.0.3/
chmod 770 /opt/oracle/product/base/11.2.0.3/dbs
chmod 770 /opt/oracle/product/base/11.2.0.3/network/
chmod 770 /opt/oracle/product/base/11.2.0.3/network/admin
chmod 770 /opt/oracle/product/base/11.2.0.3/network/admin/listener.ora
srvctl start listener -l listener_DB112
srvctl start database -d DB112

To summarize the situation until now: The operating system is installed and configured. On top of it I installed the grid infrastructure software, configured it for single node usage, patched it to the latest release and created the ASM instance including to disk-groups. Several reboot tests proved that the whole stack survives a server reboot and we do not need to create any custom scripts to manage the shutdown and startup of the resources managed by the cluster stack.

Now we are doing the database software installation ( in much se same way we installed the grid infrastructure software ). You will notice once again: If all the prerequisites have been met, the software installation is no magic at all.

If you did not transer the source files ( p10404530_112030_Linux-x86-64_1of7.zip and p10404530_112030_Linux-x86-64_2of7.zip) to your Virtual Machine, now is the time to do so ( see here for a description on how to do it ).

As the database software will be installed under the “oracle” user, establish a ssh connection to your Virtual Machine and do the installation ( I will do a software only installation here, nothing will be configured for the moment ):

su - oracle
cd /opt/oracle/stage
unzip p10404530_112030_Linux-x86-64_1of7.zip
unzip p10404530_112030_Linux-x86-64_2of7.zip
cd database
./runInstaller \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_BASE=/opt/oracle/product/base \
ORACLE_HOME=/opt/oracle/product/base/11.2.0.3 \
ORACLE_HOME_NAME=H112030 \
UNIX_GROUP_NAME=oinstall \
oracle.install.db.DBA_GROUP=dba \
oracle.install.db.OPER_GROUP=oper \
FROM_LOCATION=../stage/products.xml \
INVENTORY_LOCATION=/opt/oracle/oraInventory \
SELECTED_LANGUAGES=en \
oracle.install.db.InstallEdition=EE \
DECLINE_SECURITY_UPDATES=true \
-ignoreSysPrereqs \
-ignorePrereq \
-waitforcompletion \
-silent
su -
/opt/oracle/product/base/11.2.0.3/root.sh

Again, that’s all what needs to be done.

Let’s set up some environment variables and aliases…

su - oracle
echo "ORACLE_HOME=/opt/oracle/product/base/11.2.0.3
ORACLE_SID=DB112
LD_LIBRARY_PATH=/opt/oracle/product/base/11.2.0.3/lib:$LD_LIBRARY_PATH
PATH=/opt/oracle/product/base/11.2.0.3/bin:$PATH
PS1='\[33[1;34m\]${ORACLE_SID}\[33[1;33m\]@\[33[1;32m\]`uname -n`\[33[0m\] $LOGNAME:$PWD $ '
export ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH PS1
alias sqlp='sqlplus '\''/ as sysdba'\'''
" >> ~/.bash_profile

A final little test, to prove that sqlplus is working:

su - oracle
sqlp

… you should see something like this:

DB112@oracleplayground.fun oracle:/home/oracle $ sqlp
SQL*Plus: Release 11.2.0.3.0 Production on Mon Mar 26 14:42:12 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> exit;
Disconnected
DB112@oracleplayground.fun oracle:/home/oracle $

Congratulations, now you are prepared to set up the oracle database instance.

Again, remember to take a snapshot of your Virtual Machine if you want to save your work or if you want to revert to this point. Delete the source files if you do not want to become your Virtual Machine too big before:

su - oracle
cd /opt/oracle/stage/
rm -rf database p10404530_112030_Linux-x86-64_1of7.zip p10404530_112030_Linux-x86-64_2of7.zip

On your workstation create the snapshot:

vboxmanage snapshot oracleplayground take "after database software installation"

OS ready, Grid Infrastructure ready, patched to the latest release. Time to start with the “real” things…

Thanks to the virtualization technology ( Virtual Box ) in this case, it is easy to add storage to you machine. If running, shut down your Virtual Machine and add two disks to it.

From your workstation, execute:

vboxmanage storagectl oracleplayground --name "SCSI Controller" --add scsi --controller LSILogic
vboxmanage createhd --filename ~/VirtualBox\ VMs/oracleplayground/oracleplayground_asm1.vdi --size=10240 --variant Fixed
vboxmanage createhd --filename ~/VirtualBox\ VMs/oracleplayground/oracleplayground_asm2.vdi --size=10240 --variant Fixed
vboxmanage storageattach oracleplayground --storagectl "SCSI Controller" --port 1 --device 0 --type hdd --medium ~/VirtualBox\ VMs/oracleplayground/oracleplayground_asm1.vdi
vboxmanage storageattach oracleplayground --storagectl "SCSI Controller" --port 2 --device 0 --type hdd --medium ~/VirtualBox\ VMs/oracleplayground/oracleplayground_asm2.vdi

What happened: We created a new SCSI Controller for our Virtual Machine, created two 10gb hard disks and attached them to the Controller.

Startup your Virtual Machine and check the devices:

su -
ls -la /dev/sd*
brw-r----- 1 root disk 8, 0 Mar 23 13:02 /dev/sda
brw-r----- 1 root disk 8, 16 Mar 23 13:02 /dev/sdb

These are our newly created disks. What we will need for ASM is one partition for each disk, so lets create the partitions:

su -
fdisk /dev/sda
fdisk /dev/sdb

The commands for creating the partitions are ( in this sequence ): p n p 1 enter enter w quit

If we check the devices again, we now can see the newly created partitions:

ls -la /dev/sd*
brw-r----- 1 root disk 8, 0 Mar 23 13:06 /dev/sda
brw-r----- 1 root disk 8, 1 Mar 23 13:06 /dev/sda1
brw-r----- 1 root disk 8, 16 Mar 23 13:09 /dev/sdb
brw-r----- 1 root disk 8, 17 Mar 23 13:09 /dev/sdb1

To be usable to asm, the disks must belong to the grid user. We could change the permissions now with chmod, but because we want this to be persistent across reboots we create udev rules for it:

su -
echo "KERNEL==\"sd[a-b][1-9]*\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\"" > /etc/udev/rules.d/61-asm.rules
reboot

Once the Virtual Machine rebooted, check the devices again and you will see that the owner,group and permissions changed:

su -
ls -la /dev/sd*
brw-r----- 1 root disk 8, 0 Mar 23 13:17 /dev/sda
brw-rw---- 1 grid asmadmin 8, 1 Mar 23 13:17 /dev/sda1
brw-r----- 1 root disk 8, 16 Mar 23 13:17 /dev/sdb
brw-rw---- 1 grid asmadmin 8, 17 Mar 23 13:17 /dev/sdb1

Now we are prepared for creating our ASM instance. Because we are lazy, lets define two variables for the init.ora and the spfile:

su - grid
INITORA=$ORACLE_HOME/dbs/init+ASM.ora
SPFILE=$ORACLE_HOME/dbs/spfile+ASM.ora

Create a minimal set of parameters:

echo "instance_type='asm'
memory_target=128m
memory_max_target=128m
" > ${INITORA}

… and start the cssd resource ( which is the cluster synchronization service, required by ASM ):

crsctl start resource ora.cssd

You should see the following output:

CRS-2672: Attempting to start 'ora.cssd' on 'oracleplayground'
CRS-2672: Attempting to start 'ora.diskmon' on 'oracleplayground'
CRS-2676: Start of 'ora.diskmon' on 'oracleplayground' succeeded
CRS-2676: Start of 'ora.cssd' on 'oracleplayground' succeeded

Let’s try if we can startup and shutdown our ASM instance:

sqlplus /nolog <<EOF
connect / as sysasm
startup force nomount pfile=${INITORA};
shutdown abort;
exit;
EOF

The output should look like:

SQL*Plus: Release 11.2.0.3.0 Production on Fri Mar 23 13:28:29 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> Connected to an idle instance.
SQL> ASM instance started
Total System Global Area 267227136 bytes
Fixed Size 2227504 bytes
Variable Size 239833808 bytes
ASM Cache 25165824 bytes
SQL> ASM instance shutdown
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Automatic Storage Management option

Ok, basically we are able to startup our ASM instance. As we want our ASM instance managed by the cluster stack, we will need to create and register some resources.

Start by adding the listener for the ASM instance:

srvctl add listener -l listener_ASM -o $ORACLE_HOME -p 1526

… continue with adding ASM itself:

srvctl add asm -l listener_ASM -p ${INITORA}

… startup listener and ASM:

srvctl start listener -l listener_ASM
srvctl start asm

… and check the resources ( we will use the alias again. you can also type “crsctl status resource -t” ):

crsstat

If you followed the steps, this is what you will see:

--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER_ASM.lsnr
ONLINE ONLINE oracleplayground
ora.asm
ONLINE ONLINE oracleplayground Started
ora.ons
OFFLINE OFFLINE oracleplayground
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE oracleplayground
ora.diskmon
1 OFFLINE OFFLINE
ora.evmd
1 ONLINE ONLINE oracleplayground

Two new resources are showing up, the listener and the ASM instance.

Lets create a spfile for the ASM instance:

srvctl stop asm
sqlplus /nolog <<EOF
connect / as sysasm
create spfile='${SPFILE}' from pfile='${INITORA}';
startup force;
show parameter pfile
shutdown abort;
exit;
EOF

You can ignore the “ORA-15110: no disk-groups mounted” message in the output. We will create disk-groups shortly.

As we registered ASM with a pfile in the cluster stack, we need to modify this:

srvctl modify asm -p ${SPFILE}
srvctl start asm
srvctl config asm
crsctl status resource -t
rm -f ${INITORA}

Fine, ASM is now managed by cluster stack. We do not need to worry about shutting down or starting up the instance when the server reboots anymore. And we even do not need to create startup or shutdown scripts for the ASM instance.

ASM without any disks and disk-group does not make much sense. Lets create some:

sqlplus /nolog <<EOF
connect / as sysasm
alter system set asm_diskstring='/dev/sd*' scope=both;
create diskgroup DB112_DATA_DG external redundancy
disk '/dev/sda1' name DB112_DATA_DG_VOL01
attribute
'au_size' = '4M'
, 'compatible.asm' = '11.2'
, 'compatible.rdbms' = '11.2'
;
create diskgroup DB112_ARCH_DG external redundancy
disk '/dev/sdb1' name DB112_ARCH_DG_VOL01
attribute
'au_size' = '4M'
, 'compatible.asm' = '11.2'
, 'compatible.rdbms' = '11.2'
;
exit;
EOF

Work done. You can check the cluster stack for the status of the resources:

crsstat

Notice the disk-groups showing up:

--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DB112_ARCH_DG.dg
ONLINE ONLINE oracleplayground
ora.DB112_DATA_DG.dg
ONLINE ONLINE oracleplayground
ora.LISTENER_ASM.lsnr
ONLINE ONLINE oracleplayground
ora.asm
ONLINE ONLINE oracleplayground Started
ora.ons
OFFLINE OFFLINE oracleplayground
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE oracleplayground
ora.diskmon
1 OFFLINE OFFLINE
ora.evmd
1 ONLINE ONLINE oracleplayground

Although it is optional, let’s create some directories for holding the audit logs and diagnostic files. I personally prefer to have it outside the ORACLE_HOME:

su -
mkdir -p /oradata/+ASM
chown grid:oinstall /oradata/+ASM
su - grid
mkdir /oradata/+ASM/admin
mkdir /oradata/+ASM/admin/adump
sqlpa
alter system set audit_file_dest='/oradata/+ASM/admin/adump' scope=spfile;
alter system set diagnostic_dest='/oradata/+ASM/admin' scope=spfile;
exit;
srvctl stop asm -f
srvctl start asm
sqlpa
show parameter audit_file_dest
show parameter diagnostic_dest
exit
echo "ADR_BASE_LISTENER_ASM=/oradata/+ASM/admin" >> /opt/oracle/product/crs/11.2.0.3/network/admin/listener.ora
srvctl stop listener -l listener_asm
srvctl start listener -l listener_asm

What happened: We told the listener and the asm instance to place the traces and logs at the location we want to.

Finally, let’s create an alias for the sqlplus connections:

echo "alias sqlpa='sqlplus '\''/ as sysasm'\'''" >> ~/.bash_profile

If you re-login as grid user, you can now connect the easy way:

sqlpa

As usual ( on your workstation ), if you like, create a snapshot to save your work:

vboxmanage snapshot oracleplayground take "asm running"

For your convenience, here’s the complete script:

#!/bin/bash
if [ $(id -un) != "grid" ]; then
echo "you must run this as root"
exit 0
fi
INITORA=$ORACLE_HOME/dbs/init+ASM.ora
SPFILE=$ORACLE_HOME/dbs/spfile+ASM.ora
echo "instance_type='asm'
memory_target=128m
memory_max_target=128m
" > ${INITORA}
crsctl start resource ora.cssd
sqlplus /nolog <<EOF
connect / as sysasm
startup force nomount pfile=${INITORA};
shutdown abort;
exit;
EOF
srvctl add listener -l listener_ASM -o $ORACLE_HOME -p 1526
srvctl add asm -l listener_ASM -p ${INITORA}
srvctl start listener -l listener_ASM
srvctl start asm
srvctl stop asm -f
crsctl status resource -t
sqlplus /nolog <<EOF
connect / as sysasm
create spfile='${SPFILE}' from pfile='${INITORA}';
startup force;
show parameter pfile
shutdown abort;
exit;
EOF
srvctl modify asm -p ${SPFILE}
srvctl start asm
srvctl config asm
crsctl status resource -t
rm -f ${INITORA}
sqlplus /nolog <<EOF
connect / as sysasm
alter system set asm_diskstring='/dev/sd*' scope=both;
create diskgroup DB112_DATA_DG external redundancy
disk '/dev/sda1' name DB112_DATA_DG_VOL01
attribute
'au_size' = '4M'
, 'compatible.asm' = '11.2'
, 'compatible.rdbms' = '11.2'
;
create diskgroup DB112_ARCH_DG external redundancy
disk '/dev/sdb1' name DB112_ARCH_DG_VOL01
attribute
'au_size' = '4M'
, 'compatible.asm' = '11.2'
, 'compatible.rdbms' = '11.2'
;
exit;
EOF

The OS is prepared and everything is configured. Time to come to the first part of the installation: Oracle Grid Infrastructure

If you did not already transfer the source files to your Virtual Machine do it now. If your workstation runs on linux, here is an example:

scp -P 3000 p10404530_112030_Linux-x86-64_1of7.zip grid@localhost:/opt/oracle/stage
scp -P 3000 p10404530_112030_Linux-x86-64_2of7.zip grid@localhost:/opt/oracle/stage
scp -P 3000 p10404530_112030_Linux-x86-64_3of7.zip grid@localhost:/opt/oracle/stage
scp -P 3000 p13348650_112030_LINUX.zip grid@localhost:/opt/oracle/stage

Windows users may use tools like winscp, filezilla or cygwin to name a few of it.

As the Grid Infrastructure will be installed under the “grid” user, establish a ssh connection to your Virtual Machine and do the installation ( we will do a software only installation here, nothing will be configured for the moment ):

su - grid
cd /opt/oracle/stage
unzip p10404530_112030_Linux-x86-64_3of7.zip
cd grid
./runInstaller \
INVENTORY_LOCATION=/opt/oracle/oraInventory \
SELECTED_LANGUAGES=en \
oracle.install.option=CRS_SWONLY \
ORACLE_BASE=/opt/oracle/product/base \
ORACLE_HOME=/opt/oracle/product/crs/11.2.0.3 \
ORACLE_HOME_NAME=HCRS112030 \
UNIX_GROUP_NAME=oinstall \
oracle.install.asm.OSDBA=asmdba \
oracle.install.asm.OSASM=asmadmin \
FROM_LOCATION=../stage/products.xml \
DECLINE_SECURITY_UPDATES=true \
-ignoreSysPrereqs \
-ignorePrereq \
-waitforcompletion \
-silent
su -
/opt/oracle/oraInventory/orainstRoot.sh
/opt/oracle/product/crs/11.2.0.3/root.sh

That’s it for the software installation. Surprised ? The most important thing to remember if installing oracle software is: Read the installation guides and fulfill all the requirements. If you do this, the installation will be fast and easy.

Some explanations for the above commands:

  • runInstaller: this is oracle installer on linux/unix ( it is setup.exe on windows )
  • INVENTORY_LOCATION: the location where you want to store the central oracle inventory
  • SELECTED_LANGUAGES: the languages you want to install for the product
  • oracle.install.option: how do you want to install ( CRS_SWONLY is for installing the software, but do not configure anything )
  • ORACLE_BASE: the location you want to use for the $ORACLE_BASE
  • ORACLE_HOME: the location where you want to install the product, this is the $ORACLE_HOME
  • UNIX_GROUP_NAME: the OS group you want to own the installed software
  • oracle.install.asm.OSDBA: the OS group you want to use as asm dba
  • oracle.install.asm.OSASM: the OS group you want to use for sysasm
  • FROM_LOCATION: references the xml where all the products are defined
  • DECLINE_SECURITY_UPDATES: true means: do not try to connect to oracle support for downloading the latest patches
  • -ignoreSysPrereqs: ignore the system prerequisites
  • -ignorePrereq: ignore all the other prerequisites
  • -waitforcompletion: wait until the installation completes before returning to the shell
  • -silent: do a silent installation ( do not use the graphical mode )

Take a look at the sample response file if you want to learn about all the other options you can use ( /opt/oracle/stage/grid/response/grid_install.rsp ).

The root scripts:

  • /opt/oracle/oraInventory/orainstRoot.sh : Creates the pointer to the oraInventory and sets the correct permissions
  • /opt/oracle/product/crs/11.2.0.3/root.sh: Calls various other scripts to set up the installation

Lets see if if everything works as expected and configure the cluster stack for single node ( The Grid Infrastructure sofware is exactly the same for Cluster and Single Node installations. For single node installations, oracle calls this “Oracle Restart” ):

su -
/opt/oracle/product/crs/11.2.0.3/crs/install/roothas.pl

The output should like this:

[root@oracleplayground stage]# /opt/oracle/product/crs/11.2.0.3/crs/install/roothas.pl
Using configuration parameter file: /opt/oracle/product/crs/11.2.0.3/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node oracleplayground successfully pinned.
Adding Clusterware entries to inittab
oracleplayground 2012/03/23 09:18:15 /opt/oracle/product/crs/11.2.0.3/cdata/oracleplayground/backup_20120323_091815.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server

If you had troubles you can deconfigure the whole stack and try again:

su -
/opt/oracle/product/crs/11.2.0.3/crs/install/roothas.pl -deconfig -force
### check the logfiles ( $ORACLE_HOME/log/oracleplayground/* ) for the issue and try to configure again
/opt/oracle/product/crs/11.2.0.3/crs/install/roothas.pl

There is one important thing to note: Take a look at this line:

Using configuration parameter file: /opt/oracle/product/crs/11.2.0.3/crs/install/crsconfig_params

This is the one and only configuration file you will need to adjust if setting up the stack for a cluster ( If you want to configure for a cluster rootcrs.pl will be used instead of roothas.pl, but the configuration file keeps the same ).
In our case we do not need to modify it, as we will work with a single node.

What happened here:
The script created same trace directories, the olr ( oracle local registry ), pinned the node and added a call to inittab. Can verify this with:

cat /etc/inittab | grep ohas

If you take a look at your processes now, you’ll notice that several oracle processes started up:

ps -ef | grep ora

This are the basic cluster stack processes which will manage you oracle infrastructure.

  • ohasd.bin: the process resonsible for starting up all the cluster processes
  • oraagent.bin: will spawn agents to start resources
  • evmd.bin: the event volume manager daemon
  • evmlogger.bin: spawned by evmd to log events

To make a life a bit easier for us, lets define some aliases and environment variables for the grid user:

su - grid
echo "ORACLE_HOME=/opt/oracle/product/crs/11.2.0.3
ORACLE_BASE=/opt/oracle/base
ORACLE_SID=+ASM
PATH=$ORACLE_HOME/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
PS1='\[33[1;34m\]${ORACLE_SID}\[33[1;33m\]@\[33[1;32m\]`uname -n`\[33[0m\] $LOGNAME:$PWD $ '
export ORACLE_HOME ORACLE_BASE ORACLE_SID PATH LD_LIBRARY_PATH PS1
alias crsstat='crsctl status resource -t'" >> ~/.bash_profile

It is a good idea to reboot your Virtual Machine now and to check if the cluster stack comes up again.

su -
reboot

Once the Virtual Machine is up and running again ( notice that it will take some time for the oracle processes to come up ), verify if you can interact with the stack ( we will use the alias defined above for this ):

su - grid
crsstat

If everything is fine, the output should like this:

--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ons
OFFLINE OFFLINE oracleplayground
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 OFFLINE OFFLINE
ora.diskmon
1 OFFLINE OFFLINE
ora.evmd
1 ONLINE ONLINE oracleplayground

To summarize: We installed the Grid Infrastructure software without doing any configuration initially and executed the root scripts for setting up permissions, the oracle inventory and the grid infrastructure software. roothas.pl did the configuration of the cluster stack, added an entry to the inittab and generated the oracle local registry. We did a reboot to check if everything comes up again and defined some environment variables and aliases to make life a bit easier for us.

If you’ll ask yourself what the crsctl is for: We will come back to all the commands in next posts and introduce them when appropriate.

In the next post we will apply the first patch to the grid infrastructure and will learn about the oracle patch utility opatch.

Again, remember to take a snapshot of your Virtual Machine if you want to save your work or if you want to revert to this point. Delete the source files if you do not want to become your Virtual Machine too big before:

su - grid
cd /opt/oracle/stage/
rm -rf grid/ p10404530_112030_Linux-x86-64_3of7.zip

On your workstation create the snapshot:

vboxmanage snapshot oracleplayground take "after gi installation and configuration"

 

 

… and as a dba you should have an understanding on how the operation works and what needs to be configured.

The first thing you need to do if you want to install oracle software is to prepare your operating system. For the little series I will use CentOS 5.8 x86_64 because it’s free and compatible to RedHat and Oracle Linux.

What you will need:

If you prefer VMWare or any other virtualization software you can do so. Just make sure to create a new Virtual Machine that matches the one created here.

Once you have installed the VirtualBox software you are ready to create new Virtual Machine. The first steps will show the command line usage for creating the Virtual Machine and mostly will go with the defaults options. For documenting the OS setup itself i decided to provide the screen-shots as automating the OS setup is not in scope of this post.

Note: Everything shown for the command line can be done with the GUI, too. I personally prefer the command line as it is easier to document and faster once you’re common with the syntax.

If you have any questions on the commands used below, please take a look at the Virtual Box documentation.

Create a new CentOS 64bit Virtual Machine and name it oracleplayground ( or whatever name you like, just make sure you replace oracleplayground with the name of your choice in the below commands ):

vboxmanage createvm --name oracleplayground --ostype redhat_64 --register

Modify the VM to use 1512 mb of memory:

vboxmanage modifyvm oracleplayground --memory 1512

Create a new virtual hard disk which will contain the OS and the oracle software ( you can specify any location you like for the –filename parameter ):

vboxmanage createhd --filename ~/VirtualBox\ VMs/oracleplayground/oracleplayground_dh1.vdi --size=30720

Create a new virtual storage controller:

vboxmanage storagectl oracleplayground --name "IDE Controller" --add ide --controller PIIX4

Attach the virtual hard disk to the newly created virtual controller:

vboxmanage storageattach oracleplayground --storagectl "IDE Controller" --port 1 --device 0 --type hdd --medium ~/VirtualBox\ VMs/oracleplayground/oracleplayground_dh1.vdi

Attach the Centos Linux ISO to the virtual machine:

vboxmanage storageattach oracleplayground --storagectl "IDE Controller" --port 1 --device 1 --type dvddrive --medium ~/Downloads/CentOS-5.8-x86_64-bin-DVD-1of2.iso

As we will use NAT for the Virtual Machine we need to configure port-forwarding. This enables us to connect to the VM using ssh once the operating system is installed. This command will forward all requests to your workstation on Port 3000 to the VMs Port 22 ( the default port the ssh daemon listens on ):

vboxmanage modifyvm "oracleplayground" --natpf1 "guestssh,tcp,,3000,,22"

Finally start the VM:

vboxmanage startvm oracleplayground

From this point onwards there will be some screen-shots to document the OS setup ( You would use tools like kickstart for installating a qualified server ).

Note: If your cursor is catched inside the Virtual Machine window you can use the “right CRTL” key to return to your workstation.






















This was the last screenshot and for all remaining task I assume you’re logged in as root and provide the command line usage to proceed:

From now on you should be able to login through ssh. If you workstation runs on Linux/Solaris/OS X this should get you the connection:

ssh -o Port=3000 root@localhost

If you are working on windows, here is the putty example:

If you want to bring your system up to date now, you can use yum to download and install the latest patches:

Do not forget to set the proxy, if you need to use one ( btw. you can permanently set the proxy for yum in /etc/yum.conf ):

export http_proxy=proxy.yourdomain.com:8080

Update the system to the latest patchlevel:

yum update

Now is the perfect time to take a snapshot of your Virtual Machine. This will be very helpful in case you want to come back to this point later or if you damage your VM during one of the next steps. Reverting a snapshot takes minutes, doing all the work above again takes hours.

On your workstation take a snapshot of the Virtual Machine:

vboxmanage snapshot oracleplayground take "after OS installation"

If you want to export the Virtual Machine as appliance, you can do this, too. Appliances are useful if you want to import the whole Virtual Machine to a new one or if you want to transfer it to a another workstation.

vboxmanage export "oracleplayground" --output oracleplayground.ovf

For importing it ( on the same or any other host ):

vboxmanage import "oracleplayground.ovf"

That’s it for the basic Operating System setup. The next post will be about the various configuration tasks that need to be done before we may start installing the oracle software.