How to Setup a Network Repository to Install or Update Packages – Part 11

Configuring the Client Machine

You can add the configuration files for custom repositories in the /etc/yum.repos.d directory. Configuration files need to end in .repo and follow the same basic structure.

[repository_name]
Description
URL

Most likely, there will be already other .repo files in /etc/yum.repos.d. To properly test your repository, you can either delete those configuration files (not really recommended, since you may need them later) or rename them, as I did, by appending .orig to each file name:

# cd /etc/yum.repos.d
# for i in $(ls *.repo); do mv $i $i.orig; done
Backup Yum Repositories
Backup Yum Repositories

In our case, we will name our configuration file as tecmint.repo and insert the following lines:

[tecmint]
name=Example repo for Part 11 of the LFCE series on Tecmint.com
baseurl=http://192.168.0.17/repos/centos/6/6/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

In addition, we have enabled GPG signature-checking for all packages in our repository.

Using the Repository

Once the client has been properly configured, you can issue the usual yum commands to query the repository. Note how yum info subversion indicates that the information about the package is coming from our newly created repository:

# yum info subversion
Check Yum Repository Info
Check Yum Repository Info

Or you can install or update an already installed package:

# yum { install | update } package

For example,

# yum update && yum install subversion
Yum Install Package
Yum Install Package

Keeping the Repository Up-to-date

To make sure our repository is always current, we need to synchronize it with the online repositories on a periodic basis. We can use rsync for this task as well (as explained in Part 6 of the LFCS series.

rsync allows us to synchronize two directories, one local and one remote). Run the rsync command that was used to initially download the repository through a cron job and you’re good to go. Remember to set the cron job to a time of the day when the update will not cause a negative impact in the available bandwidth.

For example, if you want to update your repository every day beginning at 2:30 AM:

30 2 * * * rsync -avz rsync://centos.ar.host-engine.com/6.6/os/x86_64/ /var/www/html/repos/centos/6/6/ 

Important: Make sure to execute above command on the CentOS 7 server to keep your repository.

Of course, you can put that line inside a script to do more complex and customized tasks before or after performing the update. Feel free to experiment and tell me about the results.

Conclusion

You should never underestimate the importance of a local or network repository given the many benefits it brings as I explained in this article. If you can afford the disk space, this is definitely the way to go. I look forward to hearing from you and don’t hesitate to let me know if you have any questions.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

28 thoughts on “How to Setup a Network Repository to Install or Update Packages – Part 11”

    • @Ricardo,

      First you need to set proxy connection settings in your exports path as shown.

      # export HTTP_PROXY=http://user:[email protected]:8080
      

      Then you can tell that you want rsync to use below proxy settings for its traffic.

      # RSYNC_PROXY=user:[email protected]:8080
      

      You can modify the above command as per your proxy connection requirements (some do not need user/password)

      Finally you run your rsync job.

      Reply
  1. Hi, I’m afraid your instructions are not correct. You must not use createrepo to create the repodata, but instead you should use the repodata you get from the mirror you sync from.

    If you create the repodata yourself, you will break the GPG signing of repomd.xml (see repomd.xml.asc). Please remove all references to “createrepo‘”.

    For those thinking of setting up a public CentOS mirror based on this blog posting, you should sync everything with one rsync command, and not by individual version or repository. In this case the -H (preserve hard links) rsync option would save you some bandwidth and hard disk space.

    Best regards, avij on behalf of the CentOS Linux Project.

    Reply
  2. Dear Tecmint Team,

    Thanks for your support with reference to Hadoop and Maria DB. Good Article and very good for a beginner like me. I request to kindly help me with the article for creation Installation and usage of Active Directory Services for Centos 7 64bit Server and Centos 7 64bit Client.(i.e i should communicate with Centos 7 Server with Centos 7 Client).

    Please help
    Thanks and Regards
    Dinakar N K

    Reply
  3. It’s important to remember that after you setup your rsync in cron, you also need to update the repo, may be include the update command after the rsync in cron.

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.