This page applies to an earlier version of the AppDynamics App IQ Platform.
See the latest version of the documentation.
On this page:
Related pages:
Most Windows server software runs as a service when the machine boots up. To secure your environment and ensure Database Agent availability, you can install the Database Agent as a Windows service using the SRVANY.EXE and SC.EXE utilities that are part of the Microsoft Resource Kit for Windows 2003 Server. The SRVANY.EXE tool creates a Windows service that launches the JVM processes for the agent in non-GUI mode using parameters specified in the registry of the service. The SC.EXE command is used to install and uninstall the agent service.
Install the Database Agent as a Windows Service - Pre Windows 2008
The following procedure involves editing the registry. Before proceeding, know how to backup and restore the registry as described in the WIndows Registry Editor online help.
Install the agent as usual, described in Install the Database Agent.
- Obtain the INSTSRV.EXE and SC.EXE utilities.
Download the Windows Server 2003 Resource Kit Tools, at http://www.microsoft.com/en-us/download/details.aspx?id=17657. The required utilities are included in this resource kit - Prepare registry and batch command files.
To simplify service creation and deregistration, we have attached two batch command files, InstallService.cmd and UninstallService.cmd to this page. InstallService.cmd requires the information in the DatabaseAgent.reg file to set the registry key for the service.- DatabaseAgent.reg to set the registry key values for the service
- InstallDBService.cmd to install the service
- UninstallDBService.cmd to uninstall the service
Download these files and edit them as indicated below. Specify the same service name in all three files.
Customize DatabaseAgent.reg.
Edit the service name, Application, AppParameters, and AppDirectory values of this file for your environment.
- Specify the service name is specified on the first line of this file.
AppDynamics Database Agent Service
in the sample attached. Application
is the path to the JDK you use for Database Agent.
<db_agent_home>\\jre7\\bin\\java.exe
in the sample attached. The Database Agent is compatible with JRE 1.7 and 1.8AppParameters
is everything you want to pass to the JVM as arguments.
For a 32-bit system, set java.library.path="<db_agent_home>\auth\x32", the absolute path
For a 64-bit system, set java.library.path="<db_agent_home>\auth\x64", the absolute path
If your agent will be monitoring more than 100 databases, increase the size of the initial memory allocation specified in the code example below as follows:
change-Xmx32m
to-Xmx256m
For 64-bit systems, allocating 32 MB of initial heap sizejava -Djava.library.path="<db_agent_home>\auth\x64" -Xms32m -jar "<agent_home>\db-agent.jar"
AppDirectory
points to the agent working directory, the location where you installed the Database Agent.<agent_home>
.
- Specify the service name is specified on the first line of this file.
Customize InstallDBService.cmd.
Edit the create and binPath values in this file for your environment.
- Specify the service name in quotes in the sc command create option as follows:
sc create "AppDynamics Database Agent Service"
in the sample attached. Specify binPath as the path to the SRVANY.EXE Windows Resource
<agent_home>\srvany.exe in the sample attachedThe service installed runs with the permissions of the user logged in when service is created. To change the user running the installed process, modify InstallService.cmd by inserting the following anywhere before "pause" at the end of the file.
sc config <service> obj= <username> password= <password>
Note: There is a required space between obj= and <username> .
Customize UninstallDBService.cmd
UninstallDBService.cmd - Uninstalls the Database Agent Service@echo off rem UnInstall AppDynamics Database Agent Service echo "Stopping AppDynamics Database Agent Service - may be running" sc stop "AppDynamics Database Agent Service" echo "Uninstalling AppDynamics Database Agent Service from the Service Manager" sc delete "AppDynamics Database Agent Service" echo "done." pause
- Specify the name of the service in quotes after the sc stop or delete options.
"AppDynamics Database Agent Service" in the sample file attached.
- From the Windows Explorer, right-click InstallDBService.cmd and click Run as Administrator.
Install the Database Agent as a Windows Service - Windows 2008 and 2012
Download NSSM - the Non-Sucking Service Manager.
Create a start.bat file containing your agent startup script, such as:java -Djava.library.path="<agent_home>\auth\x64" -jar "<agent_home>db-agent.jar"
where <agent_home> is where you installed the Database Agent.
Note that if the agent configuration property values contain spaces, you must enclose the entire name in double quotes (" "). For example,
Windows, 64-bit system with 256 MB initial memory allocation
java -Djava.library.path="<db_agent_home>\auth\x64" -Ddbagent.name="Scarborough Network Database Agent" -Dappdynamics.agent.uniqueHostId="Scarborough Network Database Agent Host" -jar "<db_agent_home>\db-agent.jar"
For a 32-bit system, set java.library.path="<db_agent_home>\auth\x32"
as the absolute path
For a 64-bit system, set java.library.path="<db_agent_home>\auth\x64"
as the absolute path
If your agent will be monitoring more than 100 databases, increase the size of the initial memory allocation specified in the code example below as follows:
change -Xmx32m
to -Xmx256m
Add the path to nssm.exe to your Path environment variable.
Start a command shell and enter the following:
nssm.exe install <service name>
where <service name> is the name of the agent service.
In the NSSM service installer dialog, enter the full path to the agent startup script in the Path field of the Application tab. Enter any other details appropriate for your environment. For information on the various options, see the NSSM documentation.
Click Install service.
A service is created named <service name>, that starts up automatically when the machine is started and that is also restarted if the process stops for any reason.
Uninstall the Database Agent as a Service
If you used INSTSRV.EXE and SC.EXE utilities:
From the Windows Explorer, right-click UninstallService.cmd and click Run as Administrator. This stops and removes the service from Windows.
If you used NSSM:
From a command shell, enter
nssm.exe remove <service name>
where <service name> is the name of the agent service.
Known Issues
In Windows Server 2003 you must install and start or stop the service from the console window. If you do a normal RDP connection to the 2003s Terminal Services the service will be stopped when you log-out. Therefore issue the command "mstsc /console <machinename>" to connect to the console session of Windows Server 2003.
Running the Agent on Windows Using the Task Scheduler
It is recommended to run the Database Agent as a Windows service. However, if you choose to run the agent using Task Scheduler, ensure the agent runs with the highest privileges available. When using Task Scheduler, if the host is restarted, the agent will not start automatically.