9i unix startup / shutdown with listener password

Thanks to Laurent Schneider for tips on how to handle listener passwords in scripts. [Update 12-Jan-2007 - ammended script following Laurent's comment, and update 09-Feb-2007 - ammended script following Kevin's comment]

A system startup/shutdown shell script I just used that copes with listener passwords is below.

The location of the listener.ora file was /etc in my case, but that can be different in other servers. The script assumes oracle environment variables are all set correctly at login (the “su -”). This is 9i specific – as explained on Laurent Schneider’s blog post, things are different/better with 10g. Also is only designed to work with a single listener with the default name, LISTENER).

For this script to actually run at system startup/shutdown time, it needs to be linked into the /etc/rc*.d directories, at least /etc/rc3.d (the default startup/shutdown level) although I put it in the others also. The easiest way to do this is using the “chkconfig –add oracle” utility, but it can also be done manually as root user:

vi /etc/init.d/oracle
[pasted in below shell script]
chmod 755 /etc/init.d/oracle
cd /etc/rc1.d
ln -s ../init.d/oracle K99oracle
ln -s ../init.d/oracle S99oracle
cd /etc/rc2.d
ln -s ../init.d/oracle K99oracle
ln -s ../init.d/oracle S99oracle
cd /etc/rc3.d
ln -s ../init.d/oracle K99oracle
ln -s ../init.d/oracle S99oracle
cd /etc/rc4.d
ln -s ../init.d/oracle K99oracle
ln -s ../init.d/oracle S99oracle
cd /etc/rc5.d
ln -s ../init.d/oracle K99oracle
ln -s ../init.d/oracle S99oracle
cd /etc/rc6.d
ln -s ../init.d/oracle K99oracle
ln -s ../init.d/oracle S99oracle


The script Itself:

#!/bin/sh
#
#Start/Stop script for oracle
#

case "$1" in

'start')
su - oracle <<END_SU

#start databases
dbstart

#start oracle listener
lsnrctl start

END_SU
;;

'stop')

#stop oracle 9i listener with password control
ENCRYPTED_PASSWORD=`grep -i password /etc/listener.ora | awk -F= '{print $2}' -`

su - oracle <<END_SU

lsnrctl <<END_LISTENER
set password $ENCRYPTED_PASSWORD
stop
quit
END_LISTENER

#cleanly shutdown immediate databases
dbshut

END_SU
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0
This entry was posted in Installs, Scripts, SQL*Net. Bookmark the permalink.

17 Responses to 9i unix startup / shutdown with listener password

  1. note that you never need a password to start a listener 8)
    take care if you have more than one listener

  2. Thanks again. Had I known password wasn’t needed for startup, I might have been tempted to be lazy and skip the listener shutdown step, since I’m a lot less bothered about a listener not being cleanly shutdown than a database.

  3. Kevin says:

    I’m following these steps exactly, but seeing that my script is not able to set variables within the “su – ” routine.

    This is happening both on my RHES Linux 4.0 and hpux 11.11 servers.

    If I put all the oracle commands in a separate script, then everything is fine, but I’m wondering if anyone knows why the example above wouldn’t work for me?

    cheers,
    Kevin

  4. Not sure why that happens, but I just replicated it on a solaris test machine. Fix I used there was to take the environment variable line:

    ENCRYPTED_PASSWORD=`grep -i password /etc/listener.ora | awk -F= ‘{print $2}’ -`

    to be before the su.

    I’ve updated the original post to have that fix in.

  5. Kevin says:

    Ahh, that did it Andrew. Thanks so much

  6. Uneniosits says:

    Thanks for the post

  7. SJ says:

    How does the ‘start’ or ‘stop’ command get passed to the oracle script?

  8. The ‘start’ or ‘stop’ is passed to the script as the first parameter, ‘$1′.

    So from the command line you would type e.g.: “/etc/init.d/oracle start” or use it’s alias: “service oracle start”

    And the good thing is that server shutdowns and startups automatically pass in either ‘start’ or ‘stop’ to the scripts in /etc/init.d.

  9. That is very fascinating, You are a very professional blogger.
    I’ve joined your feed and stay up for seeking extra of your excellent
    post. Also, I’ve shared your web site in my social networks

  10. domain says:

    It’s a shame you don’t have a donate button! I’d without a
    doubt donate to this superb blog! I suppose for now i’ll settle for book-marking and adding your RSS feed to my Google account.
    I look forward to new updates and will share this blog with my Facebook group.
    Chat soon!

  11. It can be downloaded by opening Cydia and lookup for the Winterboard.
    You can have themes, wallpapers, movies and numerous more.
    Keep holding the House button down till QuickPwn tells
    you that the process has begun.

  12. This exam is very important because of the acceptance of
    design computer programs for example games. It also gives you success stories, daily
    recipes and useful guidelines.

  13. cydia : It is the unofficial software shop that allows you to accessibility all goodies which Apple doesn’t permit.
    As usually, when some thing bad happens, you can always restore via iTunes.

  14. Just in case you require more info you’ll be able to simply
    open this link how to: Link iPad to TV Guide. The retailer options people have can be very boring.
    What happens next, is a subject of destiny.

  15. Ivory says:

    Together we can have the fantastic fun inside the vehicle.

    You have the money but want to make it get quite a distance then enjoy your personal garden.

  16. An outstanding share! I have just forwarded this onto a co-worker who
    has been doing a little homework on this.
    And he actually ordered me lunch because I found it
    for him… lol. So allow me to reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending some time to talk about this topic here
    on your blog.

    my homepage; spiderman zip up hoodie hot topic

  17. Bernice says:

    You can plug it into your telly, computer or electronic camera and it’s also a potent digital recording unit.
    Some of us have even played it in a on line casino.

    They have been restored to new but can’t be offered as new.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>