{{tag>atlassian jira}} ====== Install 2 node Jira Datacenter in Docker behind apache reverse proxy ====== This assumes you already have a mysql container running with a created database for jira on the same docker network, for example at ip 172.20.20.2. If not [[https://hub.docker.com/_/mysql|create that container]] and the [[https://docs.docker.com/engine/reference/commandline/network_connect/#network-implications-of-stopping-pausing-or-restarting-containers|docker network.]] ===== Install first node ===== docker run --network=atl --ip=172.20.20.5 -e JVM_SUPPORT_RECOMMENDED_ARGS=-DjvmRoute=node1 -e CLUSTERED=true -e JIRA_NODE_ID=node1 -e ATL_PROXY_NAME=jiratestdc.example.com -e ATL_PROXY_PORT=443 -e ATL_TOMCAT_SCHEME=https -v jiradc1:/var/atlassian/application-data/jira -v jiradcshared:/var/atlassian/application-data/jira/shared/ --name="jiradc1" -d -p 8585:8080 atlassian/jira-software Explanation: ''-e JVM_SUPPORT_RECOMMENDED_ARGS=-DjvmRoute=node1'' This is required so that JVM is aware of the node used. Replace "node1" with whatever is set as ''BalancerMember'' in load balancer configuration. ''-e JIRA_NODE_ID=node1'' This sets the node name in jira home directory cluster.properties file. Should be same as in LB. ''-v jiradcshared:/var/atlassian/application-data/jira/shared/'' In addition to volume for jira home we need a shared folder that will be used by the nodes. Don't forget to copy [[https://dev.mysql.com/downloads/connector/j/ | mysql connector]] and restart the container docker cp mysql-connector-java-8.0.20.jar jiradc1:/opt/atlassian/jira/lib/ docker restart jiradc1 ===== Add node to load balancer ===== Enable the required modules: a2enmod proxy a2enmod lbmethod_byrequests Edit vhost file to match this: ProxyRequests off ServerName jiratestdc.example.com ServerAdmin webmaster@localhost # JIRA node 1 BalancerMember http://localhost:8585 route=node1 # JIRA node 2 BalancerMember http://localhost:8686 route=node2 # Security "we aren't blocking anyone but this the place to make those changes Order Deny,Allow Deny from none Allow from all # Load Balancer Settings ProxySet lbmethod=byrequests ProxySet stickysession=JSESSIONID # Here's how to enable the load balancer's management UI if desired SetHandler balancer-manager # You SHOULD CHANGE THIS to only allow trusted ips to use the manager Order deny,allow Deny from all #Allow from all Allow from # Don't reverse-proxy requests to the management UI ProxyPass /balancer-manager ! # Reverse proxy all other requests to the JIRA cluster ProxyPass / balancer://jiracluster/ ProxyPreserveHost on SSLProxyEngine On ErrorLog ${APACHE_LOG_DIR}/jiratestdc-error.log CustomLog ${APACHE_LOG_DIR}/jiratestdc-access.log combined # SSL rewrite RewriteEngine on RewriteCond %{SERVER_NAME} =jiratestdc.example.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] The same configuration should be in ssl vhost configuration as well. Reload apache2 and run through the setup of the node. ===== Add a new Jira node to the cluster ===== Copy the Jira installation directory to a new host. This is easily done by making a docker image from the first node. docker commit CONTAINER ID jiradc We will use jiradc to spin up a new node. Create new container docker run --network=atl --ip=172.20.20.6 -e JVM_SUPPORT_RECOMMENDED_ARGS=-DjvmRoute=node2 -e ATL_PROXY_NAME=jiratestdc.example.com -e ATL_PROXY_PORT=443 -e ATL_TOMCAT_SCHEME=https -v jiradc2:/var/atlassian/application-data/jira -v jiradcshared:/var/atlassian/application-data/jira/shared/ --name="jiradc2" -d -p 8686:8080 jiradc Copy home data from node1 and change permissions: cp -R atlassian-jira.log caches cluster.properties customisations customisations-backup dbconfig.xml .java .jira-home.lock log monitor plugins __pycache__ tmp ../../jiradc2/_data/ chown -R 2001:2001 ../../jiradc2/_data/ Change the cluster.properties line to ''jira.node.id=node2'' for the second node and restart second docker node. ===== Test ===== Go to the configured url and hit refresh couple of times. You should see the node names change on bottom of page {{:wiki:node1jira.png|}} {{:wiki:node2jira.png|}} Once you're logged in, the Session cookie JSESSIONID will be set (Developer console > Storage) with the name of the node e.g. ''JSESSIONID:"F24EF7DBDB6AF41DD6930A0CA947E4CF.node2"'' ====== Tested on ====== * Atlassian Jira Project Management Software (v8.8.1#808001) * Docker 18.09.1 * Debian 10.8 ====== See also ====== * [[wiki:installing_confluence_server_in_docker_behind_reverse_proxy|Installing Confluence server in Docker behind reverse proxy]] * [[wiki:docker_commands|Docker commands]] * [[wiki:dockerized_jenkins_install_docker_via_ansible_dind|Dockerized jenkins install with docker in docker via ansible (dind)]] ====== References ====== * https://confluence.atlassian.com/adminjiraserver071/installing-jira-data-center-802592197.html * https://confluence.atlassian.com/jirakb/how-to-determine-which-node-a-user-is-accessing-in-datacenter-885252555.html * https://confluence.atlassian.com/enterprise/jira-data-center-load-balancer-examples-781200827.html * https://hub.docker.com/r/atlassian/jira-software