Table of Contents
Install Update Mirror
This page shows how to set up a CentOS 6 x86_64 mirror.
Prerequisites
You must have a CentOS 6 server available with over 50GB of space available. When a new 6.* is released, there is very little data in the folder. However, as time goes by, more and more updates increase the size of the directory.
Configure Data Disk
It is strongly recommended that you set up a dedicated partition for the mirror files that is at least 50Gb in size. There are various ways of achieving this that are documented in other pages such as Linux Disk Administration.
This guide assumes you will be creating data files in /data/mirror/centos. Create the needed subdirectories. At the time of writing, CentOS 6.4 was out of support, CentOS 6.6 was the latest edition and 6.5 was still supported. To this end, we create two directories.
mkdir -p /data/mirror/centos/6.5 mkdir -p /data/mirror/centos/6.6
=Download Updates= Run the following to do the initial download of the updates while ignoring several folders we don't need (like the CentOS ISO files). Notice that we are using warwick.ac.uk. Run 'yum update' and pay attention to where it tries to download from. If it tries to download from somewhere else, consider using that domain instead of warwick as you may find it is faster.
Please remember that the first download may take many hours.
rsync --progress -av --delete --delete-excluded --exclude "local" --exclude "xen4" --exclude "isos" --exclude "i386" rsync://anorien.csc.warwick.ac.uk/CentOS/6.5/ /data/mirror/centos/6.5 rsync --progress -av --delete --delete-excluded --exclude "local" --exclude "xen4" --exclude "isos" --exclude "i386" rsync://anorien.csc.warwick.ac.uk/CentOS/6.6/ /data/mirror/centos/6.6
Clean Up
Most CentOS servers are set to look at '6' and then '6' (on the server) is set to point to the latest 6.*.
cd /data/mirror/centos ln -s 6.6. 6
Fix SELinux permissions so that we can share this data via http
semanage fcontext -a -t httpd_sys_content_t "/data/mirror(/.*)?" restorecon -R -v /data/mirror
Install Apache
Install Apache
yum install httpd
This is a bug fix for Firefox CSS rendering
echo 'AddType text/css .css' >> /etc/httpd/conf/httpd.conf
Change the default root directory of Apache
sed -i "s/var\/www\/html/data\/mirror/g" /etc/httpd/conf/httpd.conf
rm -f /etc/httpd/conf.d/welcome.conf
cat > /etc/httpd/conf.d/repo.conf <<'END_OF_TEXT'
Alias /repo/ /data/mirror/
<directory /data/mirror>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</directory>
END_OF_TEXT
Ensure that httpd (Apache) is started and starts automatically on boot
service httpd restart chkconfig httpd on
Open the Firewall
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT service iptables save service iptables restart
Set Crontab
Obviously, for the above to work you will have to create the scripts sync6.6.sh and sync6.5.sh.
cat << EOF > /root/sync6.5.sh #/bin/bash rsync --progress -av --delete --delete-excluded --exclude "local" --exclude "xen4" --exclude "isos" --exclude "i386" rsync://anorien.csc.warwick.ac.uk/CentOS/6.5/ /data/mirror/centos/6.5 EOF cat << EOF > /root/sync6.6.sh #/bin/bash rsync --progress -av --delete --delete-excluded --exclude "local" --exclude "xen4" --exclude "isos" --exclude "i386" rsync://anorien.csc.warwick.ac.uk/CentOS/6.6/ /data/mirror/centos/6.6 EOF chmod u+x /root/sync6.*.sh
Add the following to crontab (with the 'crontab -e' command) to update at 2am each morning
0 2 * * * /root/sync6.5.sh; 0 2 * * * /root/sync6.6.sh;
Configure Client to Use Mirror
If centosupdate.example.com exists and is a functioning repository for CentOS, you can replace the contents of /etc/yum.repos.d/CentOS-Base.repo with the following
cat > /etc/yum.repos.d/CentOS-Base.repo << EOF [base] name=CentOS-6.5 - Base baseurl=http://centosupdate.example.com/centos/6/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [updates] name=CentOS-6.5 - Updates baseurl=http://centosupdate.example.com/centos/6/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [extras] name=CentOS-6.5 - Extras baseurl=http://centosupdate.example.com/centos/6/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [centosplus] name=CentOS-6.5 - Plus baseurl=http://centosupdate.example.com/centos/6/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [contrib] name=CentOS-6.5 - Contrib baseurl=http://centosupdate.example.com/repo/centos/6/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 EOF
