BigMemory 4.3.10 | Product Documentation | BigMemory Max Administrator Guide | Configuring the Terracotta Server Array | Configuration in a Development Environment
 
Configuration in a Development Environment
In a development environment, using a different configuration file for each Terracotta client facilitates the testing and tuning of configuration options. This is an efficient and effective way to gain valuable insight on best practices for clustering your application with Terracotta.
One-Server Setup in Development
For one Terracotta server, the default configuration is adequate.
To use the default configuration settings, start your Terracotta server using the start-tc-server.sh (or start-tc-server.bat) script in a directory that does not contain the file tc-config.xml :
[PROMPT] ${TERRACOTTA_HOME}\bin\start-tc-server.sh
To specify a configuration file, use one of the approaches discussed in How Terracotta Servers Get Configured.
Two-Server Setup in Development
A two-server setup, sometimes referred to as an active-mirror setup, has one active server instance and one "hot standby" (the mirror) that should load the same configuration file.
The configuration file loaded by the Terracotta servers must define each server separately using <server> elements. For example:
<tc:tc-config xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-9.xsd"
xmlns:tc="http://www.terracotta.org/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<!-- Use an IP address or a resolvable host name for the host attribute. -->
<server host="123.456.7.890" name="Server1">
...
<server host="myResolvableHostName" name="Server2">
...
</tc:tc-config>
Assuming Server1 is the active server, using the same configuration allows Server2 to be the mirror and maintain the environment in case of failover. When running both servers on the same host, the <tsa-port> for each server should be different. The other ports are automatically generated from the <tsa-port>. Having a separate log location is a good idea, but failing to do so will not prevent the servers from starting. If the servers are set up to be restartable, setting the data directory to a different location would be a requirement.
Server Names for Startup
With multiple <server> elements, the name attribute may be required to avoid ambiguity when starting a server:
start-tc-server.sh -n Server1 -f <path_to_configuration_file>
In Microsoft Windows, use start-tc-server.bat.
For example, if you are running Terracotta server instances on the same host, you must specify the name attribute to set an unambiguous target for the script.
However, if you are starting Terracotta server instances in an unambiguous setup, specifying the server name is optional. For example, if the Terracotta configuration file specifies different IP addresses for each server, the script assumes that the server with the IP address corresponding to the local IP address is the target.
Clients in Development
You can explicitly specify a client's Terracotta configuration file by passing -Dtc.config=path/to/my-tc-config.xml when you start your application with the Terracotta client.
-Dtc.config=path/to/my-tc-config.xml -cp classes myApp.class.Main
where myApp.class.Main is the class used to launch the application you want to cluster with Terracotta.
If tc-config.xml exists in the directory in which you run Java, it can be loaded without -Dtc.config.