Saturday, April 12, 2008

Adventures with Apex, part two: Setting up the stand-alone Oracle HTTP Server as a Windows service

The latest stand-alone version of Oracle HTTP Server (OHS) for Windows is available on OTN as the file "iAS_101330_Apache2_Modplsql2_win32.zip".

I ran the default setup on a Windows 2003 server (a separate machine from the database server) and encountered no errors during installation. The setup process created a few Start Menu items to start and stop the Apache process (through the Oracle Process Manager, OPMN, and the "opmnctl startall" command, which in turn starts the HTTP Server).

After configuring OHS and mod_plsql on the webserver to connect to Apex on the database server (as per the Apex installation docs), everything seemed to work fine. However, when I logged out of the server, the Apex application (and OHS) stopped responding.

Investigating, I found that the Apache process (apache.exe) is started and runs under the current logged-in user when using the Start Menu item to start it. So once I logged out of the server, the Apache process shuts down...!

As far as I could tell, there should have been a Windows service called OracleProcessManager that runs the OPMN process in the background, without requiring a logged-on user. However, there is no such service created after installation.

I tried creating the service manually myself using the "sc create" command. The service was created successfully but gave an error message ["...did not respond in a timely fashion..."] when trying to start it.)

Fortunately, I had a quick look in the Knowledgebase on Metalink and found the solution there. According to Note:459474.1, entitled "Howto Create a Windows Services Entry for Starting Oracle Application Server Processes", this behavior is by design (!)...:

Most Oracle Application Server installations automatically create a Windows Services entry to allow the OracleAS processes to start up on server startup. By design, certain OracleAS releases such as the SOA Suite 10.1.3.1 do not create the Windows Services entry. In such installations, the user starts OracleAS processes from the Windows Start Menu. When the user logs out of the Windows session, the OracleAS processes will terminate as well. Resulting in an unexpected Application Server shutdown.

This note provides the steps to create a Windows Services entry for starting up OracleAS processes upon reboot/startup of the server. Processes started via Windows Services entries are not affect by a user logging out of the Windows session.

I'll leave the question as to why on earth the setup program doesn't create the necessary Windows services by default, for what is clearly a server-type product?!? up in the air for now.

Instead, I will provide the necessary details here for those who do not have access to Metalink:

Turns out I was right about having to create a Windows service manually using the "sc" command, but there is also a few registry entries that need to be present for it to work.

First, find the "key" value from the file \opmn\bin\oracle.key on the server. In my case, the value of this key was:

SOFTWARE\ORACLE\KEY_oracleas1

Run regedit and add the following two entries (in my case, the first entry already existed):


HKLM / Software / ORACLE / Key_oracleas1 / ORACLE_HOME_KEY = SOFTWARE\ORACLE\KEY_oracleas1


and


HKLM / Software / ORACLE / oracleas1 / ORACLE_OPMN_SERVICE = OracleHTTPServerProcessManager


Then run the following command to create the service:


sc create OracleHTTPServerProcessManager binPath= "c:\OraHome_1\opmn\bin\opmn.exe -s" DisplayName= "OracleHTTPServerProcessManager" start= "auto"


Note that there must be an empty space between the equal sign and the value in the command above. Apparently some kind of quirk with the sc command. By the way, the sc command is part of the Windows server resource kit (but it was already present on my Windows 2003 server).

After creating the service, go to Services and verify that the service starts up. Also verify using Task Manager that apache.exe runs under the SYSTEM user, rather than the logged-in user.

8 comments:

Anonymous said...

Thank you very much. This worked great. I appreciate you putting it out there for us.

Patti

Andy C Chow said...

I installed Oracle HTTP Apache 2 in the same server (Windows 2003) with the Oracle database software installation. I tried to follow the following artical to install a Windows service but failed to start the service afterward. I ran the following command in command prompt to create the Windows service and, when I tried to start it, it said "Error 1053: The service did not respond to the start or control request in a timely fashion".

Thanks.

sc create OracleHTTPServerProcessManager binPath= "f:\ora_http_v2\opmn\bin\opmn.exe -s" DisplayName= "OracleHTTPServerProcessManager" start= "auto"

Anonymous said...

I'm encountering the same 1053 error, after following the above steps and successfully (apparently...) creating a Windows Service with the following command:

C:\>sc create OracleHTTPServer101320ProcessManager
binPath= "C:\OracleXE\app\oracle\product\10.1.3.2.0\server\opmn\bin\opmn.exe -s"
DisplayName= "OracleHTTPServer101320ProcessManager" start= "auto"

Has anyone been able to find a solution? Thanks.

Anonymous said...

Metalink note 428131.1 says we also need to create the ASControl service, in addition to the ProcessManager service. But this requires the presence of nmesrvc.exe which I do not have in my OHS directory structure...

Anonymous said...

Someone on Metalink explained to me that ASControl is only required on older versions of OHS, so that's not the issue. So my original problem is that the following error message pops up, upon trying to start the ProcessManager:

"Error 1053: The service did not respond to the start or control request in a timely fashion"

Any clue? Thanks,

Chris

Morten Braten said...

@gers32: I'm afraid I don't have any clue as to what the problem is. I followed the procedure that I documented in the blog post when I installed (on a web server machine separate from the database server), and it worked for me. Did you check that the registry settings are correct? Look for any error messages in the Windows Event Log and the Oracle log files.

Anonymous said...

it 's case sensitive it has to be:
opmn -S

gr. André

Anonymous said...

Aha! Thank you André for this precious information; that was it!