Run Synchrony-standalone as a service on Linux
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
This guide applies to Confluence Data Center 6.5 and later. See Run Synchrony-standalone as a service on Linux for Confluence 6.4 and earlier if you're using an earlier version of Data Center. This guide does not apply if Synchrony is managed by Confluence.
Purpose
This article will guide you through how to run Synchrony as a service on a standalone node or cluster in Linux, for use with Confluence Data Center 6.5 or later.
Prerequisites
You should already have one Confluence Data Center node set up (see Installing Confluence Data Center), and are working through the steps to Set up a Synchrony cluster.
We also assume you already have the latest Oracle Java version installed.
How to check
You must be using Oracle Java (not OpenJDK). To check your current java version:
which java
java -version
If it's not already installed, either download it from Oracle and copy to the machine, or use the package manager like so:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Once installed, run the java -version
command again to confirm your version.
Solution
How to run Synchrony as a service on a standalone node
In Linux, the best practice is to install, configure and run each service (including Synchrony) as a dedicated user with only the permissions they require.
To run Synchrony automatically on Linux, follow the steps below. These steps are for Ubuntu 16, so you may need to adjust the syntax of these commands if you're using RHEL or another Linux distribution.
Create a
synchrony
user to run Synchrony, using the following command running as root (not using sudo):addgroup --gid 1234 synchrony && useradd -m -s /bin/bash -u 1234 -g 1234 synchrony;
Set a password for your synchrony user:
sudo passwd synchrony
Create your Synchrony home directory. This is where we'll run Synchrony from, and write logs to.
sudo mkdir -p /opt/atlassian/synchrony
Copy the following files and directories from your Confluence node to your Synchrony home directory:
<local-home>/synchrony-standalone.jar
<install-directory>/bin/synchrony
- your database driver from
<install-directory>/confluence/WEB-INF/lib
(for examplepostgresql-9.4.1212.jar
) - for convienience you may also want to copy over your
<local-home>/confluence.cfg.xml
file, as this contains some of the details you'll need to enter later.
Your Synchrony home directory should now contain the following files:
synchrony-standalone.jar
start-synchrony.sh
stop-synchrony.sh
install_synchrony_service.sh
- your database driver, for example
postgresql-9.4.1212.jar
Give your
synchrony
user proper permissions on the directory and files:sudo chown -R synchrony:synchrony /opt/atlassian/synchrony
Open
start-synchrony.sh
in your favourite text editor and enter details for your environment. See Configuring Synchrony for details of each parameter.
We recommend you use an environment variable for your database password. To do this, change to the
synchrony
user, create a file, for examplesynchronyenv
and make it executable as follows:sudo su - synchrony touch synchronyenv chmod a+x synchronyenv
Edit the file to add the environment variables for your database username and password as follows:
export SYNCHRONY_DATABASE_USERNAME="your username" export SYNCHRONY_DATABASE_PASSWORD="your password"
In your
start-synchrony.sh
script, uncomment the environment variables section, and provide the path to your environment file.SYNCHRONY_ENV_FILE="<PATH_TO_ENV_FILE>"
As your Synchrony user, run the
install_synchrony_service.sh
file to install the service:sudo ./install_synchrony_service.sh
To start, stop or restart the service, use:
service synchrony start service synchrony stop service synchrony restart
To confirm the synchrony service is running use:
service synchrony status
You're now ready to start Confluence and check it can connect to Synchrony. Continue with the installation instructions in Installing Confluence Data Center.
Synchrony logs not updated when running as a service
If you setup Synchrony standalone to run as a Linux service and the application log (atlassian-synchrony.log
) is either missing or not being updated, then check the following procedure.
Edit the Synchrony service definition and add the following configuration under the
[Service]
structure.WorkingDirectory=<path to Synchrony home>
- Reload the Synchrony service configuration.
- Restart the Synchrony service.
Running Synchrony using start and stop scripts
If you're using Confluence 6.5 or later, we provide scripts to help you start and stop Synchrony. See Configuring Synchrony to find out how to configure these scripts for your environment.
If you're using an earlier Confluence version, you can create your own start and stop scripts - see Run Synchrony-standalone as a service on Linux for Confluence 6.4 and earlier.