Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3844
  • Last Modified:

Starting listener in a script



I have a little test script to test starting listener in a script.
~
#!/bin/sh
ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle

export ORA_HOME ORA_OWNER
su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start"


from the command line i enter ./testlsnr.sh
and get console display of :

[root@dwrepository init.d]# ./testlsnr.sh
Fri Aug 27 12:06:16 EDT 2004

LSNRCTL for Linux: Version 9.2.0.3.0 - Production on 27-AUG-2004 12:06:16

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Message 1070 not found; No message file for product=network, facility=TNSTNS-125
45: Message 12545 not found; No message file for product=network, facility=TNS
 TNS-12560: Message 12560 not found; No message file for product=network, facili
ty=TNS
  TNS-00515: Message 515 not found; No message file for product=network, facilit
y=TNS
   Linux Error: 2: No such file or directory


From command line  if i enter lsnrctl start

uid=500(oracle) gid=500(oracle) groups=500(oracle),0(root),4(adm),502(dba)
[oracle@dwrepository init.d]$ lsnrctl start

LSNRCTL for Linux: Version 9.2.0.3.0 - Production on 27-AUG-2004 12:08:39

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Starting /u01/app/oracle/product/9.2.0.1.0/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 9.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/9.2.0.1.0/network/admin/listene
r.ora
Log messages written to /u01/app/oracle/product/9.2.0.1.0/network/log/listener.l
og
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dwrepository)(PORT=1521)
))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 9.2.0.3.0 - Production
Start Date                27-AUG-2004 12:08:40
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  OFF
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/9.2.0.1.0/network/admin/listen
er.ora
Listener Log File         /u01/app/oracle/product/9.2.0.1.0/network/log/listener
.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dwrepository)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "dwprodrp.edu" has 1 instance(s).
  Instance "dwprodrp", status UNKNOWN, has 1 handler(s) for this service...
Service "dwtestrp.edu" has 1 instance(s).
  Instance "dwtestrp", status UNKNOWN, has 1 handler(s) for this service...
Service "owbnewrp.edu" has 1 instance(s).
  Instance "owbnewrp", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@dwrepository init.d]$


What is it looking for that it cannot find and how do I point to it?
0
xoxomos
Asked:
xoxomos
  • 9
  • 6
  • 5
2 Solutions
 
seazodiacCommented:
xoxomos:

Hey there!

the "lsnrctl start" will call a default parameter called "LISTENER" filled by listener.ora file.

so you have to point to that explicity if you run a different user account even with ROOT.

try to modify your script like this:

#!/bin/sh
ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle
TNS_ADMIN=$ORA_HOME/network/admin

export ORA_HOME ORA_OWNER
su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start LISTENER"
0
 
xoxomosAuthor Commented:
The error changed a little, but it's still looking for something.
[root@dwrepository init.d]# ./testlsnr.sh
Fri Aug 27 13:16:47 EDT 2004

LSNRCTL for Linux: Version 9.2.0.3.0 - Production on 27-AUG-2004 13:16:47

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Message 1070 not found; No message file for product=network, facility=TNSTNS-125
45: Message 12545 not found; No message file for product=network, facility=TNS
 TNS-12560: Message 12560 not found; No message file for product=network, facili
ty=TNS
  TNS-00515: Message 515 not found; No message file for product=network, facilit
y=TNS
   Linux Error: 2: No such file or directory
[root@dwrepository init.d]#


#!/bin/sh
ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle
TNS_ADMIN=$ORA_HOME/network/admin

export ORA_HOME ORA_OWNER TNS_ADMIN
date
su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start"

~
~
~
~
0
 
seazodiacCommented:
that's because you did not do what I said:

just copy and paste what I wrote in my post....

watch for this line:

su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start LISTENER"
                                                                                                                      **********
                                                                                                                      it's different here...
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
seazodiacCommented:
also did you patch your instance from 9.2.0.1 to 9203?
0
 
seazodiacCommented:
if the above is not sufficient, I show an easy one here:

just copy and paste the "oracle" user environmental variables to this testlsnr.sh file.

and then make sure $ORACLE_HOME, $ORACLE_SID, and $TNS_ADMIN, $PATH, are set

su - $ORA_OWNER -c "lsnrctl start LISTENER"
0
 
xoxomosAuthor Commented:
Yes, it's at the .0.3 level, but was .0.1 on initial install.
0
 
xoxomosAuthor Commented:
ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle
TNS_ADMIN=$ORA_HOME/network/admin

export ORA_HOME ORA_OWNER
su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start LIST
ENER"

 or adding export for TNS_ADMIN

ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle
TNS_ADMIN=$ORA_HOME/network/admin

export ORA_HOME ORA_OWNER TNS_ADMIN
su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start LIST
ENER"

still give the message

LSNRCTL for Linux: Version 9.2.0.3.0 - Production on 27-AUG-2004 14:01:34

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Message 1070 not found; No message file for product=network, facility=TNSTNS-125
45: Message 12545 not found; No message file for product=network, facility=TNS
 TNS-12560: Message 12560 not found; No message file for product=network, facili
ty=TNS
  TNS-00515: Message 515 not found; No message file for product=network, facilit
y=TNS
   Linux Error: 2: No such file or directory
[root@dwrepository init.d]#
0
 
seazodiacCommented:
ok, I finally found out where your problem,

it's a silly file path error:

this line should change from :

su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start"

to

su - $ORA_OWNER -c "/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start"

0
 
xoxomosAuthor Commented:
Actually the /usr/u01/..... and /u01/..... are the same the way this machine is set up.

ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle
TNS_ADMIN=$ORA_HOME/network/admin

export ORA_HOME ORA_OWNER TNS_ADMIN
su - $ORA_OWNER -c "/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start LISTENER
"
 

or


ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle
TNS_ADMIN=$ORA_HOME/network/admin

export ORA_HOME ORA_OWNER TNS_ADMIN
su - $ORA_OWNER -c "/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start"

Turn up the same error.
0
 
brozzisCommented:

generally this error comes out with an error in ORACLE_HOME variable.
You should assure yourself that the $ORA_OWNER user has the correct $ORACLE_HOME variabile
settend in its .profile / .bash_profile

please try

su - oracle -c "env | grep ORA"

I suppose nothing will be written or the wrong variable. Correct and retry


#!/bin/sh
# unnecessary and useless
# ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle

# useless
# export ORA_HOME ORA_OWNER
su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start"



Alternatively some errors come out on setting variables like NLS% please take a look on those.
I had some problems on unix environments on upgrades from oracle 7 to Oracle 8 and 9 with some
of these vars setted.

0
 
xoxomosAuthor Commented:
#!/bin/sh
ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle
PATH=$ORACLE_HOME/bin:$PATH
export ORA_HOME ORA_OWNER PATH
echo $ORACLE_HOME  "   HOME"
echo $ORACLE_OWNER "   OWNER"
echo $PATH
su - $ORA_OWNER -c "/usr/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start"


If I am oracle and run the dbora script, the value for HOME echos correctly although there is nothing for OWNER since it is
waiting for a password.

[oracle@dwrepository init.d]$ ./dbora
/u01/app/oracle/product/9.2.0.1.0    HOME
   OWNER
/u01/app/oracle/product/9.2.0.1.0/bin:/opt/IBMJava2-131/bin:/opt/IBMJava2-131/jr
e/bin:/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/home/oracle/bin:
/u01/app/oracle/product/9.2.0.1.0/bin
Password:


If I run dbora as root, neither the HOME, OWNER or PATH variables are set

uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10
(wheel)
[root@dwrepository init.d]# pwd
/etc/init.d
[root@dwrepository init.d]# ./dbora
   HOME
   OWNER
/bin:/opt/IBMJava2-131/bin:/opt/IBMJava2-131/jre/bin:/usr/local/sbin:/usr/local/
bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

LSNRCTL for Linux: Version 9.2.0.3.0 - Production on 30-AUG-2004 10:44:46

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Message 1070 not found; No message file for product=network, facility=TNSTNS-125
45: Message 12545 not found; No message file for product=network, facility=TNS
 TNS-12560: Message 12560 not found; No message file for product=network, facili
ty=TNS
  TNS-00515: Message 515 not found; No message file for product=network, facilit
y=TNS
   Linux Error: 2: No such file or directory

Lsnrctl must be run as oracle  and ORA_OWNER is not passing the value.
[root@dwrepository init.d]#
0
 
brozzisCommented:

please reread what you've written...
after that, reread what I've written.

Moreover remember that  you have to declare your Oracle variables for the user oracle
and with user root you can startup your database with a

su - oracle -c "<command or script>"

Given this, look at the variable names...

you declare ORA_HOME, but you echo ORACLE_HOME (variable that is correctly defined for your user oracle)
ditto for ORA_OWNER and ORACLE_OWNER
your PATH is correctly defined in both cases (for roor the ORA_HOME var is empty)
0
 
seazodiacCommented:
you have to set ORACLE_HOME and TNS_ADMIN properly and strictly ( i.e. not ORA_HOME but ORACLE_HOME) to start some command line tool like dbca, lsnrctl ..etc.
so try to modify your script like this:


#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/product/9.2.0.1.0
export ORACLE_OWNER=oracle
export TNS_ADMIN= $ORACLE_HOME/network/admin
su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
0
 
brozzisCommented:

dear seazodiac,

there are 3 fatal errors in your script.
Moreover, as a system administrator, I wouldn't accept it, I consider it conceptually wrong.

0
 
seazodiacCommented:
brozzis:

please point out 3 fatal errors.

And What is being conceptually wrong in the script?

thx
0
 
brozzisCommented:

Sorry seazodiac, perhaps I was rude.
I apologize if my previous post was somehow or considered inappropriate.
I was in a hurry and my day wasn't one of the brightest so far...

However try this (copy'n'paste from your, adding one line):

[ste@nexus ste]$ cat script.sh
#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/product/9.2.0.1.0
export ORACLE_OWNER=oracle
export TNS_ADMIN= $ORACLE_HOME/network/admin
#su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
su - oracle -c "env|grep ORA"

and run it:
[ste@nexus ste]$ ./script.sh
./script.sh: line 4: export: `/u01/app/oracle/product/9.2.0.1.0/network/admin': not a valid identifier
Password:
[ste@nexus ste]$




#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/product/9.2.0.1.0
export ORACLE_OWNER=oracle
export TNS_ADMIN= $ORACLE_HOME/network/admin
----------------------------^space # 1
su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
-------^^^^^ORACLE_OWNER #2


exports are not inherited #3

the conceptual error is that oracle variables should be managed by the oracle user, not the root one.

root should have a script

su - oracle -c "start_listener.sh"

and user oracle should have the "start_listener.sh" script:

#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/product/9.2.0.1.0
export TNS_ADMIN=$ORACLE_HOME/network/admin
$ORACLE_HOME/bin/lsnrctl start

but since ORACLE_% vars seems to be correctly defined for the oracle user,
the "start_listener.sh" script could be reduced to a :


#!/bin/sh
$ORACLE_HOME/bin/lsnrctl start


0
 
seazodiacCommented:
brozzis:

that's fine. constructive criticism is more than welcome. I took it to be helpful.

"Conceptually", I never knew you meant that. (have the user accout manage his own variable).

But you are right, in reality, the env variables are separately managed by its owner.

But (yes another but) Xoxomos here just tried to get the concept correctly , at least I thought that way. Once he get the script execution smoothly, he then embark on further modifying his script to make it more robust.


I am not a SA, but  a DBA. I guess I took it for granted that things will work that way...

so you have to modify the script so that variables are using the hard-coded file path ....

Once again, however, the key here is what I said in my previous post:


"you have to set ORACLE_HOME (absolute requirement)  and TNS_ADMIN properly and strictly ( i.e. not ORA_HOME but ORACLE_HOME) to start some command line tool like dbca, lsnrctl ..etc."


so maybe this will work for xoxomos:




#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/product/9.2.0.1.0
export ORACLE_OWNER=oracle
export TNS_ADMIN=/u01/app/oracle/product/9.2.0.1.0/network/admin
su - $ORACLE_OWNER -c "/u01/app/oracle/product/9.2.0.1.0/bin/lsnrctl start"



xoxomos, let us know what happens?
0
 
brozzisCommented:

still wrong
ORACLE_HOME and TNS_ADMIN and are not inherited therefore their definition is useless...
Moreover xoxomos already declare these vars in the oracle .profile or similar

your script is equivalent to what I already posted
on Date: 08/28/2004 06:19AM PDT

ps
I'm a DBA too
0
 
seazodiacCommented:
Now, you are being radiculous ....

how can my script be wrong and at the same time equivalent to what you have posted?
doesn't that mean you have posted the same wrong script in your post?
so what you are saying?


Please don't bash other just try to prove you are right...


but I have to say, you got a point,

Xoxomos, have you manaully set the Oracle variables when you are running this script under Oracle user account? have you put all the variables into a .bash_profile file?
0
 
xoxomosAuthor Commented:
Don't laugh but if I run the .profile in the script, it will try to run but complain that it cannot write to the listener.log file in the $ORACLE_HOME/network/log directory.
I changed that from rw--r---r to rw-rw-rw and ran it again and it's working.  I think there is something about linux vs Solaris maybe Solaris runs the .profile when you su- and linux doesn't??????????????
I guess the su part takes place, but the listener does not start
then after /sysadmn/oracle/.profile, it gets whatever it needs?????????????

#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/product/9.2.0.1.0
export ORA_OWNER=oracle
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME
echo $ORACLE_HOME  "   HOME"
echo $TNS_ADMIN  "    TNS"
echo $ORA_OWNER "   OWNER"
echo $PATH
su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
sysadmn/oracle/.profile
$ORACLE_HOME/bin/lsnrctl start
exit








Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Starting /u01/app/oracle/product/9.2.0.1.0/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 9.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/9.2.0.1.0/network/admin/listene
r.ora
Log messages written to /u01/app/oracle/product/9.2.0.1.0/network/log/listener.l
og
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dwrepository)(PORT=1521)
))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 9.2.0.3.0 - Production
Start Date                01-SEP-2004 17:31:25
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  OFF
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/9.2.0.1.0/network/admin/listen
er.ora
Listener Log File         /u01/app/oracle/product/9.2.0.1.0/network/log/listener
.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dwrepository)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "dwprodrp.ccc.edu" has 1 instance(s).
  Instance "dwprodrp", status UNKNOWN, has 1 handler(s) for this service...
Service "dwtestrp.ccc.edu" has 1 instance(s).
  Instance "dwtestrp", status UNKNOWN, has 1 handler(s) for this service...
Service "owbnewrp.ccc.edu" has 1 instance(s).
  Instance "owbnewrp", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[root@dwrepository init.d]#
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now