Thursday, February 12, 2009

Installing and configuring oracle on ubuntu server

1. Before installing create the environment for it.

*Create user and group called oracle

adduser oracle

# Install required dependencies

aptitude install build-essential libaio1 rpm lesstif2-dev alien libstdc++6-dev

#
# Create directory for oracle installation and give permisson
# Set the environment varibles for the Oracle user
#

ORACLE_BASE=/opt/app/oracle
ORACLE_HOME=${ORACLE_BASE}/product/11.1.0/db_1
ORACLE_SID=orcl
PATH=${ORACLE_HOME}/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

mkdir -p ${ORACLE_BASE}
chown -R ${ORACLE_USER}:${ORACLE_GROUP} ${ORACLE_BASE}


#
# Set kernal parameters and limits
#
Put the following on/etc/sysctl.conf if not exists

kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000


Put following on /etc/security/limits.conf if not exists
* soft nproc 2047#


create the following symbolik link because the location of some commands are hard coded in oracle


ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /lib/libgcc_s.so.1 /lib/libgcc_s.so
ln -s /usr/lib/libstdc++.so.6 /lib/libstdc++.so.5
ln -s /usr/bin/basename /bin/basename



cd /opt/database/install; rm unzip
ln -s /usr/bin/unzip /opt/database/install/unzip

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



2 .Now you have set the environment , then follow the steps below to configure and install your db.



1) Get the oracle zip file.
unzip it to /opt
give the ownership of /opt/database folder to "oracle:oracle"


2) Then copy 11g-rsp.rsp /opt/database/response/ and modify it required.
and as user "oracle"...
run ./runInstaller -silent -responseFile /opt/database/response/11g-rsp.rsp
(Note:- Location of the runInstaller is /opt/database)

3. This will Install oracle database on yourcomputer

5.To create a database on your installed server follow the following steps.

* Use the 11g-dbca.rsp(copy from the orignal one dbca.rsp) file and again make sure settings on this file are
correct.After that copy it to /opt/database/response.

*Then run the following command to create database.

./dbca -silent -responseFile /opt/database/response/11g-dbca.rsp

6.After the database has created sucessfully start listner as below
./lsnrctl start

7. After you have created database create user who are granted to access
above databases.

create user identified by lock;
grant connect to ;


8.Setting up configuration for oracle db to startup on system restart.

1. create the listener.ora and tnsnames.ora file if does not exist.
[Location - /opt/app/oracle/product/11.1.0/db_1/network/admin]

2. Below are the sample file

################################tnsnames.ora##############################################
ORCL=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = .yourdomain.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = .yourdomain.com)
)
)

#########################################################################################


#####################################listener.ora########################################
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = .yourdomain.com)(PORT = 1521))
)

)
)

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = )
(ORACLE_HOME = /opt/app/oracle/product/11.1.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = .yourdomain.com)
(ORACLE_HOME = /opt/app/oracle/product/11.1.0/db_1)
(SID_NAME = )
)

(SID_DESC =
(GLOBAL_DBNAME = .yourdomain.com)
(ORACLE_HOME = /opt/app/oracle/product/11.1.0/db_1)
(SID_NAME =)
)


)

############################################################################


Note- when you creating new database you need to add the details of that db to listener.ora as below for each



(SID_DESC =
(GLOBAL_DBNAME = .yourdomain.com)
(ORACLE_HOME = /opt/app/oracle/product/11.1.0/db_1)
(SID_NAME = )
)


3 .After creating and doing configuring you need edit /etc/oratab file also.

test:/opt/app/oracle/product/11.1.0/db_1:Y
test1:/opt/app/oracle/product/11.1.0/db_1:Y

At the bottom of the oratab file those entrie will be created at the db creating time and the end of each line by default "N" would be
there. So if you want to up the databases on system startup you have to change it from "N" to "Y".

4.Finally you can start the oracle server and start dbs , net listner by issuing following commands.

dbstart <$ORACLE_HOME>
lsnrctl start



9. Rstoring db on oracle

1. Log in to host that the oracle is runing

oracle$ exp

Above command will create the backup of the running db.

2.Then create the database if not exist using dbca as explain above

oracle$imp (default is expdat.dmp )

Note:- above 1,2 you shoud give the user name as below
oracle as sysdba

3.After it has imported sucessfully edit the listner.ora and /etc/oratab described above.