Wednesday 26 August 2015

GitBlit Master Slave Replication Setup


Step 1#
#In Master GIT Server[Master URL
http://git.example.net:1337]


vim /opt/gitblit/data/gitblit.properties
# Modify or Add lines as below

git.enableGitServlet = true

web.showFederationRegistrations = true

federation.passphrase = p@$$w0rd [We can set anything here]

:wq!

#ps aux | grep java
#service gitblit stop
#ps aux | grep java
#service gitblit start

Step 2#
Login to http://git.example.net:1337
Click on Admin Profile-->federation-->Copy the federation tokens for "all repositories, users, & settings"

(Example: Here token is c12b82e1b5e0ba6baec48119468aa09595663164)

Step 3#
#Install Fresh GitBlit Server

#Go to Slave GIT Server

vim /opt/gitblit/data/gitblit.properties
#Modify Or Add lines as below

federation.allowProposals=true
federation.
example1.url = http://git.example.net:1337
federation.
example1.token = c12b82e1b5e0ba6baec48119468aa09595663164 [Paste the token copied from Master GIT]
federation.
example.frequency = 5 mins [Replication frequency between Master and Backup Slave]
federation.
example.folder =
federation.
example.bare = true
federation.
example.mirror = true
federation.
example.mergeAccounts = true
#ps aux | grep java
#service gitblit stop
#ps aux | grep java
#service gitblit start

Step 4#
#Monitor the log file in both the Master & Slave Servers

tail -f /opt/gitblit/data/logs/gitblit.log

Successful Logs Example:
Master:
[INFO ] ARF: lendingstream.git/info/refs?service=git-upload-pack (100) authenticated [Here lendingstream.git Repo name, like wise will get for all Repo]
[INFO ] Federation PULL_USERS request from SLAVE_IP
[INFO ] Federation PULL_TEAMS request from SLAVE_IP
[INFO ] Federation PULL_SETTINGS request from SLAVE_IP
[INFO ] Federation PULL_SCRIPTS request from SLAVE_IP

Slave:
[INFO ] Pulling federated repository lendingstream.git from
example1 @ http://git.example.net:1337
[INFO ] Next pull of
example1 @ http://git.example.net:1337 scheduled for DATE_TIME
Step 5#
#How to Check Slave is working fine.
1. Login to Slave's GIT Dashboard by admin and check the Repo's & Users are synched or not
2. Clone any repository to Local using any Master's username & password from Slave's URL.

5 comments: