After setting up a server or provisioning a VM that meets the above requirements, follow these steps to set up the repository.
Login to your internal repository as the root user through SSH or the console.
The rsync, cronie, and httpd packages must be functional to create a repository. Install these packages by running the command:
shell> yum install rsync httpd cronieThis will install any of those packages if they are missing.
Make a set of directories that will host the repository packages:
shell> mkdir -p /var/www/html/centos/7/{os,updates}/x86_64
Use rsync
to create a clone of the base OS packages from the ferred online mirror. In the following command, replace <mirror-url>
with the rsync
URL for the chosen online repository:
shell> /usr/bin/rsync -avrt <mirror-url> /7/os/x86_64 --exclude=debug /var/www/html/centos/7/os/
Example command using the UC Berkeley mirror:
shell>/usr/bin/rsync -avrt rsync://mirrors.ocf.berkeley.edu/centos
/7/os/x86_64 --exclude=debug /var/www/html/centos/7/os/
This will download approximately 6 GB of packages to the internal repository.Use rsync
to create a clone of the update packages from the ferred online mirror. In the following command, replace <mirror-url>
with the rsync
url for the chosen online repository:
shell> /usr/bin/rsync -avrt <mirror-url>/7/updates/x86_64 --exclude=debug /var/www/html/centos/7/updates/
This will download approximately 9 GB of packages to your internal repository.With all the packages in place, the internal repository is almost ready to distribute packages. Start the Apache httpd server to bring the repository online:
shell> service httpd start
Use the following command to ensure httpd
is started automatically whenever the repository is restarted:
shell>chkconfig httpd on
The local CentOS firewall is most likely blocking access to the internal repository by default. Add a new rule to allow traffic to port 80.
shell>firewall-cmd --permanent --zone=public --add-port=80/tcp
After the new rule has been added, restart the firewall with the command:
shell>systemctl restart firewalld
The internal repository has all the current packages now, but it will quickly become out of date as new updates are pushed out to the online repositories. To keep the internal repository up to date, setup a cron
job to periodically download updates from the preferred repository. To create a cron
job, run the command:
shell> crontab -eThis will open an editor to add the
cron
script. Write out the following on a single line in the editor (replacing <mirror-url>
with the rsync
url for your chosen online repository):
00 00 * * * /usr/bin/rsync -avrt <mirror-url>
/7/updates/x86_64 --delete --exclude=debug /var/www/html/centos/7/updates/
This will download updates from the online repository every midnight.
The internal repository is setup, ready for use, and configured to update itself automatically. The next section will cover configuring your SAKA to use the internal repository for package management.