文/一觉亮天
Yum is a tool of RHEL for automating installation process of packages. As we all know, we can install packages using rpm command. But many rpm packages depend on other packages, and the depended packages may also depend on others. If it is up to the user to resolve the dependencies, it is a painful job. Fortunately there is yum.
If your RHEL release can get formal support of Red Hat, i.e. if you get a code to connect to Redhat Network, you can install any package via just “yum install package-name”. If you don’t, or if you don’t have an internet connection but you have a list of rpms locally, you can build your own yum packages repository.
The steps for building yum repository
Step1 createrepo
Yum repository can be provided via HTTP, FTP, or local file system. Say your rpms are put in /root/rpmpackages directory. You need first create repository descriptions of these rpms. Use the command followed,
createrepo /root/rpmpackages
Step2 put your repository into use
Yum’s config file is /etc/yum.conf. You can change /etc/yum.conf/gpgcheck to 0 for omitting the steps to check rightness of packages. Repository description files go into /etc/yum.repos.d/.
Repository description file is a file with “.repo” extention. An example “.repo” file followed. The key field in the “.repo” file is “baseurl”. It indicates the location of the repository. The urls can be http or ftp and so on. The “enabled” field indicates whether the repository is put into use.
Usually we get a RHEL CD disk. There are rpm packages in it. In the example file followed, I also add repository of the standard RHEL CD disk, because we often need to get dependency packages from it. (Take CD disk RHEL5.5 as example.)
#example.repo
[repo-name-specify-as-you-like]
name=description
baseurl=file:///root/rpmpackages
enabled=1
[rhel-svr]
name=rhel-svr
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=0
[rhel-vt]
name=rhel-vt
baseurl=file:///mnt/cdrom/VT
enabled=1
gpgcheck=0
[rhel-clstr]
name=rhel-clstr
baseurl=file:///mnt/cdrom/Cluster
enabled=1
gpgcheck=0
[rhel-cs]
name=rhel-cs
baseurl=file:///mnt/cdrom/ClusterStorage
enabled=1
gpgcheck=0
Use yum to install packages
You can use yum to install packages through “yum install package-name”.
You can use yum to install a group of packages, too. Use “yum grouplist” to get the predefined groups in the current repositories. Use “yum groupinstall” to install a cluster of packages. How to make a installation group is beyond the scope of the article.