YUM Repositories are warehouses of RPM package files. RPM file is a Red Hat Package Manager file and enables quick and easy software installation on Red Hat/CentOS Linux distributions. YUM Repositories hold a number of RPM package files and enable your server to download and new software. YUM Repositories can hold RPM package files locally or remotely (FTP, HTTP or HTTPS). YUM configuration files hold the information required to successfully find and install RPM packages files on your system. YUM automatically resolves dependencies when installing RPM package files.
YUM Repository Configuration File
You can install new software on Red Hat/CentOS Linux with “yum install package” console command. This command checks for existing YUM Repository configuration files in /etc/yum.repos.d/ directory. YUM Repository configuration files hold the information required to download and install new software on your system.
YUM Repository configuration files must:
- be located in /etc/yum.repos.d/ directory
- have .repo extension, to be recognized by YUM
Available YUM Repository configuration file options are:
- Repository ID – One word unique repository ID (example: [examplerepo])
- Name – Human readable name of the repository (example: name=Example Repository)
- Baseurl – URL to the repodata directory. You can use file://path if repository is located locally or ftp://link, http://link, https://link if repository is located remotely – HTTP Authentication available http://user:email@example.com/repo1 (example: baseurl=http://mirror.cisp.com/CentOS/6/os/i386/)
- Enabled – Enable repository when performing updates and installs (example: enabled=1)
- Gpgcheck – Enable/disable GPG signature checking (example: gpgcheck=1)
- Gpgkey – URL to the GPG key (example: gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6)
- Exclude – List of the packages to exclude (example: exclude=httpd,mod_ssl)
- Includepkgs – List of the packages to include (example: include=kernel)
Example YUM Repository Configuration file:
[examplerepo] name=Example Repository baseurl=http://mirror.cisp.com/CentOS/6/os/i386/ enabled=1 gpgcheck=1 gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6
Custom YUM Repository
If we have a number of RPM package files and want to install it with “yum install” command, since this way software dependencies are automatically resolved, we must create our own “Custom” YUM Repository. This Repository will contain only the RPM package files we decide to include in it.
Step 1: Install “createrepo”
To create Custom YUM Repository we need to install a software called “createrepo” on our system. We can install “createrepo” software by running the following command from console:
yum install createrepo
Step 2: Create directory
Next we need to create a new directory that will contain the desired RPM package files. We can do this with the following command from console (you can choose a different directory name):
Step 3: Put RPM files into directory
Transfer/Copy/Move all of the desired RPM package files into the newly created directory from Step 2.
Step 4: Run “createrepo”
Createrepo command reads through Custom YUM Repository directory from Step 2 and creates a new directory in it called “repodata”. Repodata directory holds the metadata for the newly created repository.
Step 5: Create YUM Repository Configuration file
To start using the newly created Custom YUM Repository we must create YUM Repository Configuration file with .repo extension, which must be placed to /etc/yum.repos.d/ directory. Instructions on creating YUM Repository Configuration file were covered in the first topic of this article “YUM Repository Configuration File”.
Example Custom YUM Repository Configuration file:
[customrepo] name=Custom Repository baseurl=file:///repository1/ enabled=1 gpgcheck=0
CentOS DVD ISO YUM Repository
CentOS DVD ISO holds a large number of software (RPM package files) which are available for install during Red Hat/CentOS installation wizard. We can also use RPM package files from CentOS DVD ISO and create CentOS DVD ISO YUM Repository. This way we can install all of the software available on CentOS DVD ISO with “yum install” command from server console after we have already completed Red Hat/CentOS installation wizard.
Step 1: Download/Transfer CentOS DVD ISO to server
We need to download or transfer CentOS DVD ISO to your server:
- Transfer – If you have already downloaded CentOS DVD ISO to a machine different than your server, you will probably need to transfer it via FTP or SSH. You can do this with software like WinSCP (free SFTP client and FTP) or something similar.
- Download – You can usually download CentOS DVD ISO directly to your server with following console command (please change HTTP link accordingly):
Step 2: Mount CentOS DVD ISO
To see the CentOS DVD ISO we need to mount it. We usually mount CD-ROM, USB devices and ISO files to /mnt directory. To mount CentOS DVD ISO run the following command (please change /path/to/iso and /mnt accordingly):
mount -o loop /path/to/iso /mnt
Step 3: Create YUM Repository Configuration file
To start using the newly created CentOS DVD ISO YUM Repository we must create YUM Repository Configuration file with .repo extension, which must be placed to /etc/yum.repos.d/ directory. Instructions on creating YUM Repository Configuration file were covered in the first topic of this article “YUM Repository Configuration File”.
Example CentOS DVD ISO YUM Repository Configuration file:
[centosdvdiso] name=CentOS DVD ISO baseurl=file:///mnt enabled=1 gpgcheck=1 gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-6
This post was written by GeekPeek.Net and first appeared on DigitalOcean!