Oracle CentOS 5: Difference between revisions
From VVCWiki
Jump to navigationJump to search
(Updated start script for Oracle 11 functionality) |
(No difference)
|
Latest revision as of 22:08, 22 October 2008
Installing Oracle 11 on CentOS 5
Pre-installation steps
- Create Oracle user and groups
groupadd oinstall groupadd dba groupadd oper useradd -g oinstall -G dba,oper oracle
- Prepare environment
- Create Oracle configuration file /etc/sysconfig/oracledb
ORACLE_BASE=/opt/oracle
ORACLE_SID=MYDB
ORACLE_HOME=$ORACLE_BASE/product/11g
START_ORACLE=yes
START_LISTENER=yes
- Make sure the correct kernel parameters are appended to /etc/sysctl.conf
# added for Oracle kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 262144 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000
- Update kernel parameters
sysctl -p
- Create /etc/profile.d/oracle.sh and make it executable
#!/bin/sh
if [ -f /etc/sysconfig/oracledb ] ; then
. /etc/sysconfig/oracledb
export ORACLE_BASE ORACLE_SID ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME/bin
fi
if [ $USER = oracle ]; then
ulimit -u 16384 -n 65536
umask 022
fi
if [ -n "$EDITOR" ]; then
export EDITOR=vi
fi
- Update /etc/security/limits.conf
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
- Create directories/filesystems for installation and database files
. /etc/profile.d/oracle.sh mkdir -p $ORACLE_HOME chown -R oracle:oinstall $ORACLE_BASE chmod -R 775 $ORACLE_BASE mkdir -p /u02/oradata chown oracle:oinstall /u02/oradata chmod 775 /u02/oradata mkdir -p /opt/oraInventory chown oracle:oinstall /opt/oraInventory chmod 770 /opt/oraInventory
- Install required packages
yum -y install gcc-c++ libaio-devel compat-libstdc++-33 elfutils-libelf-devel unixODBC-devel yum -y install ksh xorg-x11-utils sysstat
Installation
- Download distribution from http://www.oracle.com
- All following steps need to be done under oracle user id
su - oracle
- Extract the distribution
cd /u02/oradata unzip /media/linux_x86_11gR1_database.zip
- Start X server on a workstation
- Start installation (do not create database during this step)
- During installation you will be asked to run two scripts under root user id, do it in a separate terminal window
cd /u02/oradata/database export DISPLAY=workstation:0.0 ./runInstaller
- Add selinux context
semanage fcontext -a -t textrel_shlib_t '/opt/oracle/.*/lib/.+\.so([^/]*)*(\.[^/]*)*' restorecon -R /opt
- Some cleaning
cd /u02/oradata rm -rf database rm -rf /tmp/OraInstall*
- Generate client libraries
genclntst genclntsh
- Create your database
dbca
- Edit file /etc/oratab and enable automatic startup of the database
- Shutdown just created database
dbshut
- Create listener configuration file $ORACLE_HOME/network/admin/listener.ora
LOGGING_LISTENER=OFF DBA_GROUP = dba STOP_LISTENER = YES CONNECT_TIMEOUT_LISTENER = 10 STARTUP_WAIT_TIME_LISTENER = 0
Post-installation tasks
- The following tasks are executed by root
- Create startup script /etc/rc.d/init.d/oracle
#!/bin/bash
# chkconfig: 345 85 15
# description: The Oracle Database
# config: /etc/oratab
# config: /etc/sysconfig/oracledb
# Source function library.
. /etc/rc.d/init.d/functions
ORA_OWNER="oracle"
# pull in sysconfig settings
if [ -f /etc/sysconfig/oracledb ]; then
. /etc/sysconfig/oracledb
fi
[ $START_ORACLE = "yes" ] || exit 0
# check environment (e.g. ORACLE_HOME)
if [ -z "$ORACLE_HOME" -o ! -d $ORACLE_HOME ]; then
echo "Cannot find ORACLE_HOME directory."
echo -n "Environment settings are wrong? Check /etc/sysconfig/oracledb"
failure $"Checking Oracle environment"
exit 1
fi
start () {
echo -n $"Starting Oracle: "
if [ "${START_LISTENER:-no}" = "yes" ]; then
ORACLE_HOME_LISTNER=$ORACLE_HOME
fi
daemon --user $ORA_OWNER $ORACLE_HOME/bin/dbstart $ORACLE_HOME_LISTNER >/dev/null
if [ $? -eq 0 ] ; then
touch /var/lock/subsys/oracle
success
echo
return 0
else
failure
echo
return 1
fi
}
stop () {
echo -n $"Stopping Oracle: "
su - $ORA_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" > /dev/null
if [ $? -eq 0 ] ; then
rm -f /var/lock/subsys/oracle
success
echo
return 0
else
failure
echo
return 1
fi
}
restart () {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/oracle ] && restart || :
;;
*)
echo "Usage: $0 {start|stop|restart|condrestart}"
exit 1
esac
- Add it to the startup sequence
chmod +x /etc/init.d/oracle chkconfig --add oracle
- Add a daily maintenance script to oracle's cron or /etc/cron.d/oracle
- Example
#!/bin/sh
[ -f /etc/oratab -o -f /etc/sysconfig/oracledb ] || exit 0
. /etc/sysconfig/oracledb
TODAY=`date +%Y%m%d`
# For each enabled database
grep -v ^# /etc/oratab| awk -F: '{if ($3=="Y") print $1}'| while read DB
do
if [ -d "$ORACLE_BASE/admin/$DB" ] ; then
/usr/sbin/tmpwatch -m -d -x $ORACLE_BASE/admin/$DB/scripts 168 $ORACLE_BASE/admin/$DB
if [ -s "$ORACLE_BASE/admin/$DB/bdump/alert_$DB.log" ] ; then
mv $ORACLE_BASE/admin/$DB/bdump/alert_$DB.log $ORACLE_BASE/admin/$DB/bdump/alert_${DB}_$TODAY.log
grep ORA- $ORACLE_BASE/admin/$DB/bdump/alert_${DB}_$TODAY.log > /tmp/ora_alert.$$
if [ -s /tmp/ora_alert.$$ ] ; then
mail -s "$DB alert log" $ORA_OWNER < /tmp/ora_alert.$$
fi
rm -f /tmp/ora_alert.$$
fi
fi
done
- Add oracle id into /etc/aliases
Start your Oracle
service oracle start
Enjoy !