How to connect to a DB installed on another host using shell script?
Hi Experts
There are two hosts say A and B. On host B, Oracle DB is installed and running. I am trying to check if the DB on host B is up and running fine from a script on host A. Is this possible. I tried using commands like sql plus but those doesn't seem to help. Could you please guide.
IMHO you need to see 2 things running on a server to consider an oracle instance is up, and perhaps running:
1) the listener
2) a oracle pmon process associated to that instance
Using sqlplus wont work if no listener to start with...
So a shell script would be to connect to the host B and using ps command and the adequate grep to return the wanted information
and your shell would be using a Here doc formating
Thanks for posting this. What error messages/output do you actually get? Please post them (in CODE tags for clarity) and we can try to help. Does it say sqlplus: not found or connection refused, something about credentials or what? It could be many things at present.
If there is not useful output because your script covers it up, try running your script with -x set. You don't mention a shell, but it might work as one of these or a similar variation:-
Indenting your code will help clarity and show you more easily where conditions and loops are effective.
Your "script on server A" also has this statement if (( $rval == 0 )) yet you do not set this. Your previous active statement may generate a return code or some output, but you don't use them. The return code from the script on Server B will not be passed back to server A. Server A will see the return code of the ssh command itself, not what was run by it so that will just tell you if ssh connected.
Have you considered tnsping to determine database state?
I'm afraid that none of the scripts posted will do what you expect. On the other hand, it's not too well known what your targets are. Some comments:
Host B:
- is that script's path /scripts/checkDB.sh?
- it will output lines after lines "Trying ..." and "DB is up ..." if the pmon test fails. This is important for the planned evaluation on host A.
- try ps -ef | grep -q [p]mon in lieu of your lenghtier approach.
Host A:
- the local variable checkDB will be filled with text (at least "DB is up ... if not with lines after lines) but never evaluated.
- rval is set to 0 and not modified before the first zero test.
- what is the process test for server.sh for?
- why do you run startup.sh on host A if the DB should run on host B?
- same comment on ps ... | grep ... as for host B.
Thank you for getting back. I am trying to bring up a application server on Host A if the DB is up on host B. tnsping and sqlplus are not working when trying to execute on Host A. So i thought of doing an ssh to host B and if the process ID is up or retry till the process ID on host B is up and then start the application server on Host A.
So, given that my crystal ball is in for servicing at the moment, when you say "not working", can you actually show us the errors? Without them I might suggest:-
You don't have the Oracle client installed
Your network configuration is wrong 'somewhere'
tnsnames.ora is incomplete
The server is not listening on the defined port
You have a spelling mistake
Is the power on even?
It might seem a little flippant and I apologise, but if we cannot see the symptoms, we can't help to diagnose it.
hello
i try to made a report to conect all database to diferent OS
HP-UX/LINUX/SOLARIS/AIX
this is my example
i have 5 db
OS are HP-UX
ps -fea | grep pmon
root 1120 1 0 Nov 29 ? 5:14 ipmon -sD
oracle 10286 1 0 Nov 29 ? 27:19 ora_pmon_BD1
oracle 10431... (7 Replies)
Hi All,
Need to connect to target host and execute a command and connect back to source host to continue with next set of command execution.
Is there a utility/command using which we can connect to target host ?
Please suggest.
Note: Netezza database is instaled on Linux server. ... (4 Replies)
Hi
i am trying to open HTTP by curl command.
i am tryng to do that from command or script BASH.
also iptables is off
it doesnt work i am getting an error:
curl: (7) coudn't connect to host
the scipt is:
#! /bin/bash
curl http://www.cnn.com (1 Reply)
I currently have a shell script that utilizes the "Date" binary - this application is slightly different on OS X (BSD General Commmand) and Linux systems (gnu date). In particular, the version on OS X requires the following to get a date 14 days in the future "date -v+14d -u +%Y-%m-%d" where gnu... (1 Reply)
Hi everyone,
I have oracle 9i installed in Windows XP and i have ubuntu in VM WARE.
I would like to know how to connect to Oracle in windows xp from Linux through shel scripting...... (3 Replies)
Hello all
I installed apache in CentOS 5.5 ,after searching the web for tips on configuration
I did the fallowing stuff to unable connecting the http server from outside.
In /etc/httpd/conf/httpd.conf I changed the Listen value to 0.0.0.8011
Then checked with then check with: netstat -anp and I... (2 Replies)
i want use ssh on the host01 to execute autoexec.sh on the host02 like following :
host01> ssh host02 autoexec.sh
autoexec.sh include nohup command like follwing :
nohup /home/jack/deletedata.sh &
after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
How can my unix shell script automatically connect to remote host?
Assume that there is a remote host called "rhost". When I connect to that host i give the command "telnet rhost".
It then asks me for my id and password. Once i give it connects there.
I want to automate these steps. I want... (8 Replies)
hi there
I've got a strange problem with a webserver box (suse linux 7.2). My MTA is sendmail, and when I tried manually send a mail.
Sendmail -v "user@something" < /etc/hosts
The Server tried
"simon@localhost... Connecting to local..." but nothing happend and the system hold on.
This... (3 Replies)