The following is from the
book
Oracle Utilities
Starting and Stopping Oracle on Windows with
oradim
The dbstart and dbstop shell scripts do not exist on Windows
platforms. Consequently Oracle database startup and shutdown is
implemented completely differently. The oradim utility provides
more than just the ability to start and stop Windows databases.
Windows oradim can create and edit databases. It also allows DBAs
to configure script-based installation mechanisms.
The oradim utility is used on the Windows
platform to perform these tasks.
C:\ora11g\bin\oradim -startup -sid ORCL92 –usrpwd
manager
-starttype SRVC,INST -pfile
C:\ora11g\admin\ORCL92\pfile\init.ora
• startup – Indicates that the specified instance should be started.
• sid – The SID of the database to start.
• usrpwd – The password for the database user.
• starttype – Specifies whether to start the instance, the service, or
both
Startup -
The following command can be used to start
the instance with oradim:
C:\oracle\bin\oradim
–startup –sid
MYSID
Shutdown -
The following command can be used to shutdown
the instance with oradim:
C:\oracle\bin\oradim -shutdown -sid MYSID -shutttype
SRVC,INST –shutmode A
Create instance -
The following command can be used to create an instance with oradim:
C:\oracle\bin\oradim
–new –sid MYSID –intpwd
<pwd> –maxusers 20 startmode auto –pfile
initMYSID.ora
Delete Instance -
The following command can be used to delete an instance with oradim:
C:\oracle\bin\oradim
–delete –sid
MYSID
Notice that no password is needed to perform
this task.
The shuttype parameter specifies what is to be
stopped – the service (SRVC), the instance
(INST), or both (SRVC, INST). The shutmode
specifies the method that should perform the
shutdown – (A)bort, (I)mmediate, or (N)ormal.
Each operation, regardless of success, is
logged in the oradim log file.
The ORADIM utility only exists on Windows. It is the
command-prompt tool that creates, deletes, stops, and starts instances.
If you have UNIX scripts that create databases, you can still use them
(modified of course), but you will need to run ORADIM first to actually
create the Instance. This command is what actually creates the
Windows Service that runs the Instance.
An example of creating a
new Instance for ORCL is:
Oradim –new –sid ORCL –intpwd –maxusers
4 startmode auto –pfile initSID.ora
An example of
deleting the Instance for ORCL is:
Oradim
–delete –sid ORCL
An example of a shutdown and startup.
These can be used in scripts, such as for a cold backup.
Oradim –shutdown –sid ORCL –usrpwd
/ -shuttype inst, srvc –shutmode i
Oradim –startup –sid ORCL
The oradim utility can be launched several different ways to accomplish
differing tasks. Also, the parameters passed vary depending upon the
purpose being invoked. It creates a log file in the directory
$ORACLE_HOME\database.
To create a new instance, the syntax is as
follows:
-NEW -SID sid | -SRVC service | -ASMSID sid | -ASMSRVC
service
[-SYSPWD password] [-STARTMODE auto | manual] [-SRVCSTART
system | demand]
[-PFILE file | -SPFILE] [-SHUTMODE normal | immediate
| abort]
[-TIMEOUT seconds] [-RUNAS os_user/os_password]
To
modify an existing instance, the syntax is as follows:
-EDIT -SID
sid | -ASMSID sid
[-SYSPWD password] [-STARTMODE auto | manual] [-SRVCSTART
system | demand]
[-PFILE file | -SPFILE] [-SHUTMODE normal | immediate
| abort]
[-SHUTTYPE service | instance] [-RUNAS os_user/os_password]
To delete an existing instance, the syntax is as follows:
-DELETE -SID sid | -ASMSID sid | -SRVC service | -ASMSRVC service
To start up an existing instance, the syntax is as follows:
-STARTUP -SID sid | -ASMSID sid
[-SYSPWD password] [-STARTTYPE service
| instance | service,instance]
[-PFILE filename | -SPFILE]
To
shut down an existing instance, the syntax is as follows:
-SHUTDOWN
-SID sid | -ASMSID sid
[-SYSPWD password] [-SHUTTYPE service | instance
| service,instance]
[-SHUTMODE normal | immediate | abort]
Although no password is needed to perform this task, the Windows user must
have sufficient privileges to execute this command successfully.
The shuttype parameter specifies what is to be stopped – the service (SRVC),
the instance (INST), or both (SRVC, INST). The shutmode specifies the
method that should perform the shutdown – (A)bort, (I)mmediate, or (N)ormal.
Each operation, regardless of success, is logged in the oradim log
file (ORACLE_HOME\database\OraDim.Log). This file should be checked for
errors after each oradim command is executed.
The oradim utility
provides more than just the ability to start and stop Windows databases.
Oradim can create and edit databases. It also allows DBAs to configure
script-based installation mechanisms, bypassing the Oracle Database
Configuration Assistants graphical user interface (GUI).
For a
reference of all oradim commands, use the oradim–help command. A good
Oracle DBA will become intimately familiar with the oradim options, and
DBAs that start in Linux will often create their own dbstart /dbshut
scripts that call the oradim procedure.
More on oradimOracle on Windows is delivered
with a utility that is used exclusively for that Operating System – the
ORADIM utility. Basically its mission in life is to create, delete,
stop and start Oracle-related Windows Services from the command line.
In UNIX or Linux, when you create a database with a script, you use the
create database command - that’s all you need.
In Windows, you
first need to create the Windows Service. This is done with the
ORADIM command. Again, ORADIM can also be used to stop, start,
modify, and delete the service.
Please note that when using
the Oracle Database Assistant or choosing the create database option when
using the Oracle Universal Installer, this step us not necessary since
those create the service for you.
To create the service, the
general syntax is:
ORADIM -NEW -SID -INTPWD
-MAXUSERS
-STARTMODE -PFILE
An actual example to create the ORCL instance would be:
ORADIM
-NEW -SID ORCL -INTPWD mypasswd -MAXUSERS 4 -STARTMODE auto -PFILE
C:\oracle\10g\database\initORCL.ora
This would create the ORCL
instance (and associated Windows Service), with password mypasswd, allowing
4 users to connect as SYSDBA, with the service set to start automatically,
using a pfile of C:\oracle\10g\database\initORCL.ora.
A
couple things to note here: First, the command is all one continuous
line. Second, all that this does is create the Windows Service that
supports the Oracle Instance. It does NOT create the database; this
you need to do using scripts or commands.
Again, if you use
the Database Assistant or the Oracle Universal Installer, then the step of
creating the Windows Service is done for you.
ORADIM can also be
used to delete a service. To delete the service, the general
syntax is:
ORADIM -DELETE -SID
An example to delete
the ORCL instance would be:
ORADIM -DELETE -SID ORCL
The
database itself does NOT get deleted by this command, just the Windows
Service. Therefore, one could delete the service, recreate it using
the same name, and restart the instance. All of the database files
and contents would remain unchanged.
ORADIM can also be used to
stop and start the Oracle Instance. The commands are as follows:
To shut down the service (and so the database/instance):
ORADIM
-SHUTDOWN -SID -USRPWD / -SHUTTYPE SRVC -SHUTMODE
To shut down the database/instance but leave the service running:
ORADIM -SHUTDOWN -SID -USRPWD / -SHUTTYPE INST -SHUTMODE
Remember - the INST shuttype shuts the instance down, and the SRVC
shuttype stops the Windows Service and with it the database.
As an
example:
ORADIM -SHUTDOWN -SID ORCL -USRPWD / -SHUTTYPE SRVC -SHUTMODE
i
One would generally want the shutdown to be immediate or abort;
normal would hang until all users and transactions were completely done.
That could take all day!
To startup:
ORADIM –STARTUP –SID
As an example:
ORADIM –STARTUP –SID ORCL
These stop and start commands can be quite handy to use when scripting
shutdowns and startups, as well as for controlling things from the command
line.
In addition to the Oracle Alert Log, there is an ORADIM.LOG
in the ORACLE_HOME\database directory that tracks all instance shutdowns
and startups
The net stop and net start commands can be used to stop and start Oracle
Services from scripts and the command line.
Either ORADIM or
the net command can be used effectively for those purposes.
Warning - Your Oracle
Database Probably Will Not be Shutdown Cleanly When Windows is Shut Down!!!
If you recall, we reviewed Oracle Services in Chapter 6 and discussed
the Registry Settings controlling the Oracle Services in Chapter 4.
For a reference of all oradim commands, use
the oradim scripts here.
oradim script download
Oracle Windows oradim Utility
Auto start Oracle Automatically
Batch script to start Oracle Windows services
Advanced
Oracle Utilities - Oracle ORADIM Utility
How
to start Oracle Windows services
Oracle Utilities
Starting and Stopping Oracle on Windows
Oracle on Windows for Unix Users