Saturday, July 29, 2023

How to Configure Yum Server in RHEL/CentOS/Rocky Linux | Create Local Yum Server Configuration


To create a local YUM (Yellowdog Updater Modified) server, you'll need a system with access to the packages you want to host locally. This local server can then be used to distribute packages to other systems on the same network, improving installation and update speeds and reducing external internet dependencies. Here's a step-by-step guide to creating a local YUM server:

Steps To follow:

1 - Set Up a CentOS/RHEL System (or Similar) 

2 - Install Required Software 

3 - Prepare the Package Repository 

4 - Create the YUM Repository Metadata 

5 - Configure HTTP Server (Apache) 

6 -  Configure Firewall (if necessary) 

7 - Verify the YUM Repository

8 - Configure YUM Clients:

9 - Update YUM Cache on Clients

10 - Install Packages from Local Repository

 


  1. 1: Set Up a CentOS/RHEL System (or Similar):

  2. Choose a CentOS, Red Hat Enterprise Linux (RHEL), or a similar distribution as the base for your local YUM server. You can also use a virtual machine for this purpose.


  3. 2: Install Required Software: Open a terminal and make sure your system is up to date. Install the necessary packages:

    bash
    sudo yum update
    sudo yum install epel-release
    sudo yum install createrepo httpd

  4. 3: Prepare the Package Repository: Create a directory to store the RPM packages you want to make available via YUM. For example, you can use the following directory structure:

    bash
    sudo mkdir -p /var/www/html/local-yum/repo

    Copy or download the RPM packages you want to host into this directory.


  5. 4: Create the YUM Repository Metadata: Now, you need to generate metadata for the repository using the createrepo command. This metadata helps YUM clients understand the package dependencies and other information.

    bash
    sudo createrepo /var/www/html/local-yum/repo
  6. 5: Configure HTTP Server (Apache): Since YUM clients will access the repository over HTTP, you need to configure a web server. The most common choice is Apache.

    bash
    sudo systemctl start httpd
    sudo systemctl enable httpd
  7. 6: Configure Firewall (if necessary): If you have an active firewall, you need to open the HTTP port (port 80) to allow incoming connections.

    bash
    sudo firewall-cmd --add-service=http --permanent
    sudo firewall-cmd --reload
  8. 7: Verify the YUM Repository: At this point, your local YUM repository should be set up and accessible over HTTP. To verify it, open a web browser and go to http://your_server_ip/local-yum/repo/. You should see the repository's directory listing and the repodata folder containing the repository metadata.


  9. 8: Configure YUM Clients: On the client machines, create a .repo file in the /etc/yum.repos.d/ directory to configure YUM to use your local repository. For example:

    bash
    sudo vi /etc/yum.repos.d/local-yum.repo

    Add the following content to the file (replace your_server_ip with the IP address or hostname of your YUM server):

    makefile
    [local-yum]
    name=Local YUM Repository
    baseurl=http://your_server_ip/local-yum/repo
    enabled=1
    gpgcheck=0 # If you're not using GPG signing

    Save the file and exit the editor.


  10. 9: Update YUM Cache on Clients: On the client systems, update the YUM cache to include the new local repository:

    bash
    sudo yum clean all
    sudo yum makecache
  11. 10: Install Packages from Local Repository: Now, you can install packages from your local repository as you would with any other YUM repository:

bash
sudo yum install package_name

That's it! You now have a local YUM server that provides packages to your local network. Keep in mind that you'll need to regularly update the packages in your local repository to keep it up to date with the latest versions. Additionally, you can explore further configurations, such as setting up GPG signing for added security.

No comments:

Post a Comment

Installing Jenkins on RHEL 8 is a straightforward process. Here's a step-by-step guide

Introduction  Jenkins is an open-source automation server widely used for continuous integration (CI) and continuous delivery (CD) pipelines...