cancel
Showing results for 
Search instead for 
Did you mean: 

start listener automatically

SOLVED
Go to solution
syuhei mitani
Occasional Contributor

start listener automatically

Hi,
i want to start listener automatically when the server startup.
my dbora file is;
#!/bin/sh
# Set ORA_HOME to be equivalent to the ORACLE_HOME
# from which you wish to execute dbstart and
# dbshut
# set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME

ORA_HOME=/home/oracle/r11i/proddb/8.1.6
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')

# Start the Oracle databases:
# The following command assumes that the oracle login will not prompt the
# user for any values

/usr/bin/su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
/usr/bin/su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" &
;;
'stop')

# Stop the Oracle databases:
# The following command assumes that the oracle login will not prompt the
# user for any values

/usr/bin/su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" &
/usr/bin/su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
;;
esac


db could start but not listener. i have no error messages when the server startup. in my rc.log, i get a message like this;
stty: : Not a typewriter

i have no ideas why the listner couldn't start.
please give me some advice.

my system is
HP_UX Release: B.11.00
oracle ver. 8.1.6

thank you
9 REPLIES
Stefan Farrelly
Honored Contributor

Re: start listener automatically


By default when you log in as say oracle it runs the .profile in the oracle home directory. This .profile has lots of terminal commands in - stty, etc. When you su - oracle as part of the system startup or a cron job you do NOT want these terminal commands in your .profile to be run as they will screw it up. So, we copy ~oracle/.profile to ~oracle/.profile.cron and edit the .profile.cron to remove all stty commands etc. It should only contain variable declarations. Then when you need to su to oracle as part of the system startup or cron you do;

su oracle -c ". ~oracle/.profile.cron;startup.sh"

(in the example above the startup.sh script would try to start the databases and listener).
This works fine for us.
If you did su - oracle .... then it would run ~oracle/.profile which is not what you want.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Vicente Sanchez_3
Respected Contributor

Re: start listener automatically

Hi Syuhei,

I have a similar script to start server and listener automatically, and when it start I have the same message

stty: not a typewriter, but it start.

The two only differences are,

Oracle version: 8.1.7.x

and I don't have an & at the end of the line.

Hope this help
Ruediger Noack
Valued Contributor

Re: start listener automatically

Any messages in your listener log file ($ORACLE_HOME/network/log/listener.log) ?

Ruediger
Victor Geere
Frequent Advisor
Solution

Re: start listener automatically

If you want to set ORA_HOME = ORACLE_HOME rather do a
ORA_HOME = $ORACLE_HOME; export ORA_HOME
than to set them both the whatever since the one could change and you would still assume that they are the same. Check that they are the same. You also haven't exported ORA_HOME.

Secondly to debug the script, execute each line manually from the command prompt and see where it goes wrong, then dig there.

I thought that I was because I had thought.
Jon Mattatall
Esteemed Contributor

Re: start listener automatically

There's no need to run the lsnrctl in the background.

The stty error occurs because you're using "su - oracle". This runs the .profile for oracle, which looks for stty settings. You're not running the command from a terminal, but from a script, so there's no terminal type involved and the stty message appears. It's not a problem, but if you want it to go away you could use "su oracle" instead of "su - oracle" and set up the environment variables in the script - which seems like a lot of effort for little return.

You refer to "databases". Do you have multiple listeners? e.g.

if [ ${ORACLE_START} -eq 1 ]
then
echo "Starting Oracle"
su - oracle -c dbstart
su - oracle -c "lsnrctl start listener_AAAA"
su - oracle -c "lsnrctl start listener_BBBB"
su - oracle -c "lsnrctl start listener_CCCC"
su - oracle -c "lsnrctl start listener_DDDD"
su - oracle -c "lsnrctl start listener_EEEE"
su - oracle -c "lsnrctl start listener_FFFF"
su - oracle -c "lsnrctl start listener_GGGG"
su - oracle -c "lsnrctl dbsnmp_start"
set_return
else
rval=2
fi

What's in your listener.ora?

Jon
A little knowledge is dangerous - none is absolutely terrifying!!!
John Dixon_1
Advisor

Re: start listener automatically

Hi,
To solve this problem on our systems, we add a "wrapper" in the .profile around the stty commands to check for a terminal.

For example:
#If interactive, then run all the sttys
if [ -t 0 ]
then
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty hupcl ixon ixoff
tabs
fi



cheers,
John

Rory R Hammond
Trusted Contributor

Re: start listener automatically

Attached are /sbin/init.d/oracle and
/sbin/init.d/listener startup scripts. they are linked to run in runstate 3.

Remember that you need a
file named /etc/rc.config.d/oracle that cantains the following line.
"ORACLE_START=1"

To manually stop oracle.

/sbin/init.d/oracle stop
/sbin/init.d/listener start

To manually start oracle

/sbin/init.d/listener start
/sbin/init.d/oracle start.


As you can tell these are the standard start\stop scripts used during system reboot.

If you don't want to issue the four lines to bounce oracle. write a script to execute the four commands.


Ror
There are a 100 ways to do things and 97 of them are right
Sanjay_6
Honored Contributor

Re: start listener automatically

Hi,

We are starting the listener only and not starting the oracle database. But if you want you can add the oracle startup to this file. Attached is the oracle/listener startup file from /sbin/init.d. also the config file /etc/rc.config.d/oracle is typed below,

ORACLE_START=1
export ORACLE_START

The /sbin/init.d/oracle file is linked to /sbin/rc2.d/S990oracle and /sbin/rc1.d/K010oracle

cd /sbin/rc2.d
ln -s /sbin/init.d/oracle S990oracle
cd /sbin/rc1.d
ln -s /sbin/init.d/oracle K010oracle

Hope this helps.

Regds



syuhei mitani
Occasional Contributor

Re: start listener automatically

thanks for your advice. finally, i could startup listener automatically. first, i'd tried manual startup but it didn't work. when i connect database, i got a message below;
ORA-12505:TNS:listener could not resolve SID given in correct descriptor

i used 'lsnrctl start SID' always when startup lisnter manually so i tried modify dbora script in the same way.

however i'm not sure if it's the right way. here is an attachment of my dbora script. if someone knows better way, tell me.