Build git backup servers with gitolite-3.6

Source: Internet
Author: User

Requirements:

Build a git server on the Internet. You can submit and clone a git server wherever you are connected. If a repository is too large, it will take too long to clone a repository from the company, bandwidth usage and other adverse factors, we can build an image server in the company's intranet. When cloning code, we can clone the image server, which saves a lot of time. Let's start.

I built with reference to gitolite official documentation: http://gitolite.com/gitolite/mirroring.html


Environment:

A total of three machines, one git master server on the Internet (hereinafter referred to as servser1), one git backup server on the company's Intranet (hereinafter referred to as server2), and the other client (hereinafter referred to as client ), rhel6.5 is used in this experiment environment.

Server1 IP: 192.168.1.172

Server2 IP: 192.168.1.165

Client IP: 192.168.1.180


Add the following content to the hosts file of the three machines:

192.168.1.172 server1.example.com192.168.1.165 server2.example.com


Install git on server1 and server2 and create a git account

#yum -y install git perl-Time-HiRes #useradd git#su - git


Generate key on client, server1, and server2

#ssh-keygen


On the client side to server1, server2, and renamed Admin. Pub, and download server1 pubkey and named as server-server1.pub (The pubkey of the server must start with server-)

#scp .ssh/id_rsa.pub server1.example.com:/tmp/admin#scp .ssh/id_rsa.pub server2.example.com:/tmp/admin#scp server1.example.com:/home/git/.ssh/id_rsa.pub /tmp/server-server1.pub


Create a config file on Server 1 and Server 2, and set the File Permission to 644.

Server1 Configuration:

# Vim. Ssh/config ### Add the following content ### host server2user githostname server2.example. comidentityfile ~ /. Ssh/id_rsa ### save and exit ### chmod 644. Ssh/config

Server2 Configuration:

# Vim. Ssh/config #### Add the following content: Host server1user githostname server1.example. comidentityfile ~ /. Ssh/id_rsa ### save and exit ### chmod 644. Ssh/config


Download and install gitolite on Server 1 and Server 2

#git clone git://github.com/sitaramc/gitolite#mkdir ~/bin#gitolite/bin/install -to /home/git/bin#gitolite setup -pk /tmp/admin.pub


At this point, we can clone the gitolite-Admin repository on the client side.

Create the server1 and server2 directories to identify which server's gitolite-Admin Repository

# Mkdir server1 # cd server1 # git clione [email protected]: gitolite-Admin # cd gitolite-Admin # cp/tmp/server-server1.pub keydir/# Vim CONF/gitolite. conf ### add server-server1 to gitolite-Admin warehouse read and write permissions ### repo gitolite-Admin RW + = admin server-server1repo testing RW + = @ All ### save and exit ### # git add. & git commit-M "Update gitolite. conf, add server key "& git push

Create the server2 directory. Repeat the preceding steps.


Run the following command on server1 to display the 'hello server-server1, this is [email protected] running' message takes effect

#ssh server2 info


Modify the gitolite. conf file of the server1 and server2 Repositories on the client, add the following content, and submit

repo gitolite-admin    RW+     =   admin server-server1    option mirror.master = server1    option mirror.slaves = server2    option mirror.redirectOK = allrepo testing    RW+     =   @all    option mirror.master = server1    option mirror.slaves = server2    option mirror.redirectOK = all        #git add . && git commit -m "update gitolite.conf" && git push


Modify the. gitolite. RC file in the git home directory on the server1 side (three modifications in total)

# Vim. gitolite. RC ### cancel the annotation and change the hostname to server1 ### hostname => "server1", ### cancel the annotation ### 'mirerror', 'ignoring ',

Modify the. gitolite. RC file in the git home directory on server2 (three modifications in total)

# Vim. gitolite. RC ### cancel the annotation and change the hostname to server1 ### hostname => "server2", ### cancel the annotation ### 'mirerror', 'ignoring ',

Now the backup storage has been set up. Let's test whether synchronization can be performed.


Clone the test warehouse of the master server in the Client Server 1 directory, and create a file and submit it to check whether the file will be synchronized to the backup storage.

#git clone [email protected]:testing#cd testing/#touch test.txt#git add . && git commit -m "add file" && git push origin master


Clone the testing repository of the backup storage in the client server2 directory.

#git clone [email protected]:testing#ls testing

The test.txt file is found in the testingdirectory, which indicates that the backup storage is successfully built.



If all the repositories have images, you only need to add the following content.

repo @all    option mirror.master = server1    option mirror.slaves = server2    option mirror.redirectOK = all




This article is from the "Linux" blog, please be sure to keep this source http://crazyjjx.blog.51cto.com/2746212/1558131

Build git backup servers with gitolite-3.6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.