CentOS 7.6 YUM source configured offline

1. Background Description

a. For safety reasons most companies now provide service machines are generally not directly connected to the public network, this is the case, install the software and dependencies when it is inconvenient, usually mount the iso image files locally from local installation RPM package, if several servers Fortunately, the number of servers in dozens up time, it is more a waste of disk space and time;
. b This paper focuses on the way ftp, yum configuration of an offline source for local area network within the server uses to enhance the efficiency of operation and maintenance;

2. Preparing the Environment

. A CentOS 7.6 x64 prepare two servers, one server is the FTP, to configure the yum source; Client other is yum, yum source is used to test the normally available locally;
B preparation contains a complete mirror RPM installation package. files, paper CentOS-7-x86_64-Everything- 1810.iso mirror, for example, and the integration of all packages;
c preparing for FTP services RPM installation package, vsftpd-3.0.2-25.el7.x86_64.rpm.

3. The method of operation

3.1 turn off the firewall and selinux

3.1.1 Display system version information

[root@192168088102-FTP-YUM-Source ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

3.1.2 Check and turn off the firewall

[root@192168088102-FTP-YUM-Source ~]# firewall-cmd --state
running
[root@192168088102-FTP-YUM-Source ~]# systemctl stop firewalld.service
#禁止开机自动启动防火墙
[root@192168088102-FTP-YUM-Source ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@192168088102-FTP-YUM-Source ~]# firewall-cmd --state
not running

3.1.3 Check and close selinux

[root@192168088102-FTP-YUM-Source ~]# cat /etc/sysconfig/selinux
#selinux开启状态
SELINUX=enforcing
[root@192168088102-FTP-YUM-Source ~]# vi /etc/sysconfig/selinux
#将enforcing改为disabled
SELINUX=disabled
[root@192168088102-FTP-YUM-Source ~]# cat /etc/sysconfig/selinux
#selinux关闭状态
SELINUX=disabled

# Does not modify the file currently in effect, if you want to take effect, then either restart the server or use the following commands to temporarily disable selinux
# to view the current operating status of selinux

[root@192168088102-FTP-YUM-Source ~]# getenforce
Enforcing

# 0 temporarily closed, a temporary open

[root@192168088102-FTP-YUM-Source ~]# setenforce 0
[root@192168088102-FTP-YUM-Source ~]# getenforce
Permissive

# After restarting the system, view the status of firewall and selinux

[root@192168088102-FTP-YUM-Source ~]# sestatus
SELinux status:                 disabled
[root@192168088102-FTP-YUM-Source ~]# firewall-cmd --state
not running

3.2 uploaded files, and install the service started vsftp

# Check the FTP upload and install the package iso image

[root@192168088102-FTP-YUM-Source data]# ls -lh
total 11G
-rw-r--r--. 1 root root  11G Jul 29 00:57 CentOS-7-x86_64-Everything-1810.iso
-rw-r--r--. 1 root root 172K Jul 29 00:53 vsftpd-3.0.2-25.el7.x86_64.rpm

# Yum check whether the installation services

[root@192168088102-FTP-YUM-Source data]# rpm -qa|grep yum
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-161.el7.centos.noarch
yum-plugin-fastestmirror-1.1.31-50.el7.noarch

# Check for and install vsftp Service

[root@192168088102-FTP-YUM-Source data]# rpm -qa|grep ftp
[root@192168088102-FTP-YUM-Source data]# rpm -ivh vsftpd-3.0.2-25.el7.x86_64.rpm
warning: vsftpd-3.0.2-25.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                               ################################# [100%]
Updating / installing...
   1:vsftpd-3.0.2-25.el7              ################################# [100%]
[root@192168088102-FTP-YUM-Source data]# rpm -qa|grep ftp
vsftpd-3.0.2-25.el7.x86_64

#rpm -qi vsftpd view details of installed software
CentOS 7.6 YUM source configured offline
# vsftp start and check the service without vsftp configuration file, the default anonymous access on the line

[root@192168088102-FTP-YUM-Source data]# /bin/systemctl start vsftpd.service
[root@192168088102-FTP-YUM-Source data]# /bin/systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-07-29 01:27:34 EDT; 13s ago
  Process: 21058 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
 Main PID: 21059 (vsftpd)
   CGroup: /system.slice/vsftpd.service
           └─21059 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

Jul 29 01:27:34 192168088102-FTP-YUM-Source systemd[1]: Starting Vsftpd ftp daemon...
Jul 29 01:27:34 192168088102-FTP-YUM-Source systemd[1]: Started Vsftpd ftp daemon.

# Test whether the FTP service can properly access
CentOS 7.6 YUM source configured offline

3.3 Mount the image file, and the files are copied to directory pub

# Mount image files

[root@192168088102-FTP-YUM-Source data]# mount -o loop CentOS-7-x86_64-Everything-1810.iso /mnt/
mount: /dev/loop0 is write-protected, mounting read-only

CentOS 7.6 YUM source configured offline

# Copy the files in the directory / mnt to the / var / ftp / pub / directory

[root@192168088102-FTP-YUM-Source mnt]# cp -ar /mnt/* /var/ftp/pub/

CentOS 7.6 YUM source configured offline
# Check whether the normal ftp access to, the following screen appears, indicating that the normal ftp
CentOS 7.6 YUM source configured offline

Reminder:
If you mount a data disk partition ext4 format type, format type your root partition as xfs, and / var / ftp / pub / directory hanging beneath the roots, then there will be partition cp file from where you are to ext4 / after the next var / ftp / pub / directory, ls -al copy files found success, but the input ftp://192.168.88.102/pub/ found no document in the browser, df -Th look at the system partition type, with recommendations partition type within a consistent system;

3.4 YUM client configuration

Check system version 3.4.1, the files in the backup directory yum.repos.d

[root@192168088100-YUM-Client ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@192168088100-YUM-Client ~]# cd /etc/yum.repos.d/
[root@192168088100-YUM-Client yum.repos.d]# ll
total 32
-rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo
[root@192168088100-YUM-Client yum.repos.d]# mkdir bak
[root@192168088100-YUM-Client yum.repos.d]# cd bak/
[root@192168088100-YUM-Client bak]# mv ../CentOS-* ./
[root@192168088100-YUM-Client yum.repos.d]# ll
total 0
drwxr-xr-x. 2 root root 187 Jul 29 17:09 bak

3.4.2 Create and configure ftp.repo file in the directory /etc/yum.repos.d

[root@192168088100-YUM-Client yum.repos.d]# cat ftp.repo
[yum]
#自定义名称
name=yumftp
#yum访问路径
baseurl=ftp://192.168.88.102/pub
#启用yum源,0为不启用,1为启用
enabled=1
#检查GPG-KEY,0为不检查,1为检查
gpgcheck=0

3.4.3 Client test using the yum command to automatically install software

[root@192168088100-YUM-Client yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: yum
Cleaning up list of fastest mirrors
Other repos take up 215 M of disk space (use --verbose for details)
[root@192168088100-YUM-Client yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
yum                                                                                                                                     | 3.6 kB  00:00:00
(1/4): yum/group_gz                                                                                                            | 166 kB  00:00:00
(2/4): yum/filelists_db                                                                                                          | 7.1 MB  00:00:00
(3/4): yum/primary_db                                                                                                         | 6.0 MB  00:00:00
(4/4): yum/other_db                                                                                                             | 2.6 MB  00:00:00
Metadata Cache Created

CentOS 7.6 YUM source configured offline

Guess you like

Origin blog.51cto.com/14463906/2424644