How to set up a yum repository on CentOS 6
Do you maintain a bank of servers that all need a common set of RPM packages when initially configured? You can maintain a local Yellowdog Updater, Modified (YUM) repository with the latest releases and speed up installations by not having to go to the public Internet to fetch the latest packages. Once configured and mounted, each new server then just fetches the necessary RPM packages from the locally configured repository.
|DIFFICULTY||Basic - 1 | Medium - 2 | Advanced - 3|
|TIME REQUIRED||20 min|
|RELATED PRODUCTS||CentOS-based VPS or dedicated servers|
For starters, you need to install the createrepo package as root.
You'll be shown a list of packages to install, including any dependencies. When prompted with:
answer with a 'y' (without the quotes) and press Enter/Carriage return.
You'll see the previously listed packages installed.
Once you have createrepo installed, you need to prep the local repository directory (change /myrepo to your desired location):
Then, place the RPM files to cache into that directory (replacing files and /myrepo with appropriate names).
The createrepo command needs to create a database of information for the cached files. Change to that directory and run the following createrepo command (use your directory name instead of /myrepo):
createrepo --database /myrepo
Lastly, you need to create the YUM repository configuration file to reference the local resource. These files are located in /etc/yum.repos.d/. These files must have a .repo extension. Pick your favorite editor if you don't like vi. Pick an appropriate name for the package filename.
The minimum information necessary is the name to use with the yum command found within square brackets, and the name, baseurl, enabled, and gpgcheck properties. The filename doesn't need to match the name within square brackets, though it is helpful for editing later. And make sure the baseurl points to the right directory. There needs to be three / characters after the file: protocol in the URL.
Save the file and your new repository is all set.