reposync is used to download an entire remote yum repository or a set of remote repositories. It will also synchronize changes in a repository with a local directory.
Why reposync is preferred over an rsync based approach …?
- reposync by default uses HTTP , so it is easier on firewalls (Most of time outbound ports 80/443 are opened in firewall)
- reposync can use multiple mirrors, as specified in the ‘mirrorlist’ directive. So there is no longer a dependency on a single server on the remote end to be up and running
- There are significantly more HTTP mirrors than rsync ones, so reposync scripts can play nicely and distribute the load over a larger number of server
In this tutorials we will download CentOS 6.2 yum repositories locally on my ftp server and will make available these repositories to my data center centos machines.
Step:1 Download & install reposync rpm
# wget ftp://ftp.pbone.net/mirror/ftp.sourceforge.net/pub/sourceforge/y/yu/yum-repo-sync/yum-repo-sync/2.0/yum-repo-sync-2.0-0.noarch.rpm # rpm -ivh yum-repo-sync-2.0-0.noarch.rpm
Step:2 Create a Directory locally
# mkdir /var/ftp/pub/Centos-6.2-RPMS
Open the file “cat /etc/yum.repos.d/CentOS-Base.repo” Copy the name of repositories you want to download and Run the below Command.
# nohup reposync -r base -p /var/ftp/pub/Centos-6.2-RPMS/ &
A directory with name base will be created automatically under /var/ftp/pub/Centos-6.2-RPMS. We can check the progress of downloading by using below command
# tail -f nouhup.out
Similarly download all the repositories using above reposync Command , just replace the name of “base” with new repository.
Note: To get all the updates after downloading repositories , run below command under the directory /var/ftp/pub/Centos-6.2-RPMS
# reposync --repoid=base --repoid=updates --repoid=extras
Step:3 Create a repomd (xml-based rpm metadata) repository from a set of rpms
# cd /var/ftp/pub/Centos-6.2-RPMS # createrepo -v base
Similarly run the above command for all downloaded repositories.
Step:4 Create a repository file under “/etc/yum.repos.d/”
First Move all repositories to another folder and create a file.
# vi server.repo
In this tutorials we are assuming ftp service up and running.
Step:5 Now transfer server.repo fils to all centos-6.2 machines.
# scp server.repo root@<ip-address>:/etc/yum.repos.d/
For testing , run the below command on Centos Machines :
# yum list all
It will list all packages corresponding to repositories.