on 11-08-2013 2:18 PM
Hi,
we have a sap system running on windows.
Iam not good at prgramming, iam looking for a small script which first starts Oracle and then SAP system on windows machine.
It should look something like this:
Check if Oracle listener process is down
if yes
(
start the oracle listener
5 seconds pause
start the Oracle DB
5 seconds pause
start the sap
)
if no
(
do nothing
)
Please help.
Many thanks,
Mohan.
hi Krishna,
As per your requirement. first You can start Oracle then SAP in a sequence(oracle, SAP).
For Start Oracle:
Please create a file with name startup.sql and put this text startup
now make a batch file with name StartOracle.bat and put the following text.
sqlplus /@SID as sysdba @drive:\Startup.sql
For Start SAP:
Please make a batch file with name StartSAP.bat and put following text as per your installation drive.
usr\sap\SID\DVEMGS00\exe\startup name=SID nr=00 sapdiahost=Hostname
now schedule the both batch files(StartOracle.bat, StartSAP.bat ) via
Start --> Administrative Tools --> Task Scheduler
FYI..: whenever you start the SAP via SAPMMC. first start the oracle and start the sap ecc.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Billy & Abdul,
based on your tips, i created this code but somehow it is not working. Where am i going wrong? The code is based on my logic above:
net Start|find /i "OracleEFB11203TNSListener">nul
If errorlevel 1
(
Net start "OracleEFB11203TNSListener";
sqlplus "/ as sysdba" ;
startup open;
exit;
startsap name=EFB nr=00 SAPDIAHOST=vm0123;
)
else
(
echo Processes are running
)
Regards,
Mohan.
my first advise is:
You need to pay attention that starting a service will first start the service process which is normally in "start pending" mode. If the service reaches the status "running" it is operational and you can work with.
So be prepared to listen to the current status before performing the next step.
In terms of Oracle the database consists of at least two processes:
The listener is needed to allow remote connections (using tcpip or named pipe sockets. SAP Systems perform a remote connection to the database).
You can start the listener any time without starting the database.
The database itself consist of two different services:
The database instance can be started when starting the (Windows) database service. Thats a question of the configuration of the service (run oradim for more information).
In powershell:
Start-Service "OracleServiceXXX"
Start-Service "Oracle*Listener" #yeah Start-Service supports Wildcards!!
# be sure that you have defined ORACLE_SID as environment variable!!!
# furthermore your user account needs to be in the ORA_DBA or ORA_SID_DBA operating system group
$env:ORACLE_SID="PRD"
sqlplus /nolog
connect / as sysdba
startup
exit
# now we start the sap instance. Do no longer use sapstart/startsap
sapcontrol.exe -prot PIPE -nr 00 -function Start
that's it
regards
Peter
You need to create If / Then statements and based on the conditions met will run the execution.
If oracle.service.1 = down then start oracle.service.1
or
If oracle.process.1 = down then start oracle.service.1
You are going to have problems trying to start services that are already running and return odd values if you do not first capture the status of the services/processes.
Chek this wiki.. you will very happy to start with this.
http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=198738223
best regards
ashish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Ashish,
thanks for the link. I have managed to write the code on my own:
@echo off
net Start|find /i "OracleEFB11203TNSListener" >NUL
IF ERRORLEVEL 1 (
ECHO NOT Running.
net start OracleEFB11203TNSListener
sqlplus "/ as sysdba" @D:\scripts\startdb.sql
startsap name=EFB nr=00 SAPDIAHOST=vmbn0236
) ELSE (
ECHO Running.
)
pause;
In the startdb.sql , i wrote startup open; exit;
Thanks to everybody,
Mohan.
A batch file should accomplish this just leverage the 'sc' command:
sc start oracle.service.1
ping ip.add.re.ss
sc start oracle.service.2
ping ip.add.re.ss
sc start SAP
This doesn't include service/process checking, but you can leverage something like pslist to check on a process and depending on the exit code take action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.