Making a simple Yum repository.

Here is some low hanging fruit to improve your RHEL environment and simplify your work… setup a simple Yum repository.

 

There is very little magic involved in getting a yum repository up and running. You just need a web server and createrepo.

yum -y install createrepo httpd

Give your repo a home.

mkdir -p /path/to/repo/MyRepo

Go ahead and setup a vhost for the repo.

cat <<EOF > /etc/httpd/conf.d/repo.conf
<VirtualHost *:80>
ServerName repo.example.com
ServerAlias repo
ServerAdmin ops@example.com
DocumentRoot /path/to/repo/
ErrorLog logs/repo.example.com-error_log
CustomLog logs/repo.example.com-access_log common
<Directory "/path/to/repo/*">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EOF

And fire it up.

/etc/init.d/httpd start

Now, dump your RPMs there and run createrepo. It scans the RPMs in the directory and makes the proper metadata resources.

mv *.rpm /path/to/repo/MyRepo
createrepo /path/to/repo/MyRepo

Everytime you add or remove rpms, re-runit.

Now on each node drop a .repo file pointing at your repository.

cat <<EOF_REPO > /etc/yum.repos.d/MyRepo.repo
[MyRepo]
name=MyRepo
baseurl=http://repo.example.com/MyRepo
enabled=1
gpgcheck=0
EOF_REPO

You can also make a hierarchy like /path/to/repo/MyRepo/5/x86_64 and in the .repo file’s baseurl directive add something like:
baseurl=http://repo.example.com/MyRepo/$releasever/$basearch
will exapnd to http://repo.example.com/MyRepo/5/x86_64.

Now, you may want to setup priorities. If you want to host RPMs for stuff that may also be in other repos there may be conflicts. You can enforce a policy using yum priorities as to which repo wins out.

yum -y install yum-priorities

Then in your repo files set a priority, 1-99 (1 having the highest priority) where repos with no priroty set defaults to 99.

In my internal repo I set it to priority=1 and the MySQL 5.5.21 RPMs we grabbed from Oracle win out over the 5.0.95 RPMs in the CentOS updates repo.

There are a lot of more fun options but the stuff above should be just enough to get you going.

댓글 남기기

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin