Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Starting listener in a script

Posted on 2004-08-27
20
Medium Priority
?
3,810 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

604 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