Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto start an oracle db & listener on AIX

Status
Not open for further replies.

tallyaix

MIS
Mar 29, 2007
4
US
My initial goal was to auto start/stop the oracle database and listener on AIX. Oracle suggested the following for starting and stopping the database (not the listener):

1. Create a file called dbora in the /etc directory.
2. chgrp dba /etc/dbora (change the group for the file permissions)
3. chmod 750 /etc/dbora (change the permissions of the file.)
4. add the following lines in the dbora file:

#! /bin/sh -x
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.

ORACLE_HOME=/u01/app/oracle/product/ora10g
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle

PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
#
if [ ! "$2" = "ORA_DB" ] ; then
if [ "$PLATFORM" = "HP-UX" ] ; then
remsh $HOST -l $ORACLE -n "$0 $1 ORA_DB"
exit
else
rsh $HOST -l $ORACLE $0 $1 ORA_DB
exit
fi
fi
#
case $1 in
'start')
$ORACLE_HOME/bin/dbstart $ORACLE_HOME &
;;
'stop')
$ORACLE_HOME/bin/dbshut $ORACLE_HOME &
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit

5. Now that we have the dbora file with the correct oracle user and oracle home, we simply create the soft links as follows:

# ln -s /etc/dbora /etc/rc.d/rc2.d/S99dbora
# ln -s /etc/dbora /etc/rc.d/rc2.d/K01dbora

6. You then have to edit the /etc/hosts.equiv file with the following entry:

host root (where the host is the name of the server)

My database now will auto start and stop when the AIX system is shutdown.

I tried doing the same thing for the listener with the following changes:

I created a dblsn file with the following changes in the script:

case $1 in
'start')
$ORACLE_HOME/bin/lsnstart $ORACLE_HOME &
;;
'stop')
$ORACLE_HOME/bin/lsnstop $ORACLE_HOME &
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit

The lsnstart script works when I run it from the user Oracle or root. It is as follows:

#
# Startup the oracle listener
#
export PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/ora10g
export ORACLE_SID=orasql
export AGENT_HOME=/u01/app/oracle/product/agent10g

/bin/su oracle -c /u01/app/oracle/product/ora10g/bin/lsnrctl start

For the /etc/dblsn file, I implemented the following soft links:

# ln -s /etc/dbora /etc/rc.d/rc2.d/S97dbora
# ln -s /etc/dbora /etc/rc.d/rc2.d/K03dbora

If it worked for the database, I thought it should work for the listener. When it didn't, I tried a different method for auto starting the listener:

1. I copied the lsnstart script above to the /etc directory and renamed it to rc.lsnstart
2. I then added the script to the inittab by using the following:

#/usr/sbin/mkitab "rclsnstart:2:wait:/etc/rc.lsnstart > /dev/console 2>&1"

If I do a telinit q, it should reread the inittab file and start the listener. It doesn't work.

So, I've tried two methods to automajically starting the oracle listener in an AIX environment with no luck. Any suggestions would be appreciated.
 
Have you tried to run the script manually first? Did it work?

I'm afraid you didn't set the permission for the listener script! Did you?

(By the way puting the script either in /etc or / is the same scripting-wise on aix!)

Regards,
Khalid
 
Am I missing something (entirely possible)? We use /etc/inittab and /etc/rc.shutdown to start and stop the database and listener(s).

I want to be good, is that not enough?
 
In addressing both of the responses above:

1. Have you tried to run the script manually first? Did it work? Yes it does work when I run it manually.

2.I'm afraid you didn't set the permission for the listener script! Did you? Yes, I've even gone as far as giving rwx access to everyone for the script.

3. Am I missing something (entirely possible)? We use /etc/inittab and /etc/rc.shutdown to start and stop the database and listener(s). Yes, I'm trying to use the inittab to start the listener. As stated in the latter part of my first post, the inittab entry is as follows:
#/usr/sbin/mkitab "rclsnstart:2:wait:/etc/rc.lsnstart > /dev/console 2>&1"


The script isn't being invoked when the inittab entry is read. The script works manually from both users oracle and root. Definitely seems to be an AIX issue.
 
Code:
wait 
When the init command enters the run level specified for this record, start the process and wait for it to stop. While the init command is in the same run level, all subsequent reads of the /etc/inittab file ignore this object.

That's from the manual of mkitab!

Try this command instead:

#/usr/sbin/mkitab "rclsnstart:2:respawn:/etc/rc.lsnstart > /dev/console 2>&1"

then telinit q

If this didn't work please list your /etc/inittab just to view it over here.

Regards,
Khalid
 
That's how we do it at work:

(From root crontab)

Code:
oralsnr:2:wait:/bin/su - oracle -c /ora0/app/oracle/product/8.1.7/bin/lsnrctl start

and it is working! If it doesn't work with telinit q try rebooting the system!

Regards,
Khalid
 
When I use the suggested inittab entry
#/usr/sbin/mkitab "rclsnstart:2:respawn:/etc/rc.lsnstart > /dev/console 2>&1"

and to a telinit q, it works! The listener starts. IBM couldn't even give me this information. Thank you very much for replying to my post. I've been looking for a solution for about 2 weeks now.
 
You have a crontab entry for this? The crontab entry is different from the inittab entry. A crontab entry is something that I haven't tried.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top