### Setting up and configuring a JReport Server Cluster

Before setting up a JReport Server Cluster, first you need to make the time difference between the target computers that will join the cluster as small as possible (the time difference between the target computers should be within one minute), and make sure all servers in the cluster will be set up on the same architecture and operating system.

A JReport Server Cluster can be set up either during the JReport Server installation or after the servers have been installed using the appropriate license key for cluster.

#### Creating a JReport Server Cluster during installation

It is recommended that you create a JReport Server Cluster during the installation of servers. This is the easiest way for you to set up a cluster.

To create a JReport Server Cluster during installation:

1. Run the JReport Server installation file to install JReport Server with the Installation Wizard.
2. Specifies your User ID. In the License Key text field, use the cluster enabled license key.
3. When choosing the installation type, choose Custom Installation for Standalone Server. Then specify the installation directory for JReport Server.
4. In the Service tab of the Configure System Environment screen, check the Network Address At option and type in the IP address of the server.
5. In the Cluster tab, specify a cluster name in the Cluster Name text field. You can either make the server join an existing cluster or specify a new cluster name to build another cluster.
6. Uncheck the Disable Cluster option.
7. From the Load Balancer Type drop-down list, select the algorithm for load balancing clustered servers.
8. Check the Cluster Scheduler Lease option to enable lease for the cluster, then set the active count, valid time and check interval for the cluster scheduler lease. If you don't enable the lease option, all clustered servers in the cluster will compete for a chance to trigger scheduled tasks which could lower overall system throughput. Read main features for additional information.
9. Specify values for Cluster Storage History Number of Copies, Cluster Storage Realm Number of Copies and Cluster Storage CRD Result Number of Copies. If you are using shared disk resources for any of these directories you should set the value to 1. The default value is 2 which means make one copy plus the original. This allows any one node to go down and the system will still be able to find all resources. If you want to allow 2 simultaneous failures, set the number of copies to 3.
10. Specify the value for Cluster Memory Storage Number of Copies to set how many memory copies will be shared in the cluster.
11. Check Notify via E-mail When a Server Is Down if you need to notify somebody via e-mail when a server in the cluster is down, then in the E-mail Address text field, input the e-mail addresses of the people to whom you want to send a notification e-mail.
12. Set the Properties, Realm, Resource, History, and Temporary Directories if necessary. If they are not specified, default directories will be used.
13. Type the IP address or host name of the server in the Server's RMI Host text field, and type the port number in the Server's RMI Port text field.
14. Go on with the installation steps to complete the installation.
15. Install another server you want to join the cluster and repeat the above steps to configure its cluster settings.

    Since JReport Cluster uses the same server DBMS, you need to make the system database in the JDBC URL text field point to the same DBMS as the previous server. This requires that you replace localhost with the IP address of the first cluster node that you installed, for example, `jdbc:derby://IP:1527/`.

#### Creating a JReport Server Cluster after installation

After the servers have been installed using the appropriate license key for cluster, you can configure the clustered servers either by using the JReport Administration page or the server.properties and dbconfig.xml files.

##### Using the JReport Administration page

1. Start up the server that hasn't been enabled for cluster.
2. Log onto the JReport Administration page, and click Cluster > Configuration on the system toolbar to show the panel.
3. In the Cluster Name text field, specify a name for the cluster. You can either make the server join an existing cluster or specify a new cluster name to build another cluster.
4. Check the Enable Cluster option.
5. Click Save to enable the cluster.
6. A cluster member ID will be generated automatically for the server. But if you need to modify it, go to server.properties file located in `<install_root>\bin` and set the property cluster.member.id.
7. Go to the JReport Administration > Data page, configure the databases to make sure they point to the database that the server will use. For details, see Configuring the server database.
8. Restart the server you have enabled with cluster, then log onto the JReport Administration page, go to the Cluster > Configuration panel. See the panel.

9. From the Load Balancer Type drop-down list, select the algorithm for load balancing clustered servers.
10. To enable lease for the cluster, check the Cluster Scheduler Lease option and set the active count, valid time and check interval of the cluster scheduler lease respectively.
11. Specify values for Cluster Storage History Number of Copies, Cluster Storage Realm Number of Copies, Cluster Storage CRD Result Number of Copies and Cluster Memory Storage Number of Copies.
12. Check Notify via E-mail When a Server Is Down if you need to notify somebody via e-mail when a server in the cluster is down, then in the E-mail Address text field, input the e-mail addresses of the people to whom you want to send a notification e-mail.
13. Set the Properties, Realm, Resource, History, and Temporary Directories if necessary. If they are not specified, default directories will be used.
14. In the Server's RMI Host text field, type the RMI IP address or host name of the clustered server.
15. In the Server's RMI Port text field, type the RMI port number of the clustered server.
16. Shut down the server.
17. Start up another server you want to join the cluster and repeat the above steps to configure its cluster settings.

See also Cluster dialog for details about the cluster configuration options.

##### Using the server.properties and dbconfig.xml files

To set up a JReport Server Cluster using the server.properties and dbconfig.xml files, you need to modify the server.properties file on each JReport Server. The process uses the following procedures:

1. In the server.properties file located in `<install_root>\bin` of each server, set the property cluster.enabled=true.
2. Modify cluster.name in any server's server.properties file to specify the cluster name. If not specified, it will take jreport-cluster as the default name.
3. In the server.properties file of each clustered server, modify the properties file as follows:
   - cluster.member.id=(integer)
     Specifies the member ID of the local server. The value of this property should be an integer no less than 1.
   - server.rmi.host=localhost IP address
     Specifies the RMI IP address or host name of the local server.
   - server.rmi.port=1129
     Specifies the RMI port number of the local server.
4. Specify the paths of the directories on the physical disk, such as properties directory, realm directory, resource root, history directory, and temporary files directory. The directories on each clustered server should point to a different physical disk.

   Add the following properties to the server.properties file:

   - resource.share.temp.dir=
     Specifies the directories for storing temporary files.
   - resource.share.hist.dir=
     Specifies the directories for storing all versions of report results in the cluster.
   - resource.share.realm.dir=
     Specifies the directories of the realm files.
   - resource.share.properties.dir=
     Specifies the directories of the properties files.
   - resource.root=
     Specifies the directories of the JReport demo reports.
5. Modify dbconfig.xml in each server's `<install_root>\bin`, and make sure that the system database and realm database all server nodes use point to the same DBMS. For details, see Configuring the server database.

Notes:

- The databases that can be used as the server database in a JReport cluster must be able to support the lock function, therefore, you cannot use HSQLDB as the server's database in a JReport cluster because HSQLDB doesn't support the function.
- If you have upgraded your JReport Server which is cluster enabled and uses HSQLDB as the server database from versions prior to V9 to the current version, in order to make the server work normally, you need to disable cluster on the server by adding the line server.cluster.enable=false to the server.properties file.
- If you set up a JReport cluster on one computer, you need to make sure that the settings of HTTP Port, Administration Port, and Server's RMI Port on each cluster node be different from those on any other nodes.
- It is strongly recommended that you do not change the auto generated cluster member ID in a JReport cluster, because distributed storage uses the member ID to recognize on which node the physical files are stored.
- If you want to use resources from folder real paths in JReport cluster, you should first specify a disk in your file system and make sure that every node in the cluster has the same disk name mapping to the same physical location.
- Properties such as cluster.name, cluster.member.id, resource.share.properties.dir, resource.share.realm.dir, resource.root, resource.share.hist.dir, resource.share.temp.dir, server.rmi.host, server.rmi.port, cluster.enable, log.config.filename, log.config.update, and log.config.update.interval that created in the server.properties file and their corresponding UI options on the JReport Administration page need to be configured respectively for each cluster node. However, properties that are now saved in the database should be configured for all the server nodes in the cluster. These properties are:
  - The following properties listed before in the server.properties file: cluster.enable_notify_server_down, cluster.notify_server_down_address, cluster.scheduler.lease.active_count, cluster.scheduler.lease.check_interval, cluster.scheduler.lease.enabled, cluster.scheduler.lease.valid_time, cluster.share_memory.node_number, cluster.storage.crd_result.copy_number, cluster.storage.history.copy_number, cluster.storage.realm.copy_number, loadbalance.custom_class, loadbalance.type, server.autocache.enabled, server.autocache.expired.time, server.autocache.max.disk.usage, server.autocache.never.expire, server.completed.max_count, server.crd.memory.usage, server.realm.active, server.security, server.version.from.temp.
  - All properties in the mailconfig.properties file in `<install_root>\bin`.
  - All properties in the clusterWeight.properties file in the system database.
  - All properties in the LDAP configuration XML file LDAPProperties.xml in `<install_root>\properties.`
- No sub folders should be created under the realm directory because it may create a realm when server is started.
- To use the old result files in `<reporthome>\history`, install the new JReport Server to the same directory with a new license key, overriding the existing program files.
- In order to fax report result successfully in a cluster, you need to configure the fax settings for each clustered server respectively.
- If the content of the resource root directory jreports is removed, the Public Reports folder in the resource tree will be empty.