> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sync.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cluster Installation and Configuration

export const companyNameLower = "cdata";

export const siteNameShortLower = "sync";

export const siteNameShort = "Sync";

export const siteName = "CData Sync";

<Note>This page has content that is only applicable to {siteNameShort} Self-Hosted deployments. {siteNameShort} Cloud has clustering already enabled.</Note>

*Clustering* enables multiple {siteName} installations to work together and process the same jobs with the same configurations. Workloads are distributed horizontally across clustered {siteNameShort} installations to improve scalability and ensure availability.

<Note>{siteNameShort} evenly distributes scheduled jobs. Your jobs are run either through the **Admin** console or the REST API, depending on which instance of {siteNameShort} you are connected to at the time.</Note>

## Understanding Clustering

To take advantage of the failover features that are supported in {siteNameShort}, you should install the application on multiple systems within the same server farm (the same cluster). When they are configured for clustering, **each {siteNameShort} installation in the server farm uses the same application configuration and distributes job executions between each server**.

As a result, multiple instances of the application behave like a single instance, and any particular instance can fail without jeopardizing the performance of the cluster.

The overall steps to set clustering are as follows:

1. Set the [application directory](#configuring-the-application-directory).
2. Set the [application database](#configuring-the-application-database).
3. Set the **Enable Cluster mode** option to **True** in {siteNameShort} (**Settings > Advanced**).
4. Restart {siteNameShort}.

## Configuring {siteName} for Clustering

After you install {siteNameShort} on each node within a cluster, you need to configure your **application directory** and **application database**. Then, you need to configure each installation to use the same application directory and application database.

<Note>For jobs to be distributed across nodes properly, ensure that all nodes are in the same time zone and synchronize the node clock at least to second-level precision.</Note>

### Configuring the Application Directory

{siteNameShort} stores all configuration data and application data in a directory (folder) on the disk. When you use clustering, you should configure each instance of {siteNameShort} to use the same application directory. This configuration ensures that all instances of the application process the same files and use the same configuration.

To configure the application directory:

1. Set up your application directory as follows, dependent on which server you use.

   **Cross-Platform Edition with the Embedded Jetty Server:**

   1. Open the sync.properties file that resides in *`InstallationDirectory`*. For details about how to generate this file, see [Generating the sync.properties File](./configuring-the-server#generating-the-sync-properties-file).
   2. Set the `AppDirectory` environment variable to the directory path that you want to use, as shown in this example:

      ```bash theme={null}
      cdata.app.directory=/mnt/shared/sync
      ```

      If {siteNameShort} can locate the path and it has the appropriate permissions to read and write at that location, it creates the data folder within the specified directory.

   **Cross-Platform Edition with an External Server:**

   When you use the Cross-Platform Edition with an external servlet, the configuration of the application directory depends on the specific servlet that you use. Use the syntax that is appropriate for the specific servlet and set the `AppDirectory` environment variable to the directory path that you want.

   If {siteNameShort} can locate the path and it has the appropriate permissions to read and write at that location, it creates the data folder within the specified directory.

2. Configure each {siteNameShort} installation to use the same application directory.

### Configuring the Application Database

{siteNameShort} uses a database to store the application data (jobs, connections, and so on) and logging information. You should configure each instance of {siteNameShort} to use the same application database. Doing so ensures that each instance can access all the job information.

To configure the application data directory:

1. Set up your application database as follows, dependent on which server you use.

   **Cross-Platform Edition with the Embedded Jetty Server:**

   1. Open the sync.properties file that resides in *`InstallationDirectory`*. For details about how to generate this file, see [Generating the sync.properties File](./configuring-the-server#generating-the-sync-properties-file).
   2. Set the `APP_DB` environment variable to a Java Database Connectivity (JDBC) connection string that contains the appropriate connection parameters for the database that you want to use, as shown in the following examples:

      **MySQL**

      ```
      cdata.app.db=jdbc:cdata:mysql:server=localhost;port=3306;database=mysql;user=MyUserName;password=MyPassword;useconnectionpooling=true
      ```

      **PostgreSQL**

      ```
      cdata.app.db=jdbc:cdata:postgresql:server=localhost;port=5432;database=postgresql;user=MyUserName;password=MyPassword;useconnectionpooling=true
      ```

      **SQL Server**

      ```
      cdata.app.db=jdbc:cdata:sql:server=localhost;database=sqlserver;user=MyUserName;password=MyPassword;useconnectionpooling=true
      ```

      If {siteNameShort} can establish a connection successfully with the `cdata.app.db` connection string, it uses that database as the application database.

   **Cross-Platform Edition with an External Server:**

   When you use the Cross-Platform Edition with an external servlet, the configuration of the application database depends on the specific servlet that you use. Use the syntax that is appropriate for the specific servlet and choose one of the following approaches to configure the server:

   * Define a Java Naming and Directory Interface (JNDI) data source to include the connection properties for the target database.
   * Set the `APP_DB` environment variable to a JDBC connection string.

   If {siteNameShort} can use the JNDI data source or the `APP_DB` connection string to connect to a database, it uses that database as the application database.

2. Configure each {siteNameShort} installation to use the same application database.
