Technical Tip

QUESTION

How can I set up a local yum repository, so that my RedHat or CentOS systems do not need internet access to update themselves?

ANSWER

Our Linux Admin training courses cover the use of yum, and the management of software repository information.
yum provides a very admin-friendly way to install and update RPM files, and provides great facilities for package and file searches.
The problem we have is that yum repositories (the places where the software packages are stored) or held on various servers on the internet and  we do not always have internet access when running courses at customer sites.
The solution is to create a repository on a local server, in our case the instructor's Linux laptop!
The training systems can then install and update packages locally at very high speed.
The repositories on the training server are made available under the Apache web server directory structure, and are periodically update online, usually prior to the start of each course.
Server Setup - CentOS example
1. Ensure that the Apache web server is installed. The default CentOS/RedHat Apache configuration is fine.

2. Use the  necessary commands to create the Base and Updates repositories:-
mkdir  -p  /var/www/html/centos/5.5/updates
mkdir  /var/www/html/centos/5.5/os

Ensure internet access is enabled, then create a base repo as follows:-
(You may wish to choose a different rsync mirror, the example uses rsync.mirrorservice.org, see http://www.centos.org/modules/tinycontent/index.php?id=30 for a mirror list)
rsync  -avrt  rsync://rsync.mirrorservice.org/mirror.centos.org/5.5/os/i386/  --exclude=debug/     /var/www/html/centos/5.5/os/
Welcome to the University of Kent's UK Mirror Service

More information can be found at our web site: http://www.mirrorservice.org/
Please send comments or questions to help@mirrorservice.org

Please use rsync.mirrorservice.org for rsync access,
ftp.mirrorservice.org for ftp access and
don't use www.mirrorservice.org for anything other than http.
etc.. etc..
On completion, you will now have a Base repo locally.
Now create the updates repo:-
rsync -avrt  rsync://rsync.mirrorservice.org/mirror.centos.org/5.5/updates/i386/   --exclude=debug/   /var/www/html/centos/5.5/updates/
Welcome to the University of Kent's UK Mirror Service

More information can be found at our web site: http://www.mirrorservice.org/
Please send comments or questions to help@mirrorservice.org
etc.. etc..
Note: To save internet bandwidth, you can initially copy the packages to the base repo directory directly from an OS distribution image, but make sure you preserve the original time date and time stamps on the files. Having done this, then update with the rsync command shown above.
3. Start the Apache web server and enable at boot time:-
service  httpd  start
chkconfig  httpd  on

Check for errors at Apache startup.

Client Setup
1. Backup your existing CentOS-Base.repo:-
cd  /etc/yum.repos.d
cp  CentOS-Base.repo  CentOS-Base.repo.orig
2. Edit CentOS-Base.repo so it has the following contents:-

# Start of repo file
[base]
name=CentOS-$releasever - Base
baseurl=http://<yum server ip>/centos/5.5/os/
gpgcheck=0

[updates]
name=CentOS-$releasever - Updates
baseurl=http://<yum server ip>/centos/5.5/updates/
gpgcheck=0
# End of repo file

You may wish to investigate further options in the repo files, especially those concerning security.
Now run yum to test you configuration:-
yum  repolist
yum  list  available

For more information on yum and Linux why not attend our 3-day Linux Part 1 Administration course?

How do I set up and configure a Zone in Solaris 10?

ANSWER


First Alternative course instructors can answer questions like this ... and are happy to do so. Look around our site for relevant courses in Linux -Unix - Perl - Solaris

close window