Friday, April 17, 2009

Automatic startup issues of oracle database on windows

If you look for automatic startup on unix or linux server then have a look at,
http://arjudba.blogspot.com/2008/10/automatic-startup-and-shutdown-oracle.html
This post is related to automatic startup of windows machine only.

On windows to run oracle as background they run as windows services. If your oracle is started then you can see the background process oracle.exe after opening task manager (by pressing CTRL+ALT+DEL) and then browsing the processes tab. The background oracle.exe process is normally owned by system.

With the sc command (which is NT Service Controller and services) you can start and stop oracle service which is discussed on http://arjudba.blogspot.com/2008/10/how-to-start-services-from-command.html

Don't think that windows service is the database. Windows service can start/stop the database but it is also true that service has started but database does not yet started. You can start/stop oracle service from computer management.

To do so,
1)Right click on My Computer icon and click manage. You will see Computer Management window.
Alternatively you can open the window by,
- Go to control panel.
- Switch to classic view > Click Administrative Tools.
- Click Computer Management icon.

2)Go to the Services and Application menu > Select Services.

3)Navigate to Oracle Service. The name is in the form OracleService$ORACLE_SID where you may have orcl or other name instead of $ORACLE_SID.

4)Right click on that service. There you can see the "Startup type" drop down menu. If you select Automatic then database should starting up automatic while starting your windows. If it is manual then you need to manually start/stop the service.

Alternatively using oradim utility you can specify whether database would be started automatic or manual.

You can see list of oradim command by typing oradim on your command prompt as,
E:>oradim
ORADIM: [options]. Refer to manual.
Enter one of the following command:
Create an instance by specifying the following options:
-NEW -SID sid | -SRVC srvc | -ASMSID sid | -ASMSRVC srvc [-SYSPWD pass]
[-STARTMODE auto|manual] [-SRVCSTART system|demand] [-PFILE file | -SPFILE]
[-SHUTMODE normal|immediate|abort] [-TIMEOUT secs] [-RUNAS osusr/ospass]
Edit an instance by specifying the following options:
-EDIT -SID sid | -ASMSID sid [-SYSPWD pass]
[-STARTMODE auto|manual] [-SRVCSTART system|demand] [-PFILE file | -SPFILE]
[-SHUTMODE normal|immediate|abort] [-SHUTTYPE srvc|inst] [-RUNAS osusr/ospass]
Delete instances by specifying the following options:
-DELETE -SID sid | -ASMSID sid | -SRVC srvc | -ASMSRVC srvc
Startup services and instance by specifying the following options:
-STARTUP -SID sid | -ASMSID sid [-SYSPWD pass]
[-STARTTYPE srvc|inst|srvc,inst] [-PFILE filename | -SPFILE]
Shutdown service and instance by specifying the following options:
-SHUTDOWN -SID sid | -ASMSID sid [-SYSPWD pass]
[-SHUTTYPE srvc|inst|srvc,inst] [-SHUTMODE normal|immediate|abort]
Query for help by specifying the following parameters: -? | -h | -help

So to automatic startup of orcl database you may issue,
E:> oradim -edit -sid orcl -startmode auto

To make it manual you may issue,
E:> oradim -edit -sid orcl -startmode manual

After making it automatic, sometimes after starting windows you may wonder why my oracle service or sometimes oracle database is not yet started. This post will give you step by steps idea to resolve that problem.

1)Ensure that your oracle service is set to automatic. You can do it by oradim or with help you windows service which is discussed on the above of this post.

If you have already automatic but database service is not started then there is possibly improper settings in the registry or this is bad service.

2)After starting windows check if the oracle service is started. You can check it from task manager and looking for entry oracle.exe which is also discussed above of this post. If this is present then oracle service is started but oracle database is not. Investigate why oracle database is not started.

A proper way is to check alert log entry of the database. Alert log location is specified inside pfile/spfile of the database. If the problem is not with the database rather than oracle service then there will be no indication in the alert log that the database even tried to start.

3)If there is no error in the alert log then connect to sql*plus as sysdba and try to start your database.

sqlplus / as sysdba
startup


4)If step 3 is successful then be sure the problem is related to windows service. May be there is improper settings in the registry or it is bad service.

5)Check setting on registry. From Start menu> Click Run and then type regedit.
Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ORACLE_HOME_NAME

-First take a backup of the registry entry by right clicking on the ORACLE folder on the left and then export.

-In the ORACLE_HOME_NAME you will see a key name ORA_$ORACLE_SID_AUTOSTART. If your database name is orcl then you will see a key named ORA_orcl_AUTOSTART.
The value of this key must be TRUE in order to automatic startup of the database. Edit the key and make it TRUE.

-After change ORA_$ORACLE_SID_AUTOSTART to TRUE test the service by stopping and then restarting the service to see it the database automatically starts. If it does, then that fixed your problem. You can also reboot the server to verify that the database will start automatically. However in some cases your database does not start after rebooting. Then there is problem with the service itself. Follow step 6 then.

6)Delete the service.
E:>oradim -delete -sid $ORACLE_SID


If your $ORACLE_SID is orcl then the command will be,
E:>oradim -delete -sid orcl

Then create the service by,
oradim -new -sid $ORACLE_SID -startmode AUTO

If your $ORACLE_SID is orcl then the command will be,
oradim -new -sid orcl -startmode AUTO

If you use password file and initialization file other than default location then start it by,
E:>oradim -new -sid orcl -intpwd a -startmode AUTO -pfile D:\initorcl.ora

Where database name is orcl, SYS password is a and pfile resides on D:\initorcl.ora

Related Documents
http://arjudba.blogspot.com/2008/10/automatic-startup-and-shutdown-oracle.html

1 comment:

  1. Good article, thank you! If you are encountering ORA-27101 and ORA-01034 take a close look at this after you are convinced there's nothing wrong with your Oracle environment variables.

    ReplyDelete