Linux deployed YUM warehouse

CentOS-Logo

This article mainly describes how to build The custom YUM source can reduce the dependence on the external network in a host environment with a large number of local networks.


Server

install vsftp package

[[emailprotected] ~]# yum install vsftpd -y
  • Create a directory that needs to be stored
 [[emailprotected] ~]# mkdir /var/ftp/centos7 /var/ftp/others
[[emailprotected] ~]# ls /var/ftp/
centos7 others pub
  • Copy the contents of the image file to the relevant directory
[[emailprotected] ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[[email protected] ~]# cp -r /mnt/* /var/ftp/centos7/
  • toothers Directory creation repodata
[[emailprotected] ~]# createrepo -g /var/ftp/centos7/repodata/repomd.xml /var /ftp/others/
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
  • Check if the files are complete
[[emailprotected] ~]# ls /var/ftp/centos7/
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packag es repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL
[[emailprotected] ~]# ls /var/ftp/others/
repodata

Open service

[[emailprotected] ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/ multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[[emailprotected] ~]# systemctl start vsftpd
[[emailprotected] ~ ]# netstat -ntuap | grep vsftpd
tcp6 0 0 :::21 :::* LISTEN 35971/vsftpd

Turn off the firewall

[ [emailprotected] ~]# systemctl stop firewalld
[[emailprotected] ~]# setenforce 0

Client

install ftp package

[[email protected] ~]# yum install ftp -y

anonymous login view

 [[email protected] ~]# ftp 192.168.28.128
Connected to 192.168.28.128 (192.168.28.128).
220 (vsFTPd 3.0.2)
Name (192.168.28.128:root) : ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,28,128,255,56).
150 Here comes the directory listing.
drwxr-xr-x 8 0 0 2048 Sep 05 2017 centos7
drwxr-xr-x 3 0 0 22 Sep 16 19:42 others
drwxr-xr-x 2 0 0 6 Oct 30 2018 pub
226 Directory send OK.
ftp> bye
221 Goodbye.

Edit YUM source configuration file

  • Back up the existing yum source
  • < /ul>

    [[email Protected] ~]# cd /etc/yum.repos.d/
    [[email Protected] yum.repos.d]# mkdir bak
    [[email Protected ] yum.repos.d]# mv *.repo bak/
    • Edit custom yum source
    [[email protected] yum.repos.d]# vim ftp.repo
    [base]
    name=centos7.Packages
    baseurl=ftp://192.168.28.128/centos7/
    enabled =1
    gpgcheck=1
    gpgkey=ftp://192.168. 28.128/centos7/RPM-GPG-KEY-CentOS-7

    [others]
    name=others.Packages
    baseurl=ftp://192.168.28.128/others/< br />enabled=1
    gpgcheck=0

    View results

    [[emailprotected] ~]# yum clean all
    Loaded plugins: fastestmirror
    Cleaning repos: base others
    Cleaning up everything
    Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
    Cleaning up list of fastest mirrors
    [[emailprotected] ~]# yum list

Leave a Comment

Your email address will not be published.