License

How to build

Sample configuration for two Gerrit masters in high-availability

Assuming that the Gerrit masters in the clusters are gerrit-01.mycompany.com and gerrit-02.mycompany.com, listening on the HTTP port 8080, with a shared volume mounted under /shared, see below the minimal configuration steps.

Install one Gerrit master on the first node (e.g. gerrit-01.mycompany.com) using an external ReviewDb on a DB server and the repositories location under the shared volume (e.g. /shared/git). Init the site in order to create the DB Schema and the initial repositories.

Copy all the files of the first Gerrit master onto the second node (e.g. gerrit-02.mycompany.com) so that it points to the same ReviewDb and the same repositories location.

Install the high-availability plugin into the $GERRIT_SITE/plugins directory of both the Gerrit servers.

On gerrit-01.mycompany.com, create the $GERRIT_SITE/etc/high-availability.config with the following settings:

Active-active configuration

This is an evolution of the previous active-passive configuration, where only one Gerrit master at a time serves the HTTP write operations (PUT,POST,DELETE) while the remaining HTTP traffic is sent to both. In case of failure of one of the nodes, all the traffic is forwarded to the other node.

With regards to the SSH traffic, it cannot be safely sent to both nodes because it is associated with a stateful session that can host multiple commands of different nature.

Assuming an active-passive configuration using HAProxy, see below the changes needed to implement an active-active scenario.

Add to the haproxy.cfg the extra acl settings into the gerrit_http frontend configurations associated with the HTTP and SSH services:

Gerrit canonical URL and further adjustments

Both Gerrit masters are now part of the same cluster, accessible through the HAProxy load-balancer. Set the gerrit.canoncalWebUrl on both Gerrit masters to the domain name of HAProxy so that any location or URL generated by Gerrit would direct the traffic to the balancer and not to the instance that served the incoming call.

Example:

[gerrit]
canonicalWebUrl = http://gerrit.mycompany.com

Secondly, adjust the HTTP listen configuration adding the proxy- prefix, to inform Gerrit that the traffic is getting filtered through a reverse proxy.

Example:

[httpd]
listenUrl = proxy-http://*:8080/

Last adjustment is associated with the session cookies, because they would need to be bound to the domain rather than the individual node.