Operating System - HP-UX
1748153 Members
3631 Online
108758 Solutions
New Discussion юеВ

Re: starting listener running on remote server using script

 
SOLVED
Go to solution
Kevin Batter_4
Advisor

starting listener running on remote server using script

up until an Oracle upgrade the following part of a script worked
remsh ${PRODUCTION_NODE} -n "su - oracle -c 'lsnrctl start'" >>${LOGFILE} 2>& 1

Now however it just hangs and we have to kill off the remsh to continue the script.According to Oracle this should never have worked but it did !!

Anyone had similar problems and have cured them or does anyone have any other ways of starting a listener on a remote server from within a script

We are running Oracle 8.1.7

Any help appreciated




18 REPLIES 18
A. Clay Stephenson
Acclaimed Contributor

Re: starting listener running on remote server using script

I suspect that your fundamental problem is "su - oracle" rather than "su oracle". I know you want to source oracle's .profile to set environment variables but because the .profile almost certainly contains commands like tset, stty, and tabs which expect an interactive environment, the commands fail.

A beeter solution is to use remsh to invoke a script on the remote host which sets and exports all the needed environment variables and then executes lsnrctl.
If it ain't broke, I can fix that.
Kevin Batter_4
Advisor

Re: starting listener running on remote server using script

thanks for the info

Do you happen to know what variables are needed in order to start the listener.

I know I need PATH to the bin dir but what others do I need to putin the script
Geoff Wild
Honored Contributor

Re: starting listener running on remote server using script

You need the su -

Oracle upgrade? you need to check with the dba's and find out what changed...

Try it manually.

remsh PROD

su - oracle

Does that work?

what about 'lsnrctl start'?

Ask them the correct command to start the listener...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Kevin Batter_4
Advisor

Re: starting listener running on remote server using script

the listener starts it is just that the script just hangs on the remote server and so control does not pass back to the script on the local server so we need to kill off the remsh process and the local script continues on - this means we have to babysit the script whereas before we could just run it and only look at it if there was a problem
generic_1
Respected Contributor

Re: starting listener running on remote server using script

Just an idea. You may want to consider adding ssh and utilizing it instead of remsh because remsh is not secure and sends data accross your network unencrypted. Also ssh is free and downloadable form HP's site. It apears you are using a null password for oracle or remsh as root which is not safe either. There is a free tool called sudo which can provide some logging to su to root and the new versions can run a ldap database so you can centrally control what what commands your users can run and on what servers I hope you got things working again. Best of luck to you.
A. Clay Stephenson
Acclaimed Contributor

Re: starting listener running on remote server using script

I would set the following env variables:

ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=${ORACLE_BASE}/product/8.1.7
TNS_ADMIN=${ORACLE_HOME}/network/admin
export ORACLE_BASE ORACLE_HOME TNS_ADMIN

You may need to export others such as ORACLE_SID or TWO_TASK


I tend to put these commands in a script such as /usr/local/bin/oraenv.sh but make sure that this script contains no exit or return statements

Then both oracle's .profile AND any other batch scripts souce this file using the shell's "." dot operator so that the file is sourced.

e.g.

. /usr/local/bin/oraenv.sh

Now oracle's .profile and everything else "zig" together and any changes can be made in one file.

Plan B.

Surround all interactive commands in oracle's .profile with
if [ -t 0 ]
then
stty ...
tset ...
tabs
fi

so that they are only executed if stdin (-t 0) is a tty device.

I find the common sourced file to be a more elegant approach.
If it ain't broke, I can fix that.
Geoff Wild
Honored Contributor

Re: starting listener running on remote server using script

Ahhh - so control doesn't come back - what about putting it in the background?

remsh ${PRODUCTION_NODE} -n "su - oracle -c 'lsnrctl start &'" >>${LOGFILE} 2>& 1

Do all remsh's hang?

remsh ${PRODUCTION_NODE} date

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Brian Crabtree
Honored Contributor

Re: starting listener running on remote server using script

Jeff,

1. Why not write a script to do this, and call it directly with a su oracle "script" rather than trying to run the lsnrctl directly?

2. Why not just write a monitoring script to run on the system under the oracle cron that would check and see if the listener is available, and starting it as needed?

Thanks,

Brian
Kevin Batter_4
Advisor

Re: starting listener running on remote server using script

cheers for all your replies

the starting of the listener is part of a script that is runing a database refresh using BCVs
so basic order of events are :
bcv establish
shut prod database and listener
bcv split
restart prod database and listener
import bcv
mount filesystems

the script runs on the DR server and does remsh to prod server to do database shutdown and restart.

The only remsh that hangs is the one that restarts the listener so script does not continue to import bcvs,etc to the DR server. Once we kill the listener remsh it will continue and complete ok.