01 Dec Installing Terracotta as a Windows service
Since the release of webMethods 9.0, Software AG uses TerraCotta as distributed cache for their cluster solution on Integration Server. The software can be easily installed using the SoftwareAG installer, but has a big drawback on Microsoft Windows systems: there is no procedure to install Terracotta as a Windows Service. Therefore, the server needs to be started on command line with all its consequences.Fortunately, there are several solutions available:
Tanuki java wrapper
Can be configured to work with Terracotta, but the community edition only supports 32-bit JVM. Due to its memory limitation, this is not a very good solution. You can find the software at http://wrapper.tanukisoftware.com/In case you want to buy the software for 64-bit support, configuration can be done as follows:
- Download the wrapper and unzip in folder
D:SoftwareAGTerracottawrapper
- Make a wrapper file TerraCotta.conf with the following configuration and place it under D:SoftwareAGTerracotta. Suppose the Terracotta config file tc-config.xml can be found under
D:SoftwareAGTerracottabin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# for logging wrapper.java.command.loglevel=INFO wrapper.java.command=D:SoftwareAGjvmjvm170_32binjava # Method 1 main class wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperStartStopApp # classpath wrapper.java.classpath.1=D:Temp wrapperlib/wrapper.jar wrapper.java.classpath.2=D:/SoftwareAG/Terracotta/lib/tc.jar wrapper.java.library.path.1=D:Tempwrapper/lib # Java Additional Parameters wrapper.java.additional.1=-server wrapper.java.additional.2=-XX:+HeapDumpOnOutOfMemoryError wrapper.java.additional.3=-Dcom.sun.management.jmxremote wrapper.java.additional.4=-Dsun.rmi.dgc.server.gcInterval=31536000000 wrapper.java.additional.5=-Dnet.sf.ehcache.enableShutdownHook=false wrapper.java.additional.6=-Dcom.tc.l2.db.factory.name=com.tc.objectserver.storage.derby.DerbyDBFactory wrapper.java.additional.7=-Dtc.install-root=D:/SoftwareAG/Terracotta # Initial Java Heap Size (in MB)wrapper.java.initmemory=512# Maximum Java Heap Size (in MB) wrapper.java.maxmemory=512 # Application parameters. This is where you specify TC server main class wrapper.app.parameter.1=com.tc.server.TCServerMain wrapper.app.parameter.2=2 wrapper.app.parameter.3=-fwrapper.app.parameter.4=D:SoftwareAGTerracottabintc-config.xml wrapper.app.parameter.5=com.tc.admin.TCStop wrapper.app.parameter.6=FALSE wrapper.app.parameter.7=5 wrapper.app.parameter.8=-f wrapper.app.parameter.9=D:SoftwareAGTerracottabintc-config.xml wrapper.app.parameter.10=-n wrapper.app.parameter.11=Server2 wrapper.app.parameter.12=9520 wrapper.logfile=D:SoftwareAGTerracotta/ wrapper.log # Format of output for the log file. (See docs for formats) wrapper.logfile.format=LPTM # Log Level for log file output. (See docs for log levels) wrapper.logfile.loglevel=INFO # On exit behaviour wrapper.on_exit.0=SHUTDOWN wrapper.on_exit.default=RESTART |
- You can install the service by running the following command: sc create Terracotta binPath= D:SoftwareAGTerracottawrapperwrapper.exe -s D:SoftwareAGTerracottaTerraCotta.conf start= auto
Yet Another Java Service Wrapper (YAJSW)
YAJSW is a pure java implementation of the Tanuki Java Wrapper. Its big advantage is that it’s free and supports both 32 and 64-bit JDK 5, 6 and 7. You can find the software at http://yajsw.sourceforge.net/
Configuration can be done as follows:
- Download and unzip the wrapper under D:SoftwareAGTerracottawrapper
- Make a wrapper.conf file with the following configuration and place it under D:SoftwareAGTerracottawrapper. Important to mention is to use / instead of !!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
wrapper.java.command=D:/SoftwareAG/jvm/jvm170_64/bin/java wrapper.stop.conf = D:/SoftwareAG/Terracotta/wrapper/wrapper.stop.conf wrapper.java.classpath.1= D:/SoftwareAG/Terracotta/wrapper/wrapper.jar wrapper.java.classpath.2=D:/SoftwareAG/Terracotta/lib/tc.jar wrapper.java.app.mainclass = com.tc.server.TCServerMain wrapper.console.title = TerraCotta wrapper.ntservice.name = TerraCotta wrapper.ntservice.displayname = TerraCotta wrapper.ntservice.description = TerraCotta wrapper.app.parameter.1= -f wrapper.app.parameter.2= D:/SoftwareAG/Terracotta/bin/tc-config.xml wrapper.logfile=D:/logs/wrapper.log wrapper.logfile.format=LPTM wrapper.logfile.rollmode=DATE wrapper.logfile.maxdays=10 wrapper.java.additional.1=-server wrapper.java.additional.2=-Xms1024M wrapper.java.additional.3=-Xmx1024M wrapper.java.additional.4=-XX:+HeapDumpOnOutOfMemoryError wrapper.java.additional.5=-Dcom.sun.management.jmxremote wrapper.java.additional.6=-Dsun.rmi.dgc.server.gcInterval=31536000000 wrapper.java.additional.7=-Dnet.sf.ehcache.enableShutdownHook=true wrapper.java.additional.8=-Dcom.tc.l2.db.factory.name=com.tc.objectserver.storage.derby.DerbyDBFactory wrapper.java.additional.9=-Dtc.install-root=D:/SoftwareAG/Terracotta wrapper.java.additional.10=-Djava.net.preferIPv4Stack=true wrapper.on_exit.0=SHUTDOWN wrapper.on_exit.default=RESTART |
- Also make a wrapper.stop.conf file in the same folder with the following configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
wrapper.stopper = true wrapper.java.command=D:/SoftwareAG/jvm/jvm170_64/bin/java wrapper.java.classpath.1= D:/SoftwareAG/Terracotta/wrapper/wrapper.jar wrapper.java.classpath.2=D:/SoftwareAG/Terracotta/lib/tc.jar wrapper.java.app.mainclass = com.tc.admin.TCStop wrapper.app.parameter.1=-f wrapper.app.parameter.2=D:/SoftwareAG/Terracotta/bin/tc-config.xml wrapper.app.parameter.3=-n wrapper.app.parameter.4=Server1 wrapper.app.parameter.5=9520 wrapper.logfile=D:/logs/wrapper_stop.log wrapper.logfile.format=LPTM wrapper.logfile.rollmode=DATE wrapper.logfile.maxdays=10 wrapper.java.additional.1=-server wrapper.java.additional.2=-Xms512M wrapper.java.additional.3=-Xmx512M wrapper.java.additional.4=-XX:+HeapDumpOnOutOfMemoryError wrapper.java.additional.5=-Dcom.sun.management.jmxremote wrapper.java.additional.6=-Dsun.rmi.dgc.server.gcInterval=31536000000 wrapper.java.additional.7=-Dnet.sf.ehcache.enableShutdownHook=true wrapper.java.additional.8=Dcom.tc.l2.db.factory.name=com.tc.objectserver.storage.derby.DerbyDBactory wrapper.java.additional.9=-Dtc.install-root=D:/SoftwareAG/Terracotta wrapper.java.additional.10=-Djava.net.preferIPv4Stack=true |
You can test the configuration by running D:SoftwareAGTerracottawrapperbatrunConsole.bat
In that case the wrapper will load the configuration file and start the process. This can be used to debug the wrapper configuration file. Afterwards the service can be installed using the D:SoftwareAGTerracottawrapperbatinstallService.bat
command.
For both wrappers you can define the wrapper on exit behavior. By setting wrapper.on_exit.0=SHUTDOWN
the wrapper will do nothing when it gets a normal return code 0 from terracotta. For all other return codes the wrapper will automatically restart the terracotta service. We do this by setting wrapper.on_exit.default=RESTART
.
We need this option in an active-mirror terracotta setup. If we shut down the passive node and restart it, we will get the following error in the terracotta server log:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
ERROR com.tc.l2.ha.ClusterState – ********************************** ERROR *********************************** * This server is running with persistence turned on and was stopped in * PASSIVE-STANDBY state. Only the ACTIVE-COORDINATOR server is allowed to * be restarted without cleaning up the data directory with persistence * turned on. * * Please clean up the data directory and make sure that the * ACTIVE-COORDINATOR is up and running before starting this server. It is * important that the ACTIVE-COORDINATOR is up and running before starting * this server else you might end up losing data **************************************************************************** [WrapperStartStopAppMain] ERROR tc.operator.event – NODE : Server2 Subsystem: CLUSTER_TOPOLOGY Message: Started with dirty database. Exiting!! Restart enabled [WrapperStartStopAppMain] ERROR com.terracottatech.dso – Marking the object db as dirty … [WrapperStartStopAppMain] ERROR com.terracottatech.console – This standby Terracotta server instance had to restart to automatically wipe its database and rejoin the cluster. |
Terracotta will stop with a return code different than 0. By using the on exit options, the wrapper automatically restarts the service.