Thursday, October 22, 2009

ADMINISTER CRS (Cluster Ready Services)

Start/Stop CRS
crsctl start crs
crsctl stop crs

Check CRS's status
crsctl check crs

See the status of the various services
crs_stat –t

Start/stop nodeapps
srvctl start nodeapps -n
srvctl stop nodeapps -n

Start/stop asm
srvctl start asm -n
srvctl stop asm -n

Start/stop a database (all nodes)
srvctl start database -d
srvctl stop database -d
Start/stop an individual instance
srvctl start instance -d -i
srvctl stop instance -d -i
Check the VIP config
srvctl config nodeapps -n -a -g -s
Change the VIP address, subnetmask or interface
srvctl stop nodeapps -n
srvctl stop nodeapps -n
srvctl modify nodeapps -n -A //
srvctl modify nodeapps -n -A //
srvctl start nodeapps -n
srvctl start nodeapps -n

Locate the voting disk
crsctl query css votedisk

Retrive OCR (Oracle Cluster Registry) information
ocrcheck
To prevent a database starting at boot time
srvctl disable database -d
Change the private interconnect subnet
First find the interface which is in use as the interconnect - run as root from the crs home:
oifcfg getif
Make a note of the interface name (eth1 in the following example), then
run the following:
oifcfg delif -global eth1
oifcfg setif -global eth1/:cluster_interconnect

Friday, October 16, 2009

Setting Oracle Database to Archivelog / Noarchivelog

Setting ORACLE DB into noarchivelog / archivelog mode

NOTE: To change log_mode the database must be in Exclusive mount state


1. Login to sqlplus
-sqlplus /nolog
-connect / as sysdba
2. The db must be mounted EXCLUSIVE and not open for operation
-startup mount;
3. Check the log mode status of the database
-select log_mode from v$database;
4. Setting it to noarchivelog mode
-alter database noarchivelog;
5. Setting db open for user operation
-alter database open;
6. Reverting back to archivelog mode
-alter database archivelog;

Thursday, October 1, 2009

Oracle - Quick Invalid Objects compile

The Oracle database will invalidate objects if a dependent object is changed. If one rebuild a table, the indexes on that table will become invalid because they use the table's rowids and rebuilding the table changes a row's rowid. It is the same with objects like packages, procedures and functions.

In a development environment with lots of users working on the same objects this can become aggravating. Just remember that someone caused the database to invalidate the object. You can control this by controlling who changes objects in the database, or splitting the development into multiple schemas so that one section does not cause another's objects to become invalid.

You can invoke the utl_recomp package to recompile invalid objects:

EXEC UTL_RECOMP.recomp_serial('schema name');

Here is a script to recompile invalid PL/SQL packages and package bodies. You may need to run it more than once for dependencies, if you get errors from the script.
invalid.sql

Set heading off;
set feedback off;
set echo off;
Set lines 999;

Spool run_invalid.sql

select
'ALTER ' || OBJECT_TYPE || ' ' ||
OWNER || '.' || OBJECT_NAME || ' COMPILE;'
from
dba_objects
where
status = 'INVALID'
;

spool off;

set heading on;
set feedback on;
set echo on;

@run_invalid.sql

Thursday, September 3, 2009

How to Multiplex Control File using ASM and RAC

Shutdown all other instances

Follow these steps using one instance


$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Wed Sep 2 17:50:15 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$controlfile;

NAME
-------------------------------------------------------------------
+FRA/ctrk027/controlfile/current.258.695839303

SQL> alter system set control_files = ‘+FRA/ctrk027/controlfile/current.258.695839303’,’+TRACKING_DATA’,’+TRACKING_REDOCTL1’ scope=spfile sid=’*’;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 2550136832 bytes
Fixed Size 1995856 bytes
Variable Size 536873904 bytes
Database Buffers 1996488704 bytes
Redo Buffers 14778368 bytes

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Wed Sep 2 17:48:42 2009

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

connected to target database: ctrk027q (not mounted)

RMAN> restore controlfile from '+FRA/ctrk027/controlfile/current.258.695839303';

Starting restore at 02-SEP-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=144 instance=ctrk027q2 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=+FRA/ctrk027/controlfile/current.258.695839303
output filename=+TRACKING_DATA/ctrk027q/controlfile/current.370.696534557
output filename=+TRACKING_REDOCTL1/ctrk027q/controlfile/current.300.696534559
Finished restore at 02-SEP-09

RMAN> exit


Recovery Manager complete.

$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Feb 13 15:29:24 2008

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL> alter database mount;

Database altered.

SQL> alter database open;

Database altered.

SQL> alter system set control_files='+FRA/ctrk027/controlfile/current.258.695839303’,’ +TRACKING_DATA/ctrk027q/controlfile/current.370.696534557’,’ +TRACKING_REDOCTL1/ctrk027q/controlfile/current.300.696534559’ scope=spfile sid=’*’;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup
ORACLE instance started.

Total System Global Area 2550136832 bytes
Fixed Size 1995856 bytes
Variable Size 536873904 bytes
Database Buffers 1996488704 bytes
Redo Buffers 14778368 bytes
Database mounted.
Database opened.
SQL>
SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------
+FRA/ctrk027/controlfile/current.258.695839303
+TRACKING_DATA/ctrk027q/controlfile/current.370.696534557
+TRACKING_REDOCTL1/ctrk027q/controlfile/current.300.696534559
SQL>

Tuesday, June 16, 2009

RAC INSTALLATION CHECKLIST

CHECK LIST TO USE AND FOLLOW

This is the list of operations you should do, before moving to Oracle Installation steps :

Perform all these steps on all nodes participating in the RAC

1 Check the Hardware Requirements

2 Check the Network Requirements

3 Check the Software Requirements

4 Create Required UNIX Groups and User

5 Configure Kernel Parameters and Shell Limits

6 Identify Required Software Directories

7 Identify or Create an Oracle Base Directory

8 Create the CRS Home Directory

9 Choose a Storage Option for Oracle CRS,Database, and Recovery Files

10 Create Directories for Oracle CRS,Database, or Recovery Files

11 Configure Disks for Automatic Storage Management
- Disk Storage concurrently from all nodes participating to the RAC cluster

12 Synchronize the System Time on Cluster Nodes

13 Stop Existing Oracle Processes

14 Configure the oracle User's Environment

15 Configure user equivalence (eg SSH)

Tuesday, June 2, 2009

Installing Oracle Database on Redhat Linux

Installing Oracle RDBMS on Redhat linux linux

Note: This document does not replace the Oracle Install guide.

1. Create the Oracle Groups and User Account

/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/groupadd oper
/usr/sbin/useradd -m -g oinstall -G dba,oper oracle

2.
Set the password on the oracle account:
passwd oracle
3.

cat >> /home/.bash_profile <export PS1='{'$(hostname)':'$LOGIN'}$PWD ->'
set -o vi
stty erase ^?
umask 022
export ORACLE_BASE=/oracle/product
export ORACLE_HOME=$ORACLE_BASE/102_64
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:
export TEMP=/tmp
export TMP=/tmp
export TMPDIR=/tmp
export TNS_ADMIN=$ORACLE_HOME/network/admin
export DISPLAY=192.168.0.27:0.0
alias oh='cd $ORACLE_HOME'
alias sql='sqlplus "/ as sysdba"'
EOF
4.
Create Directories
mkdir -p /oracle/product
chown -R oracle:dba /oracle/product
chmod -R 775 /oracle/product


5. Get and install the missing packages as per Installation guide
checking if the packages are available
rpm -qa | grep package_name
eg rpm -qa | grep binutils

Required packages or later (32_bit)

rpm -q binutils gcc glibc glibc-headers glibc-kernheaders glibc-devel compat-libstdc++ cpp compat-gcc make compat-db compat-gcc-c++ compat-libstdc++ compat-libstdc++-devel setarch sysstat pdksh libaio libaio-devel --qf '%{name}.%{arch}\n'|sort

binutils.i386
compat-gcc-7.3-2.96.128.i386
compat-gcc-c++-7.3-2.96.128.i386
compat-libstdc++-7.3-2.96.128.i386
compat-libstdc++-devel-7.3-2.96.128.i386
cpp.i386
gcc.i386
gcc-c++.i386
glibc.i386
glibc-common.i386
glibc-devel.i386
glibc-headers.i386
glibc-kernheaders.i386
libstdc++.i386
libstdc++-devel.i386
libaio
libai-devel.i386
pdksh.i386
setarch.i386
sysstat.i386

Required packages or later (64_bit)

rpm -q binutils compat-db compat-libstdc++-33 glibc glibc-devel glibc-headers gcc gcc-c++ libstdc++ cpp make libaio ksh elfutils-libelf sysstat libaio libaio-devel setarch --qf '%{name}.%{arch}\n'|sort


binutils.x86_64
compat-db.x86_64
compat-libstdc++-33.i386
compat-libstdc++-33.x86_64
cpp.x86_64
elfutils-libelf.i386
elfutils-libelf.x86_64
gcc-c++.x86_64
gcc.x86_64
glibc-devel.i386
glibc-devel.x86_64
glibc-headers.x86_64
glibc.i686
glibc.x86_64
ksh.x86_64
libaio-devel.i386
libaio-devel.x86_64
libaio.i386
libaio.i386
libaio.x86_64
libaio.x86_64
libstdc++.i386
libstdc++.x86_64
make.x86_64
setarch.x86_64
sysstat.x86_64


6. configuring Kernel Parameters

cat >> /etc/sysctl.conf <kernel.shmmax = 4294967295
kernel.shmall = 268435456
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=1048576
net.core.rmem_max=1048576
net.core.wmem_default=262144
net.core.wmem_max=262144
EOF


7.
/sbin/sysctl -p

------------
Run the following commands as root to verify your settings:

/sbin/sysctl -a | grep shm
/sbin/sysctl -a | grep sem
/sbin/sysctl -a | grep file-max
/sbin/sysctl -a | grep ip_local_port_range
/sbin/sysctl -a | grep rmem_default
/sbin/sysctl -a | grep rmem_max
/sbin/sysctl -a | grep wmem_default
/sbin/sysctl -a | grep wmem_max

------------------
8.
Setting shell limits for the oracle user


cat >> /etc/security/limits.conf < oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF

9.
cat >> /etc/pam.d/login < session required /lib/security/pam_limits.so
EOF

10.
cat >> /etc/profile < if [ USER = "oracle" ]; then
if [ SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384
-n 65536
fi
umask 022
fi
EOF

9.
cat >> /etc/csh.login < if ( USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif
EOF
10.
Log in as oracle and execute the installer

11.
$ ./runInstaller

12.
You need to specify your Inventory Directory. The location should be set to
/u01/app/oraInventory or any valid path.
Operating System Group Name, oinstall. Click OK.

13. ...