If so, here I bring you how to mirror CentOS 7. What are the benefits of this? Among them, you save Internet bandwidth, you keep a local copy of your repositories with which the downloads and installations are much faster, and the main one of all is very useful as an update server if you have 10 servers or 1000 workstations with CentOS I think this is your best option because you can offer a fast update service and with the speed of your LAN network.
Now, you can make your mirror in about 10 ways but I'm going to tell you the one that in my opinion is the fastest and most comfortable, well you can make your mirror in any distribution that supports Rsync. Yesiiiiii! anyone, you can read only the rsync part, make a local centOS repository on ubuntu, debian, fedora, redhat, slackware, they all support rsync
Rsync is a free application for Unix and Microsoft Windows-type systems that offers efficient transmission of incremental data, which also operates with compressed and encrypted data. Using a delta encoding technique, it allows you to synchronize files and directories between two machines on a network or between two locations on the same machine, minimizing the volume of data transferred.
We proceed to install rsync
# yum install rsync
Once installed you just have to look in the list of CentOS mirrors some mirror near your locality that works with rsync (it is the sixth column) Rsync Location
Create a folder where you can place the repository, I only made a mirror of CentOS 7, complete with isos and all the available folders, which took up 38 GB, so take into consideration if you are going to make a partial mirror of other versions of centOS or a full mirror. How much space will it occupy? It is something you should evaluate.
# mkdir -p /home/repo/CentOS/7
The repository has all these folders:
rsync works as follows:
# rsync --delete-excluded --exclude "local" --exclude "isos" --exclude "*.iso"
- With the tag delete – excluded and –exclude you can ignore folders or files, example iso folder, or .iso files, very easy right?
# rsync -aqzH --delete msync.centos.org::CentOS /path/to/local/mirror/root
- With option –Delete, will delete files that no longer exist in the source.
- -a archive and store
- -q quiet mode, suppresses non-error messages
- -z compress data during transfer
- -H keep the hard links, if you wanted I would also recommend the option -l to hold symlinks
How did I do it? simple like this:
# rsync -avzqlH --delete --delay-updates rsync://ftp.osuosl.org/centos/7/ /home/repo/CentOS/7
Don't rush, I'll explain why I did it like that.
- –Delay-updates Place all the updated files at the end of the entire download, do you understand me? That is, he does not update each time he downloads a new file, but on the contrary, if there were 100 new files, after finishing the 100 new files, rsync them place in place
- rsync: //ftp.osuosl.org/centos/7/ because I only want to do CentOS 7
- / var / www / html / repo / CentOS / 7 where I am going to put all my files that I copy from the source.
It is not necessary, but I recommend the package createrepo, simply what it does is give it the http characteristic and create an index for your repository
# yum install createrepo
Then just run the command pointing to your repository
# createrepo /home/repo/CentOS/7
Now once finished, you must share it in some way, I always use an http server, continuing with CentOS 7, you can install a basic web server as follows (use httpd, it is not apache)
# yum group install -y "Basic Web Server
Create a symbolic link from the actual repository site to the "www" folder
# ln -s /home/repo /var/www/html/repo
We create the sites-available and sites-enabled folders
# mkdir /etc/httpd/sites-available
# mkdir /etc/httpd/sites-enabled
We edit the httpd.conf file to add all our active sites-enabled sites
# vi /etc/httpd/conf/httpd.conf
Add this line to the end of the file
IncludeOptional sites-enabled / *. Conf
We create and edit our website
# vi /etc/httpd/sites-available/repocentos.conf
DocumentRoot / var / www / html / repo / CentOS /
CustomLog /var/log/httpd/requests.log combined
We activate our site by creating a symbolic link
# ln -s /etc/httpd/sites-available/repocentos.conf /etc/httpd/sites-enabled/repocentos.conf
We change the owner and group of files and folders for apache
# chown apache. www/ -R
We execute the following command so that the web server starts from the moment we started the machine
# systemctl enable httpd.service
We restart the web server with the following command
# systemctl restart httpd
How can we use it?
Create a file in /etc/yum.repos.d/local.repo and paste the following lines:
[os] name = master - Base baseurl = http: //ip or url/ repo / CentOS / $ releasever / os / $ basearch / gpgcheck = 1 gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-7 [updates] name = master - Updates baseurl = http: //ip or url/ repo / CentOS / $ releasever / updates / $ basearch / gpgcheck = 1 gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-7 [extras] name = master - Extras baseurl = http: //ip or url/ repo / CentOS / $ releasever / extras / $ basearch / gpgcheck = 1 gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-7 [centosplus] name = master - CentosPlus baseurl = http: //ip or url/ repo / CentOS / $ releasever / centosplus / $ basearch / gpgcheck = 1 gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-7
We refresh the repositories with:
# yum clean all
# yum repolist all
# yum update
Well that's it for this time. As always remember to closely follow my post and this website. Comment and so we all share our knowledge, until next time !!!