Difference between revisions of "Mirror"

From CSCWiki
Jump to navigation Jump to search
m ("it's usage" -> "its usage")
(add temporary update message for merlin-go)
 
(32 intermediate revisions by 6 users not shown)
Line 1: Line 1:
We currently run a public mirror ([http://mirror.csclub.uwaterloo.ca/ mirror.csclub.uwaterloo.ca]) on [[Machine_List#sodium-benzoate|sodium-benzoate]]. We are listed on the ResNet [http://noc.uwaterloo.ca/cn/Stats/resReport "don't count" list] so downloading from our mirror will not count against one's ResNet quota. Requests to mirror a particular distribution or archive should be made to syscom@csclub.uwaterloo.ca. We also have a [http://cacti.csclub.uwaterloo.ca/graph_image.php?action=view&local_graph_id=1560&rra_id=1&graph_height=120&graph_width=440 bandwidth graph] you can look at.
+
The [https://csclub.uwaterloo.ca Computer Science Club] runs a public mirror ([http://mirror.csclub.uwaterloo.ca mirror.csclub.uwaterloo.ca]) on [[Machine_List#potassium-benzoate|potassium-benzoate]].
  
== Archives Mirrored ==
+
''We are listed on the ResNet "don't count" list, so downloading from our mirror will not count against one's ResNet quota.''
  
'''Total Size:''' 4.5 TiB
+
== Software Mirrored ==
  
{| class="wikitable"
+
A list of current archives (and their respective disk usage) is listed on our mirror's homepage at [http://mirror.csclub.uwaterloo.ca mirror.csclub.uwaterloo.ca].
!style="width: 12em"| Archive ||style="width: 31em"| Upstream/Listing ||style="width: 5em"| Size || Notes
 
|-
 
| Apache || rsync://rsync.us.apache.org/apache-dist/<br/>http://www.apache.org/mirrors/ || 24 GiB || -
 
|-
 
| Arch Linux || rsync://mirror.rit.edu/archlinux<br/>http://www.archlinux.org/download/<br/>http://wiki.archlinux.org/index.php/Mirrors#Mirror_List || 40 GiB || -
 
|-
 
| Blastwave || rsync://master.rsync.blastwave.org/blastwave/<br/>http://www.blastwave.org/mirrors.php || 12 GiB || -
 
|-
 
| CentOS || rsync://us-msync.centos.org/CentOS/<br/>http://mirror-status.centos.org/ || 118 GiB || -
 
|-
 
| CPAN || rsync://rsync.nic.funet.fi/CPAN/<br/>http://mirror.cpan.org/ || 7.3 GiB || -
 
|-
 
| CRAN || rsync://cran.r-project.org/CRAN/ || 44 GiB || '''We should get added as an official mirror.'''
 
|-
 
| CTAN || rsync://carroll.aset.psu.edu/ctan/<br/>http://www.dante.de/cgi-bin/ctan/list.cgi<br/>http://www.dante.de/mirmon/ || 17 GiB || -
 
|-
 
| Cygwin || rsync://cygwin.com/cygwin-ftp/<br/>http://www.cygwin.com/mirrors.html || 8.3 GiB || -
 
|-
 
| Damn Small Linux || rsync://ftp.heanet.ie/mirrors/damnsmalllinux.org/ || 18 GiB || '''Sent a request to be added.''' Maybe contact the dude listed here: http://www.damnsmalllinux.org/donate.html.
 
|-
 
| Debian || rsync://ftp3.nrc.ca/debian/<br/>http://www.debian.org/mirror/list<br/>http://www.de.debian.org/dmc/today/ || 489 GiB || Requested to be added to the ftp.ca.debian.org rotation; will be added if the need arises..
 
|-
 
| Debian-backports || rsync://www.backports.org/backports.org/<br/>http://www.backports.org/debian/README.mirrors.html || 35 GiB || Submitted a request to be added to the mirror list long ago with no response.
 
|-
 
| Debian-cd || rsync://cdimage.debian.org/debian-cd/ || 70 GiB || Mirror only the first CD and DVD, and all small CD's (netinst, business-card, etc...).
 
|-
 
| Debian-multimedia || rsync://www.debian-multimedia.org/debian/<br/>http://www.debian-multimedia.org/debian-m.php || 6.2 GiB || -
 
|-
 
| Debian-ports || rsync://ftp.debian-ports.org/debian/ || 44 GiB || -
 
|-
 
| Debian-security || rsync://security.debian.org/debian-security/ || 44 GiB || Debian does not currently list debian-security mirrors, and encourages users to use security.debian.org exclusively.
 
|-
 
| Debian-unofficial || rsync://debian-maintainers.org/unofficial/<br/>http://www.debian-unofficial.org/mirrors.html || 465 MiB || -
 
|-
 
| Debian-volatile || rsync://volatile-master.debian.org/debian-volatile/<br/>http://www.debian.org/volatile/volatile-mirrors || 3.4 GiB || -
 
|-
 
| Eclipse || rsync://download.eclipse.org/eclipseMirror<br/>http://www.eclipse.org/downloads/download.php?file=/ || 295 GiB || -
 
|-
 
| Emdebian || rsync://www.emdebian.org/debian/ || 3.7 GiB || Emdebian does not currently list mirrors.
 
|-
 
| FreeBSD || rsync://ftp1.ca.freebsd.org/ || 1.2 TiB || '''We should get added as an official mirror.'''
 
|-
 
| Gentoo (portage) || rsync://rsync1.us.gentoo.org/gentoo-portage/ || 594 MiB || We are rsync4.ca.gentoo.org.
 
|-
 
| Gentoo (sources) || rsync://masterdistfiles.gentoo.org/gentoo/<br/>http://www.gentoo.org/main/en/mirrors.xml<br/>http://mirrorstats.gentoo.org/ || 169 GiB || See ~sysadmin/passwords/gentoo for rsync password.
 
|-
 
| GNOME || rsync://ftp.gnome.org/gnome/ || 91 GiB || -
 
|-
 
| GNU || rsync://ftp.ibiblio.org/pub/gnu/ftp/gnu/<br/>http://www.gnu.org/order/ftp.html || 21 GiB || -
 
|-
 
| KDE || rsync://master.kde.org/kdeftp/<br/>http://www.kde.org/mirrors/ || 77 GiB || -
 
|-
 
| kernel.org || rsync://kernel.org/pub/linux/<br/>rsync://kernel.org/pub/software/<br/>http://kernel.org/mirrors/countries/html/CA.html || 136 GiB || -
 
|-
 
| Linux Mint (releases) || rsync://ftp.heanet.ie/pub/linuxmint.com/<br/>http://www.linuxmint.com/mirrors.php || 31 GiB || -
 
|-
 
| Linux Mint (packages) || rsync://packages.linuxmint.com/packages/<br/>http://www.linuxmint.com/mirrors.php || 4.4 GiB || -
 
|-
 
| mozdev || rsync://rsync.mozdev.org/mozdev/<br/>http://mirrors.mozdev.org/index.html || 6.2 GiB || Currently in the North American rotation, but could request to be added to the global rotation.
 
|-
 
| mozilla.org || rsync://releases-rsync.mozilla.org/mozilla-releases/<br/>http://www.mozilla.org/mirrors.html || 122 GiB || -
 
|-
 
| MySQL || rsync://mysql.he.net/mysql/<br/>http://dev.mysql.com/downloads/mirrors.html || 167 GiB || -
 
|-
 
| non-GNU || rsync://dl.sv.gnu.org/releases/<br/>http://dl.sv.gnu.org/releases/00_MIRRORS.html<br/>http://download.savannah.gnu.org/mirmon/ || 16 GiB || -
 
|-
 
| Openoffice (extended set) || rsync://rsync.services.openoffice.org/openoffice-extended/<br/>http://distribution.openoffice.org/mirrors/#mirrors<br/>http://www.ooodev.org/mirmon/ || 103 GiB || -
 
|-
 
| OpenSUSE (opensuse-full) || rsync://stage.opensuse.org/opensuse-full/opensuse/<br/>http://mirrors.opensuse.org/list/all.html || 179 GiB || -
 
|-
 
| Slackware || rsync://slackware.cs.utah.edu/slackware/ || 139 GiB || '''We should get added as an official mirror.'''
 
|-
 
| Ubuntu || rsync://archives.ubuntu.com/ubuntu/<br/>https://launchpad.net/ubuntu/+archivemirrors || 319 GiB || '''We used to be the official Canadian mirror (''i.e.'', ca.archive.ubuntu.com); when we get more bandwidth get us added back.'''
 
|-
 
| Ubuntu-ports || rsync://ports.ubuntu.com/ubuntu-ports/ || 442 GiB || -
 
|-
 
| Ubuntu-ports-releases || rsync://cdimage.ubuntu.com/cdimage/ubuntu-ports/releases/ || 36 GiB || -
 
|-
 
| Ubuntu-releases || rsync://rsync.releases.ubuntu.com/releases/<br/>https://launchpad.net/ubuntu/+cdmirrors<br/>http://www.ubuntu.com/getubuntu/download<br/>http://www.kubuntu.org/download.php<br/>http://www.edubuntu.org/Download || 39 GiB || Are the official Canadian mirror (''i.e.'', ca.releases.ubuntu.com); ubuntu-releases includes Ubuntu, Kubuntu, and Edubuntu.
 
|-
 
| xorg.freedesktop.org || rsync://xorg.freedesktop.org/xorg-archive/<br/>http://www.x.org/wiki/Releases/Download || 5.5 GiB || -
 
|-
 
| Xubuntu-releases || rsync://cdimage.ubuntu.com/cdimage/xubuntu/releases/<br/>http://www.xubuntu.org/get || 21 GiB || -
 
|}
 
  
== Proposed Archives to Mirror ==
+
=== Mirroring Requests ===
  
* Fedora
+
Requests to mirror a particular distribution or archive should be made to [mailto:syscom@csclub.uwaterloo.ca syscom@csclub.uwaterloo.ca].
* Mandriva
 
* OpenBSD
 
* NetBSD
 
* PCLinuxOS
 
* RubyForge
 
* SourceForge
 
* MacPorts
 
* PLT Scheme (they don't ask for mirrors, but they currently offer download from half a dozen or so sites)
 
* VLC
 
  
 
== Implementation Details ==
 
== Implementation Details ==
  
The mirroring is done by one of three scripts. The latter two are based on [http://www.debian.org/mirror/anonftpsync anonftpsync]. [[#merlin|merlin]] is used to call one of these scripts. Most of the scripts and such used to maintain the mirror are available in the public [http://git.csclub.uwaterloo.ca/?p=public/mirror.git mirror.git] repository.
+
=== Syncing ===
  
=== ftpsync ===
+
==== Storage ====
  
[http://ftp-master.debian.org/ftpsync.tar.gz ftpsync] is the official Debian mirror synchronization tool, and is used to rsync the Debian repository. It's located in ~mirror/debian. Its invocation takes a few steps (this is more or less how [[#merlin|merlin]] invokes it:
+
All of our projects are stored on one of three zfs zpools. There are 8 drives per array (7 run cscmirror3), configured as raidz2, and there is an additional drive that can be swapped in (in the event of a disk failure).
  
export BASEDIR=/home/mirror/debian
+
* <code>/mirror/root/.cscmirror1</code>
cd $BASEDIR
+
* <code>/mirror/root/.cscmirror2</code>
./bin/ftpsync sync:stage1
+
* <code>/mirror/root/.cscmirror3</code>
./bin/ftpsync sync:stage2
 
  
=== csc-sync-debian ===
+
Each project is given a filesystem under one of the two pools. Symlinks are created <code>/mirror/root</code> to point to the correct pool and file system.
  
This is used to sync debian-style repositories. Its usage is:
+
==== Merlin ====
csc-sync-debian local_dir rsync_host rsync_dir [trace_host [trace_dir]]
 
  
If trace_host is specified, then $rsync_dir/project/trace/$trace_host is checked to see if it has changed. If it has, a normal debian-style (two-pass) rsync is done.
+
<nowiki>**</nowiki>'''UPDATE'''**: merlin.py and the sync scripts are currently being merged together into merlin-go which can be found at <code>/home/mirror-go/merlin</code>. The current status can be found using <code>systemctl status merlin-go.service</code> or by going to <code>/home/mirror-go/merlin/cmd/arthur</code> and running <code>./arthur status</code>. To force sync a project execute <code>./arthur sync:PROJECT_NAME</code>.
  
=== csc-sync-standard ===
 
  
This is used to sync a tree in a general way. Like anonftpsync, it supports locking and logging. Its usage is:
+
The synchronization process is run by a Python script called &quot;merlin&quot;, written by a2brenna. The script is stored in <code>~mirror/merlin</code>.
  
csc-sync-standard local_dir rsync_host rsync_dir
+
The list of repositories and their configuration (synch frequency, location, etc.) is configured in <code>merlin.py</code>.
  
=== merlin ===
+
To view the sync status, execute <code>~mirror/merlin/arthur.py status</code>. To force the sync of a project, execute <code>~mirror/merlin/arthur.py sync:PROJECT_NAME</code>.
  
The synchronization process is run by a Python script called "merlin", written by a2brenna, stored in ~mirror/merlin. The repository list, sync time, etc. is maintained in merlin.py.
+
===== Push Sync =====
  
=== HTTP ===
+
Some projects support push syncing via SSH.
  
We use [[Apache]] as our web server. Here's a snippet of the worker configuration:
+
We are running a special SSHD instance on mirror.csclub.uwaterloo.ca:22. This instance has been locked down, with the following settings:
  
<IfModule mpm_worker_module>
+
* Only SSH key authentication
    ServerLimit          64
+
* Only users of the <code>push</code> group (except <code>mirror</code>) are allowed to connect
    ThreadLimit          64
+
* X11 Forwarding, TCP Forwarding, Agent Forwarding, User RC and TTY are disabled
    StartServers          2
+
* Users are chrooted to <code>/mirror/merlin</code>
    MaxClients        4096
 
    MinSpareThreads      16
 
    MaxSpareThreads      48
 
    ThreadsPerChild      64
 
    MaxRequestsPerChild  0
 
</IfModule>
 
  
We use the bwbar application to display current bandwidth in the footer of mirror pages.
+
Most projects will connect using the <code>push</code> user. The SSH authorized keys file is located at <code>/home/push/.ssh/authorized_keys</code>. An example entry is:
 +
 
 +
<pre>
 +
restrict,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="arthur sync:ubuntu >/dev/null 2>/dev/null </dev/null &",from="XXX.XXX.XXX.XXX" ssh-rsa ...
 +
</pre>
 +
 
 +
==== Sync Scripts ====
 +
 
 +
Our collection of synchronization scripts are located in <code>~mirror/bin</code>. They currently include:
 +
 
 +
* <code>csc-sync-apache</code>
 +
* <code>csc-sync-debian</code>
 +
* <code>csc-sync-debian-cd</code>
 +
* <code>csc-sync-gentoo</code>
 +
* <code>csc-sync-ssh</code>
 +
* <code>csc-sync-standard</code>
 +
 
 +
Most of these scripts take the following parameters:
 +
 
 +
<code>local_dir rsync_host rsync_dir</code>
 +
 
 +
=== HTTP(s) ===
 +
 
 +
We use [https://nginx.org nginx] as our webserver.
  
 
==== Index ====
 
==== Index ====
  
An index of the archives we mirror is available at http://mirror.csclub.uwaterloo.ca/.
+
An index of the archives we mirror is available at [http://mirror.csclub.uwaterloo.ca mirror.csclub.uwaterloo.ca].
As of Winter 2010, it is now generated by a Python script in <tt>~mirror/mirror-index</tt>.
+
 
 +
As of Winter 2010, it is now generated by a Python script in <code>~mirror/mirror-index</code>.
 +
 
 +
<code>~mirror/mirror-index/make-index</code> is scheduled in <code>/etc/cron.d/csc-mirror</code> to be run hourly. The script can be run manually when needed (for example, when the archive list is updated) by running:
  
<tt>~mirror/mirror-index/make-index.py</tt> is scheduled in <tt>mirror</tt>'s crontab to be
+
<code>sudo -u mirror /home/mirror/mirror-index/make-index.py</code>
run at 5:40 AM on the 14th and 28th of each month. The script can be run manually when needed
 
(for example, when an archive is removed) as follows:
 
  
sudo -u mirror /home/mirror/mirror-index/make-index.py
+
The script will iterate all folders in <code>/mirror/root</code>, identify the size of the project using `zfs get -H -o value used $dataset`, where $dataset is calculated from the symlink in <code>/mirror/root</code>. The size of all folders is added together to calculate the total folder size (the total size includes hidden projects).
  
This causes an instance of <tt>du</tt> to be run which computes the size of each directory. This
+
<code>make-index.py</code> is configured by means of a [https://yaml.org YAML] file, <code>config.yaml</code>, in the same directory. Its format is as follows:
list is then sorted alphabetically by directory name and returned to the Python script.
 
If any errors occur during this process, the script conservatively chooses to exit rather
 
than risk generating an index file that is incorrect.
 
  
<tt>make-index.py</tt> is configured by means of a [http://www.yaml.org/ YAML] file,
+
<pre class="yaml">docroot: /mirror/root
<tt>config.yaml</tt>, in the same directory. Its format is as follows:
+
output: /mirror/root/index.html
  
docroot: /mirror/root
+
exclude:
duflags: --human-readable --max-depth=1
+
  - include
output: /mirror/root/index.html
+
   - lost+found
+
   - pub
directories:
+
# (...)
   apache:
 
    site: apache.org
 
    url: <nowiki>http://www.apache.org/</nowiki>
 
 
   archlinux:
 
    site: archlinux.org
 
    url: <nowiki>http://www.archlinux.org/</nowiki>
 
 
# (...)
 
  
The <tt>docroot</tt> is the directory which is to be scanned; this will probably
+
directories:
always be the mirror root from which Apache serves. <tt>duflags</tt> specifies
+
  apache:
the flags to be passed to <tt>du</tt>. This is here so that it's easy to find
+
    site: apache.org
and alter. For instance, we could change <tt>--human-readable</tt> to <tt>--si</tt>
+
    url: http://www.apache.org/
if we ever decided that, like hard disk manufacturers, we want sizes to appear larger
 
than they are. <tt>output</tt> defines the file to which the generated index will be
 
written.
 
  
Finally, <tt>directories</tt> specifies the list of directories to be listed.
+
  archlinux:
No directories not listed here will be shown. If you add a new archive and it doesn't
+
    site: archlinux.org
appear, that's why. The format is fairly straightforward: simply name the directory
+
    url: http://www.archlinux.org/
and provide a site (the display name in the "Project Site" column) and URL.
 
  
One caveat here is that YAML does not allow tabs for whitespace. Indent with
+
# (...)</pre>
two spaces to remain consistent with the existing file format, please. Also note
+
The docroot is the directory which is to be scanned; this will probably always be the mirror root from which Apache serves. This is here so that it's easy to find and alter. For instance, we could change <code>--human-readable</code> to <code>--si</code> if we ever decided that, like hard disk manufacturers, we want sizes to appear larger than they are. <code>output</code> defines the file to which the generated index will be written.
that the directory name is case-sensitive, as is always the case on Unix.
 
  
Finally, the HTML index file is generated from <tt>index.mako</tt>, a
+
<code>exclude</code> specifies the list of directories which will not be included in the generated index page (since, by default, all folders are included in the generated index page).
[http://www.makotemplates.org/ Mako] template (which is mostly HTML anyhow).
+
 
If you really can't figure out how it works, look up the Mako documentation.
+
Finally, <code>directories</code> specifies the information of directories. All directories are listed by default, whether or not they appear in this list - only those under <code>exclude</code> are ignored. The format is fairly straightforward: simply name the directory and provide a site (the display name in the &quot;Project Site&quot; column) and URL. One caveat here is that YAML does not allow tabs for whitespace. Indent with two spaces to remain consistent with the existing file format, please. Also note that the directory name is case-sensitive, as is always the case on Unix.
 +
 
 +
Finally, the HTML index file is generated from <code>index.mako</code>, a Mako template (which is mostly HTML anyhow). If you really can't figure out how it works, look up the Mako documentation.
  
 
=== FTP ===
 
=== FTP ===
  
We use proftpd (standalone daemon) as our ftp server. To increase performance we disable DNS lookups in proftpd.conf:
+
We use [http://www.proftpd.org/ proftpd] (standalone daemon) as our FTP server.
  
UseReverseDNS          off
+
To increase performance, we disable DNS lookups in <code>proftpd.conf</code>:
IdentLookups            off
 
  
We also limit the amount of CPU/memory resources used (e.g. to minimize [http://en.wikipedia.org/wiki/Globbing Globbing] resources):
+
<pre>UseReverseDNS          off
 +
IdentLookups            off</pre>
 +
We also limit the amount of CPU/memory resources used (e.g. to minimize [https://en.wikipedia.org/wiki/Globbing Globbing] resources):
  
RLimitCPU              session 10
+
<pre>RLimitCPU              session 10
RLimitMemory            session 4096K
+
RLimitMemory            session 4096K</pre>
 +
We allow a maximum of 500 concurrent FTP sessions:
  
We allow a maximum of 200 concurrent ftp sessions:
+
<pre>MaxInstances            500
 +
MaxClients              500</pre>
 +
The contents of <code>/mirror/root/include/motd.msg</code> are displayed when a user connects.
  
MaxInstances            500
+
=== rsync ===
MaxClients              500
 
  
=== rsync ===
+
We use <code>rsyncd</code> (standalone daemon).
 +
 
 +
We disable compression and checksumming in <code>rsyncd.conf</code>:
 +
 
 +
<pre>dont compress = *
 +
refuse options = c delete</pre>
 +
The contents of <code>/mirror/root/include/motd.msg</code> are displayed when a user connects.
 +
 
 +
== Mirror Administration ==
 +
 
 +
=== Adding a new project ===
 +
 
 +
# Find the instructions for mirroring the project. Ideally, try to sync directly from the project’s source repository.
 +
#* Note that some projects provide sync scripts, however we generally won’t use them. We will instead use our custom ones.
 +
# Create a zfs filesystem to store the project in:
 +
#* Find the pool with least current disk usage
 +
#* <code>zfs create cscmirror{1,2,3}/$PROJECT_NAME</code>
 +
# Change the folder ownership
 +
#* <code>chown mirror:mirror /mirror/root/.cscmirror{1,2,3}/$PROJECT_NAME</code>
 +
# Create the symlink in <code>/mirror/root</code>
 +
#* <code>ln -s .cscmirror{1,2,3}/$PROJECT_NAME $PROJECT_NAME</code> ('''NOTE''': The symlink must be relative to the <code>/mirror/root</code> directory. If it isn’t, the symlinks will not work when chrooted)
 +
# Repeat the above steps on mirror-dc. <code>sudo ssh mirror-dc</code> on potassium-benzoate
 +
# Configure the project in merlin (<code>~mirror/merlin/merlin.py</code>)
 +
#* Select the appropriate sync script (typically <code>csc-sync-standard</code>) and supply the appropriate parameters
 +
# Restart merlin: <code>systemctl restart merlin</code>
 +
# Configure the project in zfssync.yml (<code>~mirror/merlin/zfssync.yml</code>)
 +
#* This will kick off the initial sync
 +
#* Check <code>~mirror/merlin/logs/$PROJECT_NAME</code> for errors, <code>~mirror/merlin/logs/transfer.log</code> for transfer progress
 +
# Update the mirror index configuration (<code>~mirror/mirror-index/config.yaml</code>)
 +
# Add the project to rsync (<code>/etc/rsyncd.conf</code>)
 +
#* Restart rsync with <code>systemctl restart rsync</code>
 +
 
 +
If push mirroring is available/required, see [[#Push_Sync|Push Sync]].
 +
 
 +
=== Secondary Mirror ===
 +
 
 +
The School of Computer Science's CSCF has provided us with a secondary mirror machine located in DC. This will limit the downtime of mirror.csclub in the event of an outage affecting the MC machine room.
 +
 
 +
==== Keepalived ====
 +
 
 +
Mirror's IP addresses (129.97.134.71 and 2620:101:f000:4901:c5c::f:1055) have been configured has VRRP address on both machines. Keepalived does the monitoring and selecting of the active node.
 +
 
 +
Potassium-benzoate has higher priority and will typically be the active node. A node's priority is reduced when nginx, proftpd or rsync are not running. Potassium-benzoate starts with a score of 100 and mirror-dc starts with a priority of 90 (higher score wins).
 +
 
 +
When nginx is unavailable (checked w/ curl), the priority is reduced by 20. When proftpd is unavailable (checked with curl), the priority is reduced by 5. When rsync is unavailable (checking with rsync), the priority is reduced by 15.
 +
 
 +
The Systems Committee should received an email when the nodes swap position.
  
We use rsyncd (standalone daemon). We disable compression and checksumming in rsyncd.conf:
+
==== Project synchronization ====
  
dont compress = *
+
Only potassium-benzoate is configure with merlin. mirror-dc has the software components, but they are probably not update to date nor configured to run correctly.
refuse options = c delete
 
  
For ftp and rsync, the contents of /mirror/root/include/motd.msg are displayed when users connect.
+
When a project sync is complete, merlin will kick off a custom script to sync the zfs dataset to the other node. These scripts live in /usr/local/bin and in ~mirror/merlin.

Latest revision as of 21:37, 4 August 2022

The Computer Science Club runs a public mirror (mirror.csclub.uwaterloo.ca) on potassium-benzoate.

We are listed on the ResNet "don't count" list, so downloading from our mirror will not count against one's ResNet quota.

Software Mirrored

A list of current archives (and their respective disk usage) is listed on our mirror's homepage at mirror.csclub.uwaterloo.ca.

Mirroring Requests

Requests to mirror a particular distribution or archive should be made to syscom@csclub.uwaterloo.ca.

Implementation Details

Syncing

Storage

All of our projects are stored on one of three zfs zpools. There are 8 drives per array (7 run cscmirror3), configured as raidz2, and there is an additional drive that can be swapped in (in the event of a disk failure).

  • /mirror/root/.cscmirror1
  • /mirror/root/.cscmirror2
  • /mirror/root/.cscmirror3

Each project is given a filesystem under one of the two pools. Symlinks are created /mirror/root to point to the correct pool and file system.

Merlin

**UPDATE**: merlin.py and the sync scripts are currently being merged together into merlin-go which can be found at /home/mirror-go/merlin. The current status can be found using systemctl status merlin-go.service or by going to /home/mirror-go/merlin/cmd/arthur and running ./arthur status. To force sync a project execute ./arthur sync:PROJECT_NAME.


The synchronization process is run by a Python script called "merlin", written by a2brenna. The script is stored in ~mirror/merlin.

The list of repositories and their configuration (synch frequency, location, etc.) is configured in merlin.py.

To view the sync status, execute ~mirror/merlin/arthur.py status. To force the sync of a project, execute ~mirror/merlin/arthur.py sync:PROJECT_NAME.

Push Sync

Some projects support push syncing via SSH.

We are running a special SSHD instance on mirror.csclub.uwaterloo.ca:22. This instance has been locked down, with the following settings:

  • Only SSH key authentication
  • Only users of the push group (except mirror) are allowed to connect
  • X11 Forwarding, TCP Forwarding, Agent Forwarding, User RC and TTY are disabled
  • Users are chrooted to /mirror/merlin

Most projects will connect using the push user. The SSH authorized keys file is located at /home/push/.ssh/authorized_keys. An example entry is:

restrict,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="arthur sync:ubuntu >/dev/null 2>/dev/null </dev/null &",from="XXX.XXX.XXX.XXX" ssh-rsa ...

Sync Scripts

Our collection of synchronization scripts are located in ~mirror/bin. They currently include:

  • csc-sync-apache
  • csc-sync-debian
  • csc-sync-debian-cd
  • csc-sync-gentoo
  • csc-sync-ssh
  • csc-sync-standard

Most of these scripts take the following parameters:

local_dir rsync_host rsync_dir

HTTP(s)

We use nginx as our webserver.

Index

An index of the archives we mirror is available at mirror.csclub.uwaterloo.ca.

As of Winter 2010, it is now generated by a Python script in ~mirror/mirror-index.

~mirror/mirror-index/make-index is scheduled in /etc/cron.d/csc-mirror to be run hourly. The script can be run manually when needed (for example, when the archive list is updated) by running:

sudo -u mirror /home/mirror/mirror-index/make-index.py

The script will iterate all folders in /mirror/root, identify the size of the project using `zfs get -H -o value used $dataset`, where $dataset is calculated from the symlink in /mirror/root. The size of all folders is added together to calculate the total folder size (the total size includes hidden projects).

make-index.py is configured by means of a YAML file, config.yaml, in the same directory. Its format is as follows:

docroot: /mirror/root
output: /mirror/root/index.html

exclude:
   - include
   - lost+found
   - pub
# (...)

directories:
  apache:
    site: apache.org
    url: http://www.apache.org/

  archlinux:
    site: archlinux.org
    url: http://www.archlinux.org/

# (...)

The docroot is the directory which is to be scanned; this will probably always be the mirror root from which Apache serves. This is here so that it's easy to find and alter. For instance, we could change --human-readable to --si if we ever decided that, like hard disk manufacturers, we want sizes to appear larger than they are. output defines the file to which the generated index will be written.

exclude specifies the list of directories which will not be included in the generated index page (since, by default, all folders are included in the generated index page).

Finally, directories specifies the information of directories. All directories are listed by default, whether or not they appear in this list - only those under exclude are ignored. The format is fairly straightforward: simply name the directory and provide a site (the display name in the "Project Site" column) and URL. One caveat here is that YAML does not allow tabs for whitespace. Indent with two spaces to remain consistent with the existing file format, please. Also note that the directory name is case-sensitive, as is always the case on Unix.

Finally, the HTML index file is generated from index.mako, a Mako template (which is mostly HTML anyhow). If you really can't figure out how it works, look up the Mako documentation.

FTP

We use proftpd (standalone daemon) as our FTP server.

To increase performance, we disable DNS lookups in proftpd.conf:

UseReverseDNS           off
IdentLookups            off

We also limit the amount of CPU/memory resources used (e.g. to minimize Globbing resources):

RLimitCPU               session 10
RLimitMemory            session 4096K

We allow a maximum of 500 concurrent FTP sessions:

MaxInstances            500
MaxClients              500

The contents of /mirror/root/include/motd.msg are displayed when a user connects.

rsync

We use rsyncd (standalone daemon).

We disable compression and checksumming in rsyncd.conf:

dont compress = *
refuse options = c delete

The contents of /mirror/root/include/motd.msg are displayed when a user connects.

Mirror Administration

Adding a new project

  1. Find the instructions for mirroring the project. Ideally, try to sync directly from the project’s source repository.
    • Note that some projects provide sync scripts, however we generally won’t use them. We will instead use our custom ones.
  2. Create a zfs filesystem to store the project in:
    • Find the pool with least current disk usage
    • zfs create cscmirror{1,2,3}/$PROJECT_NAME
  3. Change the folder ownership
    • chown mirror:mirror /mirror/root/.cscmirror{1,2,3}/$PROJECT_NAME
  4. Create the symlink in /mirror/root
    • ln -s .cscmirror{1,2,3}/$PROJECT_NAME $PROJECT_NAME (NOTE: The symlink must be relative to the /mirror/root directory. If it isn’t, the symlinks will not work when chrooted)
  5. Repeat the above steps on mirror-dc. sudo ssh mirror-dc on potassium-benzoate
  6. Configure the project in merlin (~mirror/merlin/merlin.py)
    • Select the appropriate sync script (typically csc-sync-standard) and supply the appropriate parameters
  7. Restart merlin: systemctl restart merlin
  8. Configure the project in zfssync.yml (~mirror/merlin/zfssync.yml)
    • This will kick off the initial sync
    • Check ~mirror/merlin/logs/$PROJECT_NAME for errors, ~mirror/merlin/logs/transfer.log for transfer progress
  9. Update the mirror index configuration (~mirror/mirror-index/config.yaml)
  10. Add the project to rsync (/etc/rsyncd.conf)
    • Restart rsync with systemctl restart rsync

If push mirroring is available/required, see Push Sync.

Secondary Mirror

The School of Computer Science's CSCF has provided us with a secondary mirror machine located in DC. This will limit the downtime of mirror.csclub in the event of an outage affecting the MC machine room.

Keepalived

Mirror's IP addresses (129.97.134.71 and 2620:101:f000:4901:c5c::f:1055) have been configured has VRRP address on both machines. Keepalived does the monitoring and selecting of the active node.

Potassium-benzoate has higher priority and will typically be the active node. A node's priority is reduced when nginx, proftpd or rsync are not running. Potassium-benzoate starts with a score of 100 and mirror-dc starts with a priority of 90 (higher score wins).

When nginx is unavailable (checked w/ curl), the priority is reduced by 20. When proftpd is unavailable (checked with curl), the priority is reduced by 5. When rsync is unavailable (checking with rsync), the priority is reduced by 15.

The Systems Committee should received an email when the nodes swap position.

Project synchronization

Only potassium-benzoate is configure with merlin. mirror-dc has the software components, but they are probably not update to date nor configured to run correctly.

When a project sync is complete, merlin will kick off a custom script to sync the zfs dataset to the other node. These scripts live in /usr/local/bin and in ~mirror/merlin.