Applies To:
Red Hat Enterprise Linux Versions 5.x and 6.x
Oracle Enterprise Linux Versions 5.x and 6.x
Problem:
To deploy systems or software quickly from a central repository using the release image provided from our Enterprise Linux vendor.
Solution:
NOTE: This example is using Red Hat Entperise Linux version 5.x but the methods are applicable across Enterprise Linux offerings.
The recommended configuration is to serve the files over http using an Apache server (package name: httpd).
This article will discuss hosting the repository files from a local filesystem storage. While other options to host repository files exist, they are outside of the scope of this article. Using local filesystem storage is our recommendation for the combination of speed and simplicity of maintenance.
- One of the requirements is to have the DVD image mounted either by physical media or by ISO image.
- In order to mount the DVD, insert the DVD into the server and it should auto-mount into the /media directory.
- In order to mount an ISO image we will need to run the following command as root, substituting the path name of your ISO image for the field "myISO.iso":
- mkdir /media/myISO
- mount -o loop myISO.iso /media/myISO
- In order to install and configure the http daemon we will first need to configure the machine that will host the repository for all other machines to use the DVD image locally. Create the file /etc/yum.repos.d/local.repo and input the following:
[local]
name=Local Repository
baseurl=file:///media/myISO/Server/
gpgcheck=0
enabled=0
- Now we will install the Apache service daemon with the following command which will also temporarily enable the local repository for dependency resolution:
yum -y install httpd --enablerepo=local
- Once the Apache service daemon is installed, start the service and set it to start up for us next time we reboot. Run the following commands as root:
- service httpd start
- chkconfig httpd on
- In order to use Apache to serve out the repository we will need to copy the contents of the DVD mount into a published web directory, run the following commands as root (make sure to switch myISO with the name of your ISO as we did in the previous command:
- mkdir /var/www/html/myISO
- cp -R /media/myISO/* /var/www/html/myISO
NOTE: The command "createrepo" is often used for creating custom repositories, but it is not required as the DVD already holds the repository information required.
- The following step is only necessary if you are running SELinux on the server that will be hosting the repository. The following command should be run as root and will restore the appropriate SELinux context to the files we just copied:
- restorecon -Rvv /var/www/html/
- The final step is to gather the DNS name or IP of the server that is hosting the repository. The DNS name or IP of the hosting server will be used to configure your yum repository repo file on the client server. The following is the listing of an example config using the RHEL 5.6 Server DVD and is held in the configuration file /etc/yum.repos.d/myRepo.repo
NOTE: Replace reposerver.mydomain.com with your server's DNS name or ip address
NOTE: You can also place this configuration file on the server hosting the repository for all other servers such that it can also use the repository as a more permanent solution to what was done in Step 2
[myRepo]
name=RHEL5.6 DVD
baseurl=http://reposerver.mydomain.com/myISO/Server
enabled=1
gpgcheck=0