Friday, December 21, 2012

ORACLE 10g/11g installation steps

download software at http://www.oracle.com/downloads or use CD


$ unzip 10201_database_linux32.zip

Note: You must unzip both files at the same location for oracle 11gR1 or 2. The output will be just 1 directory named 'database'. If you don't have just 1 directory, please redo this step because you will get an error during installation!

------------------------
check host configuration
------------------------
vi /etc/hosts

----------------------
set kernel parameters
----------------------
vi /etc/sysctl.conf

add this line:

#kernel.shmall = 2097152
#kernel.shmmax = 2147483648
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
#fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144

------
run
------
/sbin/sysctl -p

--------------------------
vi /etc/security/limits.conf
--------------------------
add this line:

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

----------------------
vi /etc/pam.d/login
----------------------
add line:

session required pam_limits.so

--------------------
Disable selinux by:
--------------------
vi /etc/selinux/config

add this line:
SELINUX=disabled

---------------------------------------
Install packages if you don't have them:
---------------------------------------
# From RedHat AS5 Disk 1
cd /media/cdrom/Server
rpm -Uvh setarch-2*
rpm -Uvh make-3*
rpm -Uvh glibc-2*
rpm -Uvh libaio-0*
cd /
eject

# From RedHat AS5 Disk 2
cd /media/cdrom/Server
rpm -Uvh compat-libstdc++-33-3*
rpm -Uvh compat-gcc-34-3*
rpm -Uvh compat-gcc-34-c++-3*
rpm -Uvh gcc-4*
rpm -Uvh libXp-1*
cd /
eject

# From RedHat AS5 Disk 3
cd /media/cdrom/Server
rpm -Uvh openmotif-2*
rpm -Uvh compat-db-4*
cd /
eject

NOTE: Your system engineer should be able to do this for you. Most firms will not give you root access, so you may have to work with your System Engineer to get the packages installed.

------------------------------
create group and user:
------------------------------
groupadd oinstall
groupadd dba
groupadd oper

useradd -g oinstall -G dba oracle
passwd oracle

-------------------------------
create directories
-------------------------------
mkdir -p /u01/app/oracle/product/10.2.0/db_1
chown -R oracle.oinstall /u01

----------------------
Login as Oracle and
----------------------

vi .bash_profile

add this line:

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=TSH1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
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/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

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


Note: This will help you set the environmental variables and avoid errors from these variables.
----------------------
set display variable
----------------------

DISPLAY=(machine-name):0.0; export DISPLAY

Note: If you don't export display, you may have a shaking screen output or may even get an error specifying the display problem.

----------------
lauch installer
----------------
change directory to database and locate runInstaller.exe

./runInstaller

----------------------------
run post installation script
----------------------------
vi /etc/oratab
add :Y to the instance line (i.e. TSH1:/u01/app/oracle/product/10.2.0/db_1:Y)

Note: This is optional.

Saturday, December 1, 2012

common Oracle DBA interview questions and answer

Here is a small list of questions and answers for junior and mid-level Oracle DBA jobs. Mastery of these questions and answers will help you survive most interview session, and also expose you to some basic and advanced tips you need on the job.

What is the relationship between Control files and V$view?
V$views are kept in the control file. This is why v$ views are always accessible even when the database is in a lesser state.

Can you access V$view while the database is not open?
Yes. V$view can be accessed even when the database is in nomount mode or in a lesser state.

How many stages are involved in getting the database open and running?
3 stages namely: Nomount, Mount and Open stage

What are the Mandatory processes in Oracle?
The processes are the backgound processes. The mandatory ones are Checkpoint, PMON, SMON, Log Writer and Database Writer.

What is an instance?
A combination of memory structure and background processes.

Where can I monitor the Retore job that my colleague did to check if it went well or done properly?
Alert log. Alert log is in background dump. From SQL prompt issue: 'show parameter background dump'

I discovered that my control files are missing, what are my option?
Create another control file from the existing one (multiplex). If there is no existing one, create/build Control file from scratch with a text file. Always back up control file to Trace so that you can have a text file to create a fresh control file.

What is RAC?
Real Application Clusters. A combination of multiple instances accessing a database. The node represents each instance in the cluster.

Why should a client use RAC?
To avoid a single port failure. When there is only one instance, reliability and fault tolerance is low.

What are the demerits of RAC?
It is expensive to maintain. It requires lot of resources (hardware and manpower) as well as maintenance costs. Most firms now use VMware to reduce hardware costs.

What is ASM?
Automatic Storage Management

What would you use ASM?
It is free and more convenient for file management. It helps with load balancing as well as improves reliability and availability.

What is the difference between full and incremental backup?
Full backup is when you backup the whole database and the database is not in open mode. Incremental backup is when you copy the changes that has occured after the last full backup. This is usually done when the database is open and running, and in ARCHIVELOG mode.

Can you use RMAN without database in archivelog mode?
Yes, you can take a cold backup when the database is cleanly shut down.

What is DATAPUMP?
It is a new features that oracle introduced to enhance import and export of database, tablespace, schema and tables. Prior to Datapump, DBAs used regular imp and exp.

What are the basic features that differentiate Datapump from Import and Export?
Datapump allows remaping of database, tablespace, schema and tables. Datapump is also very fast. You can increase parallelism by increasing the workers that will execute the job.
Please note that parallelism is only compatible with Enterprise edition of oracle 10g and 11g.

Best of luck in your interviews and shoot me an email if you have questions.
Cheers!