?
Solved

Starting listener in a script

Posted on 2004-08-27
20
Medium Priority
?
3,806 Views
Last Modified: 2007-12-19


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
Comment
Question by:xoxomos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 5
20 Comments
 
LVL 23

Expert Comment

by:seazodiac
ID: 11916905
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
 

Author Comment

by:xoxomos
ID: 11917234
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
 
LVL 23

Expert Comment

by:seazodiac
ID: 11917250
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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 23

Expert Comment

by:seazodiac
ID: 11917260
also did you patch your instance from 9.2.0.1 to 9203?
0
 
LVL 23

Expert Comment

by:seazodiac
ID: 11917283
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
 

Author Comment

by:xoxomos
ID: 11917376
Yes, it's at the .0.3 level, but was .0.1 on initial install.
0
 

Author Comment

by:xoxomos
ID: 11917541
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
 
LVL 23

Expert Comment

by:seazodiac
ID: 11918133
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
 

Author Comment

by:xoxomos
ID: 11918749
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
 
LVL 2

Expert Comment

by:brozzis
ID: 11921039

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
 

Author Comment

by:xoxomos
ID: 11933601
#!/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
 
LVL 2

Expert Comment

by:brozzis
ID: 11934610

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
 
LVL 23

Expert Comment

by:seazodiac
ID: 11934985
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
 
LVL 2

Expert Comment

by:brozzis
ID: 11935527

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
 
LVL 23

Expert Comment

by:seazodiac
ID: 11935578
brozzis:

please point out 3 fatal errors.

And What is being conceptually wrong in the script?

thx
0
 
LVL 2

Accepted Solution

by:
brozzis earned 800 total points
ID: 11936517

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
 
LVL 23

Assisted Solution

by:seazodiac
seazodiac earned 600 total points
ID: 11936785
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
 
LVL 2

Expert Comment

by:brozzis
ID: 11936853

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
 
LVL 23

Expert Comment

by:seazodiac
ID: 11936988
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
 

Author Comment

by:xoxomos
ID: 11959228
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

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question