0
votes

How to check oracle listener status by java program on Linux Server.

How I do the server by manually. After login to the server, I have to execute .oraenv proflie of oracle database which asks for Oracle SID{Oracle database name} then it will start working

lsnrctl status command.

[oracle@xx$ . oraenv ORACLE_SID = [daltaasm] ? deltaasm The Oracle base has been set to /u01/app/oracle oracle@XX$ clear oracle@xx$ . oraenv ORACLE_SID = [deltaasm] ? deltaasm The Oracle base remains unchanged with value /u01/app/oracle oracle@xx$ ^C oracle@xx$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 05-APR-2018 05:18:21

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 02-APR-2018 11:45:50 Uptime 2 days 17 hr. 32 min. 31 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /u01/app/oracle/diag/tnslsnr/deltaoramegan/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DeltaOraMegan.local)(PORT=1521))) Services Summary... Service "+ASM" has 1 instance(s). Instance "+ASM", status READY, has 1 handler(s) for this service... Service "deltaasm" has 1 instance(s). Instance "deltaasm", status READY, has 1 handler(s) for this service... Service "deltaasmXDB" has 1 instance(s). Instance "deltaasm", status READY, has 1 handler(s) for this service... The command completed successfully oracle@xx$ ^C

So how to implement java program to check lsnrctl status command status

If I don't do manually execuation. oraenv profile on Linux server it will show lsnrctl status command not found

ex oracle@xx$ snrctl status lsnrctl status command not found

Please suggest the problem solution in java program

1

1 Answers

0
votes

oraenv is just a wrapper shell script that will set $ORACLE_HOME, $ORACLE_SID, $ORACLE_BASE and the $PATH variable for you. You can just open it with a text editor and you will see all the shell code. In a nutshell, it will look at /etc/oratab where Oracle records the information of Oracle homes (there can be more than one on a given server) and also which database uses those which Oracle home.

The lsnrctl binary can be found in $ORACLE_HOME/bin, so the trick is to find out what $ORACLE_HOME is. If you install it in a fixed location, you can just simple set the $ORACLE_HOME and $PATH accordingly, for example:

Assuming that I installed the Oracle software in /opt/oracle/product/12.2.0.1/dbhome_1 my environment variables would look as follows:

export ORACLE_HOME=/opt/oracle/product/12.2.0.1/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin

From that point on you can now just call lsnrctl (because it's now in the $PATH).

So, the trick is to find out where you have the Oracle software installed which you can just find out by looking at /etc/oratab or, in case you always install it in the same place (very often the case), just set the variables beforehand.