How to create and add a Local YUM Repository on RHEL or CentOS 7
How to setup local yum repository on RHEL or CentOS 7?
This tutorial describes how to setup a local Yum repository on CentOS or RHEL 7 system. Later i will show you how you can use this repository to fetch software, security updates and fixes. Local repository is an efficient way to deploy new software's or patches as it will be over LAN where deployment will be fast, saving your internet bill.
I have two CentOS 7 systems here one is YUM repository server and another will be Client which will fetch the updates from repository server over FTP protocol.
Setting up YUM repo server with FTP:
Step 1. Mount CentOS 7 ISO and copy all the RPM packages to a FTP directory:
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# mkdir /var/ftp/pub/localrepo
[root@localhost ~]# cp -ar /mnt/Packages/* /var/ftp/pub/localrepo/
Step 2. Install vsftpd package and start it's service:
[root@localhost ~]# cd /mnt/Packages/
[root@localhost ~]# rpm -ivh vsftpd-3.0.2-25.el7.x86_64.rpm
[root@localhost ~]# systemctl enable vsftpd
[root@localhost ~]# systemctl start vsftpd
Step 3. Install "createrepo" package and it's dependencies:
[root@localhost ~]# rpm -ivh libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
[root@localhost ~]# rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm
Step 4. Create repository
[root@localhost ~]# createrepo -v /var/ftp/pub/localrepo/
Step 5. If this repository is going to be on your LAN then disable firewall and SELinux:
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
To disable SELinux, edit file /etc/sysconfig/selinux,
SELINUX=disabled
Save, exit and reboot host.
Step 6. [OPTIONAL] Test if repository is working fine on YUM server:
[root@localhost ~]# vi /etc/yum.repos.d/localrepo.repo
[localrepo]
name=Local Repository
baseurl=file:///var/ftp/pub/localrepo
gpgcheck=0
enabled=1
Save and Exit.
[root@localhost repodata]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.mirror.net.in
* extras: centos.mirror.net.in
* updates: centos.mirror.net.in
localrepo | 2.9 kB 00:00
localrepo/primary_db | 3.2 MB 00:00
repo id repo name status
base/7/x86_64 CentOS-7 - Base 10,019
base-debuginfo/x86_64 CentOS-7 - Debuginfo 6,637
extras/7/x86_64 CentOS-7 - Extras 385
localrepo Local Repository 4,021
updates/7/x86_64 CentOS-7 - Updates 1,511
repolist: 22,573
Setting up Client to get YUM repo on FTP :
[root@localhost ~]# vi /etc/yum.repos.d/localrepo.repo
[localrepo]
name=Local Repository
baseurl=ftp://192.168.189.1/pub/localrepo
gpgcheck=0
enabled=1
Save and Exit.
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.mirror.net.in
* extras: centos.mirror.net.in
* updates: centos.mirror.net.in
localrepo | 2.9 kB 00:00
localrepo/primary_db | 3.2 MB 00:00
repo id repo name status
base/7/x86_64 CentOS-7 - Base 10,019
base-debuginfo/x86_64 CentOS-7 - Debuginfo 6,637
extras/7/x86_64 CentOS-7 - Extras 385
localrepo Local Repository 4,021
updates/7/x86_64 CentOS-7 - Updates 1,511
repolist: 22,573
Clean the Yum cache and update the repository lists:
[root@localhost ~]# yum clean all
[root@localhost ~]# yum update
Try to install any package:
[root@localhost ~]# yum install ethtool
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package ethtool.x86_64 2:4.8-9.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================
Installing:
ethtool x86_64 2:4.8-9.el7 localrepo 127 k
Transaction Summary
==============================================================================================================================================
Install 1 Package
Total download size: 127 k
Installed size: 346 k
Is this ok [y/d/N]: y
Downloading packages:
ethtool-4.8-9.el7.x86_64.rpm | 127 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:ethtool-4.8-9.el7.x86_64 1/1
Verifying : 2:ethtool-4.8-9.el7.x86_64 1/1
Installed:
ethtool.x86_64 2:4.8-9.el7
Complete!
piomuli_pe Chris Swindle https://wakelet.com/wake/NAUMuQZUopxSG54oUVx_p
ReplyDeletenoliryma