Skip to content
Elias Ojala edited this page Jan 9, 2019 · 4 revisions

Quick Start

Setup you local repository

Before we start you'll need a full copy of the repository you want to distribute. Its content must be identical to the one that will be available on the mirrors.

Note: If your server is also the master repository then you probably don't need to do this and can skip this step.

Assuming you're using rsync let's grab a copy and put it on /srv/repo:

$ mkdir -p /srv/repo
$ rsync --verbose --recursive --times --links --hard-links --perms --stats --delete-after
        --timeout=300 rsync://rsync.example.org/some-folder /srv/repo

Great! Now it must be kept in sync regularly with the master. Add the following line to your /etc/crontab to sync the repository every hour at xx:31 minutes.

31 * * * * rsync --verbose --recursive --times --links --hard-links --perms --stats
--delete-after --timeout=300 rsync://rsync.example.org/some-folder /srv/repo

Installing mirrorbits

Mirrorbits is not yet packaged into Linux distributions so you'll have to build it manually but don't worry it's quite simple.

You'll need to install few packages before we begin:

Debian/Ubuntu:

$ sudo add-apt-repository ppa:gophers/archive
$ sudo apt-get update
$ sudo apt-get install golang-1.10-go redis-server geoipupdate govendor protobuf-compiler
$ systemctl start redis-server

Archlinux:

$ pacman -S go redis geoip2-database
$ systemctl start redis

It's time to download and build mirrorbits!

$ mkdir ~/go && cd ~/go
$ export GOPATH=`pwd`
$ go get github.com/etix/mirrorbits
$ cd $GOPATH/src/github.com/etix/mirrorbits
$ sudo make install PREFIX=/usr

If the last command failed, consider adding Defaults env_keep += "GOPATH" to your /etc/sudoers.

Configure

Open /etc/mirrorbits.conf with your favorite text editor and be sure that the line Repository points to the root of your repository, following the above example: "/srv/repo".

Run

We're almost ready! Now let's start mirrorbits.

$ mirrorbits daemon

During its first start mirrorbits will index all the files within the repository, this can take from few seconds to several minutes depending on the size of the repo.

Adding your first mirror

Adding a mirror is a very simple operation, the command mirrorbits add will show you all possible options. A typical command line should look like this:

$ mirrorbits add -http http://mirror1.example.org -rsync rsync://mirror1.example.org mirror1

If the command is successful, we can now scan and enable the mirror:

$ mirrorbits scan -enable mirror1

You should now be able to access the mirrorlist, open your web browser and point it to

http://yourserver.com:8080/path/to/file?mirrorlist

If everything is setup correctly you should now see a web page similar to this one.

Finally remove the final ?mirrorlist to be redirected to the closest mirror. Yay! :)