Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Setting Up a yum Repository

Use the createrepo command to create a repository from a directory holding the packages you want in it. Then it is a simple matter of providing a configuration file for it and specifying its location.

A working RHEL repository requires a combination of the existing installation packages, as well as the updates available over the Red Hat Network. When combined, you’ll have a set of packages that includes all the dependencies you might need.

The repository creation process on an RHEL system requires four basic steps:

  1. Download the packages required to update your system; make sure they aren’t deleted after they’re installed. Add the packages associated with the RHEL installation CDs.
  2. Apply the yum-arch or createrepo commands to "yummify" the repository.
  3. Share the repository directory with an appropriate service, such as Apache, FTP, or NFS.
  4. Configure your clients to update from the new repository.

Depending on the channels you want to mirror, this process may require 2GB or more of downloads. If you have only one or two RHEL systems, you may find this process not to be worth the trouble. However, if you have several dozen RHEL systems, this might save you time and bandwidth.

If you have a substantial number of RHEL systems, you should consider the Red Hat Network Proxy Server described in Chapter 2. However, if you prefer standard tools, such as yum, and have the authorized Red Hat subscriptions for the RHEL clients on your network, you the approach taken in the following sections is a viable alternative.

NOTE

If you’re working with a RHEL rebuild distribution, it’s best if you use the patch management tool (yum or apt) configured for that distribution. Then you can keep it up to date by synchronizing your repository with that available from the mirror of your choice.

Generating metadata

Yum doesn’t download all of a repo’s RPMs to see what is available. Instead, it fetches special metadata files that explain what a given repo offers.

Use the createrepo command to create metadata files for your repo. (Install the createrepo RPM on the machine that will host the yum repos, if it isn’t already there.) You run createrepo on each would-be repo. For example:

## create a repo of our OS updates mirror
createrepo /path/to/FC5/i386/os-updates

## ... then one for our Fedora Extras mirror
createrepo /path/to/FC5/i386/fedora_extras

## ... and wrap up with our internal copy of livna.org's offerings
createrepo /path/to/FC5/i386/livna.org

createrepo will recursively scan the specified directory for RPM files and extract metadata into XML files. It stores those XML files in a subdirectory repodata just below the specified directory.

Each repodata directory represents a single repo. In the above example, there are three repos for Fedora Core 6, i386 architecture: os-updates, fedora_extras, and livna.org. Have no fear: you don’t have to manually point yum to each individual repo. You can configure yum to search several repos at once. Subdividing them as I have demonstrated helps you keep track of a given package’s source.

Creating a RHEL Update Repository

With the right configuration, you can save the updated RPMs as an RHEL update repository. There are several basic steps in this process:

  1. First, log into the Red Hat Network and assign desired channels to the RHEL Update Repository system.
  2. Next, configure the Update Agent to keep downloaded packages.
  3. Configure the system where you’ll store packages as needed.
  4. Download desired RPMs into your repository.
  5. Add RPMs from the installation CDs.

Assign Desired Channels from the Red Hat Network

First, log into the Red Hat Network. Make sure your system is subscribed to the channels from which you want to create your repository.

you can configure your system with available channels, assuming that you have allowed subscriptions to that channel. To find your currently allowed subscriptions, click Channels on the top bar, then click Channel Entitlements on the left pane. Assign the channels of your choice, and then click Change Subscriptions. If you see the following error message, you may need additional subscriptions:

The assignment would exceed your allowed subscriptions in one or more channels

To confirm your channel assignments, log into the computer that you intend to use as the repository. The following command should return the channels that you’ve assigned:

up2date --showchannel 

Based on Figure 7-5, the channels that you should see are as follows:

rhel-i386-as-4
rhel-i386-as-4-extras
rhel-i386-as-4-hwcert
rhel-i386-as-4-sdk
rhn-tools-rhel-4-as-i386

Configure the Update Agent to Keep Downloaded RPMs

Log into the computer that you intend to use as a repository. Updated RPMs are stored by default in the /var/spool/up2date directory. Make sure that updated RPMs are not deleted. To do so, run the up2date-config command. You’ll see the screen shown in

Enter option 17 (the option number may vary). This is associated with the "keepAfterInstall" variable. If set to yes, packages which are downloaded remain available in /var/spool/up2date after they’re installed. The next time you download packages from the Red Hat Network, packages will be stored in that directory, and they won’t be deleted.

NOTE

You may also want to disable automatic updates to the up2date RPM, which is usually the option before keepAfterInstall. Any updates to up2date substitutes the default settings in /etc/sysconfig/rhn/up2date. If the up2date RPM is upgraded, you can restore your custom settings from the up2date.rpmnew file in the same directory. Just be aware, if you disable updates of up2date, updates will be disabled the next time there’s a new version of up2date available.

Configure the Repository with Appropriate Partitions

As you’ve seen throughout this book, repositories require gigabytes of space. It often makes sense to configure repositories in separate partitions. For the purpose of this repository, I’ve configured /var/spool/up2date on a new partition or logical volume.

For details on how you can configure a new partition, refer to any good basic book on Linux administration, including Linux Administration Handbook by Evi Nemeth, Garth Snyder, and Trent Hein (Upper Saddle River, NJ: Prentice Hall, 2002) or Mastering Red Hat Enterprise Linux 3 by Michael Jang (Alameda, CA: Sybex, 2004) . If you want more information on these commands or settings, refer to that book. If you have free space on an available partition, you can assign it to /var/spool/up2date. One method would use the following steps, which assume that you’ve added a new hard drive. The steps may vary widely depending on the hard drive and whether there are existing partitions on that drive.

  1. Open the hard disk of your choice for editing. For example, assume you’ve added a new hard drive. If this drive is the first SCSI or SATA hard drive on your system, run the fdisk /dev/sda command.
  2. Assign a new partition with the n command. You’ll need to press p to assign a new primary partition. Assign partition number 1, start with the first cylinder, and assign the room you need. You can do so with a +10GB entry when prompted for the last cylinder. Press w to write the new partition table to the hard drive.
  3. Format the drive. To format it with the default ext3 file system, run the following command:
    mkfs -t ext3 /dev/sda1
  4. Mount the /var/spool/up2date directory on that drive.
    mount /dev/sda1 /var/spool/up2date
  5. Make sure the drive is mounted the next time you reboot your computer. Add the following line to your /etc/fstab configuration file:
    /dev/sda1 /var/spool/up2date ext3 defaults 1 2

Download Desired RPMs from the Repository

Now you can download the desired RPMs from the Red Hat Network. You can download just the updates, but because of dependencies, those might not be enough. Therefore, download all available RPMs from the Red Hat Network channels to which you subscribe. This is a multi-step process. With the following command (which specifies a RHEL 4 Workstation channel), you can download the RPMs from your desired channel not currently installed on your system. Shortly, you’ll add RPMs from your installation CDs.

up2date -d --installall --channel=rhel-i386-ws-4

There is no separate updates repository on the Red Hat Network. New packages are incorporated into existing channels. Therefore, this command downloads all packages you do not have installed, including any updated RPMs.

Naturally, because there are around 2GB of data on RHEL installation RPMs, the download may be extensive. Depending on the speed of your connection, you may need to wait several hours for downloads.

Add RPMs from the Installation CDs

Now you should add the RPMs from the RHEL installation CDs. If you have the physical CDs, the mount command is elementary. If you have the ISO files (as I do), the mount command requires a small trick. For example, when I’ve stored the ISOs on my /mnt/test partition, I can mount the first RHEL ISO with the following command:

mount -o loop /mnt/test/RHEL4-i386-AS-disc1.iso /media/cdrecorder

You can then copy the RPMs to the /var/spool/up2date directory with the following command:

cp -ar /media/cdrecorder/RedHat/RPMS/* /var/spool/up2date/

Naturally, when the process is complete with the first CD, you’ll want to unmount and repeat the process with the other RHEL CDs until you’ve copied all available RPMs to the /var/spool/up2date directory.

Yummifying the RHEL Update Repository

After you’ve configured the files you need in the RHEL repository, you can set it up as a yum repository. As described earlier in this chapter, this requires the yum-arch or createrepo commands, depending on your distribution. The createrepo package was adapted for Fedora Core 3. Because RHEL 4 was built from Fedora Core 3, we’ll use this package to "yummify" this repository.

If you haven’t already done so, install the yum and createrepo RPMs. As discussed earlier in this chapter, they are not currently available from RHEL 4 channels. However, compatible versions are available from Fedora Core 3 repositories. Download guidelines are described earlier in this chapter.

Now you can yummify your repository with one of the following commands, whichever is appropriate to your distribution:

yum-arch /var/spool/up2date
createrepo /var/spool/up2date

If successful, you’ll find headers/ or repodata/ subdirectories in the /var/spool/up2date directory. I’ve used the second command on my RHEL 4 system, with downloaded updates and installation RPMs that I’ve just described.

Sharing the RHEL Repository

Now you can share the RHEL 4 repository that you’ve just created. You can configure the Apache or NFS servers described earlier. Unfortunately, as described earlier, the vsFTP service does not follow symlinks, for the security reasons described earlier. In this case, we’ll configure the server that we did not configure before, the Apache Web Server. We won’t go into detail on how to configure Apache on your system; we’ll just create a basic configuration that you can use for a RHEL repository.

If you want more information on how you can configure Apache on RHEL, there are many excellent books available, including Apache Administrator’s Handbook by Rich Bowen (Indianapolis, IN: Sams Publishing, 2002).

In this case, I’ve just installed the httpd RPM package on RHEL 4. To make sure it works, start the daemon with the following command:

apachectl start

If you see a message related to "Could not determine the server’s fully qualified domain name," do not be concerned. There is no URL specified in the default version of the Apache configuration file, httpd.conf, in the /etc/httpd/conf directory.

Test the result. If you’re on the computer with the repository, open a browser and navigate to 127.0.0.1. If the service is working, you’ll see the Red Hat Enterprise Linux Test Page. Test the result on a remote computer. I’ve configured the repository computer with an URL of yum.example.com, and therefore can navigate to that URL to see the same test Web page.

By default, Apache files on this distribution are stored in the /var/www/html directory. You already have a repository in the /var/spool/up2date directory. To allow apache to work with the repository, you need to link directories. One method is with the following command:

ln -s /var/spool/up2date /var/www/html/up2date

If everything goes right, you should be able to navigate to the up2date/directory on the Apache server. In my case, I’ve navigated to http://yum.example.com/up2date/. However, that doesn’t work at first. I’ve started with the default RHEL 4 Apache configuration file. For more information, see the error_log in the /var/log/httpd directory. The key error message from this file is

Directory index forbidden by rule: /var/www/html/

To address this issue, I’ve modified the messages associated with the Apache root directory. The default configuration file includes the following stanza about 25 percent of the way into the file:

<Directory />
  Options FollowSymLinks
  AllowOverride None
</Directory>

The Options directive you need is Indexes, which leads me to substitute the following command line:

Options Indexes FollowSymLinks

Now, you can try the desired URL again.

Naturally, you can also share /var/spool/up2date with an NFS server by using the techniques described earlier in this chapter.

Configuring Updates to the RHEL Repository

After you’ve added the packages you need to /var/spool/up2date, it is up to you to maintain that RHEL repository. While the Red Hat Network does not include a rsync server, the effect from updates is essentially the same. You can repeat the same commands described earlier, and only new packages are downloaded. However, obsolete packages are not removed from the local mirror.

However, if you’ve copied all of the installation files to the /var/spool/up2date directory, this is not necessary. You just need the updated RPMs, which are available with the following command:

up2date -u

If you want to keep using /var/spool/up2date, make sure that you never restore the defaults associated with the Red Hat Update Agent. Otherwise, the updated RPMs would be deleted after the next update. (You may also want to disable upgrades to the up2date RPM, as described in an earlier note.)

7.6.5 Configuring Clients to Use the RHEL Repository

Naturally, if you’ve created a repository on a RHEL computer, you may want to use it for that computer. You’ve already downloaded and installed the yum RPM package. You can now create a configuration file in the /etc/yum.repos.d directory similar to those you’ve created in Chapter 6. In this case, the repository is local; therefore, you can specify the file:/// (that’s three forward slashes) label described earlier to point to the /var/spool/up2date directory.

For example, I’ve entered the following in the local.repo file in the /etc/yum.repos.d directory:

[local]
name=Mike’s local RHEL 4 repo
baseurl=file:///var/spool/up2date 
gpgcheck=1
enabled=1

Now I can use the yum commands described in Chapter 6 to update the system with the repository. Naturally, you can configure other RHEL 4 clients to use the same repository. Based on the Apache server configured earlier, I’ve modified the aforementioned local.repo file accordingly:

[local]
name=Mike’s local RHEL 4 repo
baseurl=http://yum.example.com/up2date 
gpgcheck=1
enabled=1

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Feb 18, 2020] Setup Local Yum Repository On CentOS 7

Aug 27, 2014 | www.unixmen.com

This tutorial describes how to setup a local Yum repository on CentOS 7 system. Also, the same steps should work on RHEL and Scientific Linux 7 systems too.

If you have to install software, security updates and fixes often in multiple systems in your local network, then having a local repository is an efficient way. Because all required packages are downloaded over the fast LAN connection from your local server, so that it will save your Internet bandwidth and reduces your annual cost of Internet.

In this tutorial, I use two systems as described below:

Yum Server OS         : CentOS 7 (Minimal Install)
Yum Server IP Address : 192.168.1.101
Client OS             : CentOS 7 (Minimal Install)
Client IP Address     : 192.168.1.102
Prerequisites

First, mount your CentOS 7 installation DVD. For example, let us mount the installation media on /mnt directory.

mount /dev/cdrom /mnt/

Now the CentOS installation DVD is mounted under /mnt directory. Next install vsftpd package and let the packages available over FTP to your local clients.

To do that change to /mnt/Packages directory:

cd /mnt/Packages/

Now install vsftpd package:

rpm -ivh vsftpd-3.0.2-9.el7.x86_64.rpm

Enable and start vsftpd service:

systemctl enable vsftpd
systemctl start vsftpd

We need a package called "createrepo" to create our local repository. So let us install it too.

If you did a minimal CentOS installation, then you might need to install the following dependencies first:

rpm -ivh libxml2-python-2.9.1-5.el7.x86_64.rpm 
rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm 
rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm

Now install "createrepo" package:

rpm -ivh createrepo-0.9.9-23.el7.noarch.rpm
Build Local Repository

It's time to build our local repository. Create a storage directory to store all packages from CentOS DVD's.

As I noted above, we are going to use a FTP server to serve all packages to client systems. So let us create a storage location in our FTP server pub directory.

mkdir /var/ftp/pub/localrepo

Now, copy all the files from CentOS DVD(s) i.e from /mnt/Packages/ directory to the "localrepo" directory:

cp -ar /mnt/Packages/*.* /var/ftp/pub/localrepo/

Again, mount the CentOS installation DVD 2 and copy all the files to /var/ftp/pub/localrepo directory.

Once you copied all the files, create a repository file called "localrepo.repo" under /etc/yum.repos.d/ directory and add the following lines into the file. You can name this file as per your liking:

vi /etc/yum.repos.d/localrepo.repo

Add the following lines:

[localrepo]
name=Unixmen Repository
baseurl=file:///var/ftp/pub/localrepo
gpgcheck=0
enabled=1

Note: Use three slashes(///) in the baseurl.

Now, start building local repository:

createrepo -v /var/ftp/pub/localrepo/

Now the repository building process will start.

Sample Output:

root@server:-mnt-Packages_002

Now, list out the repositories using the following command:

yum repolist

Sample Output:

repo id                                                                    repo name                                                                     status
base/7/x86_64                                                              CentOS-7 - Base                                                               8,465
extras/7/x86_64                                                            CentOS-7 - Extras                                                                30
localrepo                                                                  Unixmen Repository                                                            3,538
updates/7/x86_64                                                           CentOS-7 - Updates                                                              726

Clean the Yum cache and update the repository lists:

yum clean all
yum update

After creating the repository, disable or rename the existing repositories if you only want to install packages from the local repository itself.

Alternatively, you can install packages only from the local repository by mentioning the repository as shown below.

yum install --disablerepo="*" --enablerepo="localrepo" httpd

Sample Output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-17.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-17.el7.centos.1 for package: httpd-2.4.6-17.el7.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-17.el7.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
 Package                              Arch                            Version                                         Repository                          Size
===============================================================================================================================================================
Installing:
 httpd                                x86_64                          2.4.6-17.el7.centos.1                           localrepo                          2.7 M
Installing for dependencies:
 apr                                  x86_64                          1.4.8-3.el7                                     localrepo                          103 k
 apr-util                             x86_64                          1.5.2-6.el7                                     localrepo                           92 k
 httpd-tools                          x86_64                          2.4.6-17.el7.centos.1                           localrepo                           77 k
 mailcap                              noarch                          2.1.41-2.el7                                    localrepo                           31 k

Transaction Summary
===============================================================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Is this ok [y/d/N]:

Disable Firewall And SELinux:

As we are going to use the local repository only in our local area network, there is no need for firewall and SELinux. So, to reduce the complexity, I disabled both Firewalld and SELInux.

To disable the Firewalld, enter the following commands:

systemctl stop firewalld
systemctl disable firewalld

To disable SELinux, edit file /etc/sysconfig/selinux ,

vi /etc/sysconfig/selinux

Set SELINUX=disabled.

[...]
SELINUX=disabled
[...]

Reboot your server to take effect the changes.

Client Side Configuration

Now, go to your client systems. Create a new repository file as shown above under /etc/yum.repos.d/ directory.

vi /etc/yum.repos.d/localrepo.repo

and add the following contents:

[localrepo]
name=Unixmen Repository
baseurl=ftp://192.168.1.101/pub/localrepo
gpgcheck=0
enabled=1

Note: Use double slashes in the baseurl and 192.168.1.101 is yum server IP Address.

Now, list out the repositories using the following command:

yum repolist

Clean the Yum cache and update the repository lists:

yum clean all
yum update

Disable or rename the existing repositories if you only want to install packages from the server local repository itself.

Alternatively, you can install packages from the local repository by mentioning the repository as shown below.

yum install --disablerepo="*" --enablerepo="localrepo" httpd

Sample Output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-17.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-17.el7.centos.1 for package: httpd-2.4.6-17.el7.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-17.el7.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package          Arch        Version                      Repository      Size
================================================================================
Installing:
 httpd            x86_64      2.4.6-17.el7.centos.1        localrepo      2.7 M
Installing for dependencies:
 apr              x86_64      1.4.8-3.el7                  localrepo      103 k
 apr-util         x86_64      1.5.2-6.el7                  localrepo       92 k
 httpd-tools      x86_64      2.4.6-17.el7.centos.1        localrepo       77 k
 mailcap          noarch      2.1.41-2.el7                 localrepo       31 k

Transaction Summary
================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): apr-1.4.8-3.el7.x86_64.rpm                          | 103 kB   00:01     
(2/5): apr-util-1.5.2-6.el7.x86_64.rpm                     |  92 kB   00:01     
(3/5): httpd-tools-2.4.6-17.el7.centos.1.x86_64.rpm        |  77 kB   00:00     
(4/5): httpd-2.4.6-17.el7.centos.1.x86_64.rpm              | 2.7 MB   00:00     
(5/5): mailcap-2.1.41-2.el7.noarch.rpm                     |  31 kB   00:01     
--------------------------------------------------------------------------------
Total                                              1.0 MB/s | 3.0 MB  00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                       1/5 
  Installing : apr-util-1.5.2-6.el7.x86_64                                  2/5 
  Installing : httpd-tools-2.4.6-17.el7.centos.1.x86_64                     3/5 
  Installing : mailcap-2.1.41-2.el7.noarch                                  4/5 
  Installing : httpd-2.4.6-17.el7.centos.1.x86_64                           5/5 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                  1/5 
  Verifying  : httpd-2.4.6-17.el7.centos.1.x86_64                           2/5 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                  3/5 
  Verifying  : apr-1.4.8-3.el7.x86_64                                       4/5 
  Verifying  : httpd-tools-2.4.6-17.el7.centos.1.x86_64                     5/5 

Installed:
  httpd.x86_64 0:2.4.6-17.el7.centos.1                                          

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                      apr-util.x86_64 0:1.5.2-6.el7   
  httpd-tools.x86_64 0:2.4.6-17.el7.centos.1    mailcap.noarch 0:2.1.41-2.el7   

Complete!

That's it. Now, you will be able to install softwares from your server local repository.

Cheers!

[May 03, 2019] Creating a Redhat package repository

Apr 12, 2016 | linuxconfig.org
Details
Redhat
Introduction

If your Redhat server is not connected to the official RHN repositories, you will need to configure your own private repository which you can later use to install packages. The procedure of creating a Redhat repository is quite simple task. In this article we will show you how to create a local file Redhat repository as well as remote HTTP repository.

Using Official Redhat DVD as repository

After default installation and without registering your server to official RHN repositories your are left without any chance to install new packages from redhat repository as your repository list will show 0 entries:

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repolist: 0

At this point the easiest thing to do is to attach your Redhat installation DVD as a local repository. To do that, first make sure that your RHEL DVD is mounted:

# mount | grep iso9660
/dev/sr0 on /media/RHEL_6.4 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=500,gid=500,iocharset=utf8,mode=0400,dmode=0500)

The directory which most interests us at the moment is " /media/RHEL_6.4 x86_64 Disc 1/repodata " as this is the directory which contains information about all packages found on this particular DVD disc.

Next we need to define our new repository pointing to " /media/RHEL_6.4 x86_64 Disc 1/ " by creating a repository entry in /etc/yum.repos.d/. Create a new file called: /etc/yum.repos.d/RHEL_6.4_Disc.repo using vi editor and insert a following text:

[RHEL_6.4_Disc]
name=RHEL_6.4_x86_64_Disc
baseurl="file:///media/RHEL_6.4 x86_64 Disc 1/"
gpgcheck=0

Once file was created your local Redhat DVD repository should be ready to use:

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                                     repo name                                                           status
RHEL_6.4_Disc                                               RHEL_6.4_x86_64_Disc                                                3,648
repolist: 3,648

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.

me name=


Creating a local file Redhat repository

Normally having a Redhat DVD repository will be enough to get you started however, the only disadvantage is that you are not able to alter your repository in any way and thus not able to insert new/updated packages into it. The resolve this issue we can create a local file repository sitting somewhere on the filesystem. To aid us with this plan we will use a createrepo utility.

By default createrepo may not be installed on your system:

# yum list installed | grep createrepo
#

No output indicates that this packages is currently not present in your system. If you have followed a previous section on how to attach RHEL official DVD as your system's repository, then to install createrepo package simply execute:

# yum install createrepo

The above command will install createrepo utility along with all prerequisites. In case that you do not have your repository defined yet, you can install createrepo manually:

Using your mounted RedHat DVD first install prerequisites:

# rpm -hiv /media/RHEL_6.4\ x86_64\ Disc\ 1/Packages/deltarpm-*
# rpm -hiv /media/RHEL_6.4\ x86_64\ Disc\ 1/Packages/python-deltarpm-*

followed by the installation of the actual createrepo package:

# rpm -hiv /media/RHEL_6.4\ x86_64\ Disc\ 1/Packages/createrepo-*

If all went well you should be able to see createrepo package installed in your system:

# yum list installed | grep createrepo
createrepo.noarch                        0.9.9-17.el6                          installed

At this stage we are ready to create our own Redhat local file repository. Create a new directory called /rhel_repo:

# mkdir /rhel_repo

Next, copy all packages from your mounted RHEL DVD to your new directory:

# cp /media/RHEL_6.4\ x86_64\ Disc\ 1/Packages/* /rhel_repo/

When copy is finished execute createrepo command with a single argument which is your new local repository directory name:

# createrepo /rhel_repo/
Spawning worker 0 with 3648 pkgs
Workers Finished
Gathering worker results

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

You are also able to create Redhat repository on any debian-like Linux system such as Debian, Ubuntu or mint. The procedure is the same except that installation of createrepo utility will be: # apt-get install createrepo


me name=


As a last step we will create a new yum repository entry:

# vi /etc/yum.repos.d/rhel_repo.repo
[rhel_repo]
name=RHEL_6.4_x86_64_Local
baseurl="file:///rhel_repo/"
gpgcheck=0

Your new repository should now be accessible:

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel_repo                                                                                                      | 2.9 kB     00:00 ... 
rhel_repo/primary_db                                                                                           | 367 kB     00:00 ... 
repo id                                                     repo name                                                           status
RHEL_6.4_Disc                                               RHEL_6.4_x86_64_Disc                                                3,648
rhel_repo                                                   RHEL_6.4_x86_64_Local                                                 3,648
Creating a remote HTTP Redhat repository

If you have multiple Redhat servers you may want to create a single Redhat repository accessible by all other servers on the network. For this you will need apache web server. Detailed installation and configuration of Apache web server is beyond the scope of this guide therefore, we assume that your httpd daemon ( Apache webserver ) is already configured. In order to make your new repository accessible via http configure your apache with /rhel_repo/ directory created in previous section as document root directory or simply copy entire directory to: /var/www/html/ ( default document root ).

Then create a new yum repository entry on your client system by creating a new repo configuration file:

vi /etc/yum.repos.d/rhel_http_repo.repo

with a following content, where my host is a IP address or hostname of your Redhat repository server:

[rhel_repo_http]
name=RHEL_6.4_x86_64_HTTP
baseurl="http://myhost/rhel_repo/"
gpgcheck=0

Confirm the correctness of your new repository by:

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                                      repo name                                                          status
rhel_repo_http                                               RHEL_6.4_x86_64_HTTP                                               3,648
repolist: 3,648
Conclusion

Creating your own package repository gives you more options on how to manage packages on your Redhat system even without paid RHN subscription. When using a remote HTTP Redhat repository you may also want to configure GPGCHECK as part of your repository to make sure that no packages had been tampered to prior their installation.

[Feb 08, 2017] Create your own private yum repository.

Notable quotes:
"... /var/ftp/repo/Fedora/10/i386 ..."
"... /var/ftp/repo/Fedora/10/x86_64 ..."
"... /var/ftp/repo/Fedora/10/SRPMS ..."
"... create-my-repo ..."
"... /var/ftp/repo/Fedora/10/i386 ..."
"... /var/ftp/repo/Fedora/10/x86_64 ..."
"... ftp://internalhost.com/repo/Fedora/10/i386 ..."
"... /etc/yum.repos.d/my.repo ..."
Feb 08, 2017 | linuxservconf.blogspot.com

Sometimes, especially when you create your own RPMs, it is extremely useful to keep them in a local YUM repository . The advantage of this is that, when you install a package, YUM automatically resolves any dependencies, not only by downloading the necessary packages from the other repositories you might have in you list, but also by using your local repo as a resource for potential dependencies.

So, when installing a package (eg my_package.rpm ) with YUM, you are supposed to have already created RPM packages for all of the my_package.rpm 's dependencies and to have updated the repository's metadata, so that yum is able to resolve all the dependencies. If these dependencies do not exist in any of the repositories in your list, then, in short, you cannot install your package with yum.

So, in order to install an RPM package and all the other packages that it depends on, you only need to run:

# yum install my_package.rpm

How to create a local YUM repo ?

You will need an utility, named createrepo . Its RPM package exists in Fedora Extras. To install it, just run as root:

Terminal
# yum install createrepo

Then, put all your custom RPM packages in a directory. Assuming that this directory is /path/to/repository , you can create all the necessary metadata for your local repository by running the following command as root or as the user that owns the directory:

Terminal
# createrepo -v /path/to/directory

That's it! Your local YUM repository is ready.

Keep in mind that every time you put any new RPMs in that directory or remove any old RPMs, you will need to run the above command again, so that the repository metadata gets updated.

Add your local repo to the list

The next thing you need to do is to add your local repository to your list of repos, so that yum knows where to find it. This info is kept in the /etc/yum.repos.d/ directory. As root, create a new text file in this directory, name it fedora-local.repo (you can use any name you like, but remember to add the extension .repo ), and add the following info in it:

Terminal
[[email protected]~]# cat /etc/yum.repos.d/fedora-local.repo
[localrepo]
name=[give any name you like without the square brackets ofcourse]
baseurl=[file:| ftp | http |<path to the repository>]
enabled=1
gpgcheck=0


In Order to access the repository over ftp or http the urls should be modified as follows
baseurl=http://server1.example.com/path/to/repository
or
baseurl=ftp://server1.example.com/path/to/repository

As you can see, we used the protocol file:/// in the baseurl option. This assumes that the local repo exists in the local machine. If it exists in another machine of your internal network, feel free to use any other protocol in order to tell yum where to find your local repository, For example you can use http:// , ftp:// , smb:// etc.

In the above example, the GPG key check is disabled ( gpgcheck=0 ). If you sign your packages, you can set this to " 1 " and uncomment the following line ( gpgkey=... ). This contains the path to your public key, so that YUM can verify the package signatures.

You can have as many local YUM repositories as you like.

Other uses of a local repository

Using a local repository does not only serve as a place for your custom RPMs. You can perfectly save some bandwidth by downloading all the released fedora updates in that repo and use this to update all the systems of your internal network. This will save bandwidth and time.

The Procedure is the same for all RPM based systems, using YUM Package Manager. So this can be applied to Fedora, Redhat and CentOS systems

Create your own yum repository - TechRepublic

The standard RPM package management tool in Fedora, Red Hat Enterprise Linux, and CentOS is the yum package manager. Yum works quite well, if a little bit slower than other RPM package managers like apt4rpm and urpmi, but it is solid and handles dependencies extremely well. Using it with official and third-party repositories is a breeze to set up, but what if you want to use your own repository? Perhaps you manage a large computer lab or network and need to have - or want to have - certain packages available to these systems that you maintain in-house. Or perhaps you simply want to set up your own repository to share a few RPM packages with the world or just your friends.

Creating your own yum repository is very simple, and very straightforward. In order to do it, you need the createrepo tool, which can be found in the createrepo package, so to install it, execute as root:

# yum install createrepo

Once the package is installed, you can begin creating your repository. You will also need some RPM packages to create the repository with. Decide where you want to store your repository; let's say, /var/ftp/repo will be the base directory.

Depending on how particular you want to get, you can dump everything to a single repository or keep things organized. I'm a big fan of organization, so let's assume you will be creating a repository for Fedora 10 and have both i386 and x86_64 packages you want to be made available with it. I would create an appropriate directory tree using the following commands:

# mkdir -p /var/ftp/repo/Fedora/10/{SRPMS,i386,x86_64}

Now copy your i386 packages to /var/ftp/repo/Fedora/10/i386 , your x86_64 packages to /var/ftp/repo/Fedora/10/x86_64 , and the SRPMS you have (if wanted) to /var/ftp/repo/Fedora/10/SRPMS . To easily automate the creation of the repository metadata, create a shell script called create-my-repo and place it somewhere in your PATH:

#!/bin/sh
destdir="/var/ftp/repo/Fedora/10"
for arch in i386 x86_64
do
    pushd ${destdir}/${arch} >/dev/null 2>&1
        createrepo .
    popd >/dev/null 2>&1
done

Make the script executable and whenever you run it, it will call the createrepo tool on the two directories: /var/ftp/repo/Fedora/10/i386 and /var/ftp/repo/Fedora/10/x86_64 . Once this is done, your repository is ready for use.

If /var/ftp is the available FTP root, then ftp://internalhost.com/repo/Fedora/10/i386 would be the download URL for the i386 packages. To make this available to the other client systems, create a yum repository configuration file called /etc/yum.repos.d/my.repo with the following contents:

[myrepo]
name=My Repository
baseurl=ftp://internalhost.com/repo/Fedora/10/$basearch
enabled=1

This file can be used on both i386 and x86_64 clients due to the "$basearch" specifier. It will be enabled the next time "yum update" is run.

Creating your own yum repository is very easy and very straightforward, and is a great way for administrators to distribute specialized packages within an organization.

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

Top articles

Sites

...

Setting Up a yum Repository



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March, 29, 2020