danieldk
07-11-2006, 05:17 PM
This is my short CentOS/YUM HOWTO that I have originally posted on the Libranet forum.
Getting close and fast mirrors
After the installation of CentOS, it is a good idea to get the new CentOS YUM configuration (this applies to CentOS 4.2, 4.3 contains the new YUM configuration). This new configuration will automatically pick a close mirror, based on your IP address. The new YUM configuration can be installed with:
yum update centos-yumconf
This can even be speeded up further by installing the fastest mirror plugin, which will pick the fastest mirror based on ping times. First install this plugin:
yum install yum-plugin-fastestmirror
Now you have to enable YUM plugins, by adding the "plugins=1" line to /etc/yum.conf:
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=centos-release
tolerant=1
exactarch=1
retries=20
obsoletes=1
gpgcheck=1
plugins=1
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
Now, you can pull in all security and reliability updates with the speed of light (or your broadband connection) :):
yum update
Using the RPMForge repository
The CentOS with the CentOS repositories are quite extensive, but not extensive enough Smile. So, it is a good idea to install use the RPMForge repositories, which includes Dag Wieer's repository. Before you do this, it is a good idea to install the 'protectbase' plugin. This is a bit like nifty pinning, it will make sure that packages from protected repositories are never updated with packages from other repositories. I like this, because it allows you to keep the stable tried and tested CentOS, rather than external updates.
Installing the plugin is easy:
yum install yum-plugin-protectbase
Now you have to configure which repositories should be protected. I usually protect the base CentOS repositories. To do this, open up the emacs /etc/yum.repos.d/CentOS-Base.repo file, and add the line "protect=1" to repositories that should be protected:
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
#released updates
[update]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
Pfew :). Time to use the RPMForge repository, this is easy, because the repository files are nicely packaged in an RPM file. The latest RPMForge package can always be grabbed from: http://rpmforge.net/user/packages/rpmforge-release/
Use the package for Red Hat Enterprise Linux 4 for your platform. For example, on x86 you can install it with:
wget http://apt.sw.be/redhat/el4/en/i386/RPMS.dag/rpmforge-release-0.2-2.2.el4.rf.i386.rpm
rpm -Uvh rpmforge-release-0.2-2.2.el4.rf.i386.rpm
That's it!
Useful YUM commands
Some useful YUM commands:
yum install - install a package by name, for instance: yum install mpg321
yum list - search a package by name and wildcard, for instance yum list *sqlite*
yum search - search a package by package description, for instance yum search parser
yum info - get information about a package, for instance yum info mpg321
yum localinstall - install an RPM, and try to fetch dependencies that are not installed from the known repositories, for instance yum localinstall VMWare-yadda-yadda.rpm
Of course, there's also APT for CentOS, but I don't use it ;).
Getting close and fast mirrors
After the installation of CentOS, it is a good idea to get the new CentOS YUM configuration (this applies to CentOS 4.2, 4.3 contains the new YUM configuration). This new configuration will automatically pick a close mirror, based on your IP address. The new YUM configuration can be installed with:
yum update centos-yumconf
This can even be speeded up further by installing the fastest mirror plugin, which will pick the fastest mirror based on ping times. First install this plugin:
yum install yum-plugin-fastestmirror
Now you have to enable YUM plugins, by adding the "plugins=1" line to /etc/yum.conf:
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=centos-release
tolerant=1
exactarch=1
retries=20
obsoletes=1
gpgcheck=1
plugins=1
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
Now, you can pull in all security and reliability updates with the speed of light (or your broadband connection) :):
yum update
Using the RPMForge repository
The CentOS with the CentOS repositories are quite extensive, but not extensive enough Smile. So, it is a good idea to install use the RPMForge repositories, which includes Dag Wieer's repository. Before you do this, it is a good idea to install the 'protectbase' plugin. This is a bit like nifty pinning, it will make sure that packages from protected repositories are never updated with packages from other repositories. I like this, because it allows you to keep the stable tried and tested CentOS, rather than external updates.
Installing the plugin is easy:
yum install yum-plugin-protectbase
Now you have to configure which repositories should be protected. I usually protect the base CentOS repositories. To do this, open up the emacs /etc/yum.repos.d/CentOS-Base.repo file, and add the line "protect=1" to repositories that should be protected:
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
#released updates
[update]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
Pfew :). Time to use the RPMForge repository, this is easy, because the repository files are nicely packaged in an RPM file. The latest RPMForge package can always be grabbed from: http://rpmforge.net/user/packages/rpmforge-release/
Use the package for Red Hat Enterprise Linux 4 for your platform. For example, on x86 you can install it with:
wget http://apt.sw.be/redhat/el4/en/i386/RPMS.dag/rpmforge-release-0.2-2.2.el4.rf.i386.rpm
rpm -Uvh rpmforge-release-0.2-2.2.el4.rf.i386.rpm
That's it!
Useful YUM commands
Some useful YUM commands:
yum install - install a package by name, for instance: yum install mpg321
yum list - search a package by name and wildcard, for instance yum list *sqlite*
yum search - search a package by package description, for instance yum search parser
yum info - get information about a package, for instance yum info mpg321
yum localinstall - install an RPM, and try to fetch dependencies that are not installed from the known repositories, for instance yum localinstall VMWare-yadda-yadda.rpm
Of course, there's also APT for CentOS, but I don't use it ;).