• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Create yum Repository in CentOS/RHEL

by admin

1. Create a directory for you local repository, e.g. /home/mypackage_dir/repository. Move the RPMs into that directory.

# mkdir /home/mypackage_dir/repository
# cp /media/packages/* /home/mypackage_dir/repo

2. Fix some ownership and filesystem permissions:

# chown -R root:root /home/mypackage_dir/repo

3. Install the createrepo package if not installed yet, and run:

# createrepo /home/mypackage_dir/repo
# chmod -R o-w+r /home/mypackage_dir/repo

4. Create a repository configuration file, e.g. /etc/yum.repos.d/customrepo.repo containing:

# vi /etc/yum.repos.d/customrepo.repo
[local]
name=My RPM System Package Repo
baseurl=file:///home/mypackage_dir/repository
enabled=1
gpgcheck=0

5. Install your package using yum command like below, replace package_name with the package you want to install and locate on mypackage_dir/repository:

# yum install package_name

Configuring repository over httpd

If there is a requirement to use the same repository on multiple nodes. Follow the instructions given below on each node where you need to install packages using the repository we just configured.

1. To use the yum repository configured on node1 on node2 through http url please follow the below instructions.

# yum install httpd
# ln -s /var/www/html/repo /home/mypackage_dir/repo
# service httpd start

2. Then in a webbrowser access the url http://[node1-ip]/repo. In node 2 configure .repo file as below.

[node1-repo]
name=My RPM System Package Repo
baseurl=http:///repo
enabled=1
gpgcheck=0

3. Then run the below command on node2 followed by yum update to update the machine.

# yum repolist

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. fprintd Logs Messages into /var/log/messages Even If USEFPRINTD=no in /etc/sysconfig/authconfig (CentOS/RHEL 7)
  2. Linux OS Service ‘avahi-daemon’
  3. grub-install: command not found
  4. apt Command Examples in Linux
  5. CentOS / RHEL 7 : How to reinstall GRUB2 from rescue mode
  6. chsh: command not found
  7. getenforce: command not found
  8. How To Add/Remove Locale Archive in CentOS/RHEL 5,6
  9. CentOS / RHEL : How to install Open Virtual Machine Tools for Virtual machines Hosted on VMWare
  10. How to configure NTP server and client in CentOS / RHEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright