Yum repository and NFS sharing

1. Introduction to yum Repository

1.1 introduction of yum

Yum (full Yellow Dog Updater, Modified) is a Shell front-end package manager in Fedora and RedHat and CentOS. Based on RPM package management, RPM packages can be automatically downloaded and installed from a specified server, and dependencies can be automatically handled. In addition, all dependent software packages can be installed at a time without tedious downloading and installation.

Yum is a software update mechanism built on RPM packages (short for Red-hat Package Manager) that automatically resolves dependencies between packages. Because Linux itself is to simplify the system for its own advantage, so when installing the operating system, there is no installation of all library files and compiled software packages. Therefore, software package dependence occurs during software installation on the Linux operating system. Yum is made up of a repository and a client, meaning the whole yum is made up of two parts, so yum can be hosted on two servers. It can also be stored on a server. Services can be provided by officials or third parties, such as Alibaba Cloud and Sohu Cloud in China, as well as some non-profit organizations such as schools. The official source is generally in foreign countries, the download speed is certainly limited, manually changed to the domestic cloud can greatly improve the download speed.

2. Yum configuration files and commands

2.1 Yum Configuration File

2.1.1 Master Configuration file

Location: /etc/yum.conf // Master configuration file

[root@localhost]# /etc/yum. Conf [main] cachedir=/var/cache/yum/$basearch/$releasever //yum $releasever Specifies the system version. For example, 7 keepCache =0 Logfile =/ var/log/ym.log // Log file location Exactarch =1 // Should different versions of RPM be allowed to install Obsoletes =1 // Update Gpgcheck =1 // Validate key plugins=1 // Allow plugins 1 = yes installonly_limit=5 // Save several kernels 5 =5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?categ Yum =yum distroverpkg=centos-release yum's repo configuration file available variables: $releasever: the main version number of the current OS distribution, e.g., 8,7,6 $arch: CPU architecture, such as: AARCH64, I586, I686, X86_64, etc. I386, x86_64 $contentDIR: indicates directories, such as centos-8, centos-7 $YUM0-$YUM9: custom variablesCopy the code

2.1.2 Warehouse setting file

/etc/yum. Repos. D /*.repo //yum

In this example, the default yum repository is the official centos yum source, which needs to be connected to the network

[root@localhost yum.repos.d]# ls /etc/yum.repos.d/
bak               CentOS-Debuginfo.repo  CentOS-Sources.repo
CentOS-Base.repo  CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-CR.repo    CentOS-Media.repo
Copy the code

2.1.3 Log files

Location: /var/log/yum.log // log file

Jun 23 11:03:16 Installed: [root@localhost yum. Repos. D]# install Jun 23 11:03:16 Installed: X86_64 Jun 23 11:03:16 Installed: apr-util-1.5.2-6.el7.x86_64 Jun 23 11:03:16 Installed: apr-util-1.5.2-6.el7.x86_64 Jun 23 11:03:16 Installed: Httpd-tools-2.4.6-67.el7.centos.x86_64 Jun 23 11:03:16 Installed: Mailcap-2.1.41-2.el7.noarch Jun 23 11:03:17 Installed: httpd-2.4.6-67.el7.centos.x86_64 Jun 23 11:03:26 Installed: Ftp-0.17-67.el7.x86_64 Jun 23 11:03:38 Installed: vsftpd-3.0.2-22.el7.x86_64Copy the code

2.2 Explanation of yum Commands

The command No keywords Add keywords, software packages, and software package groups
yum list Displays all available packages Single installable package
yum info Displays information about all available packages A single specific piece of information
yum search \ Fuzzy search for all relevant information
yum whatprovides \ Accurate search
yum grouplist Displays all available package groups Displays a specific package group
yum groupinfo All package group details are displayed Displays detailed information about a specific package group
yum install \ Installing specific Software packages
yum groupinstall \ Install a specific software package group
yum update All software updates Specific software upgrade
The command No keywords Add keywords, software packages, and software package groups
yum group update All package groups are upgraded Upgrade the package group
yum remove \ Uninstalling specific Software
yum groupremove \ Uninstall specific package group software
yum history View the current YUM operation history \
yum history undo Add the serial number uninstall the software installed in the serial number \
yum history redo Add serial number to perform the operation in the serial number \

2.2.1 query

1. Yum list

All available installation packages are displayed. If no software name is added, all available packages are displayed.

[root@localhost ~]# yum list httpdInstall packages httpd.x86_64 2.4.6-67.el7.centos ABCCopy the code
2. Yum info

The installation package details are displayed as follows

[root@localhost ~]# yum info httpdFastestmirror, langpacks Loading mirror speeds from cached hostfile Fastestmirror, langpacks Loading mirror speeds from cached hostfile Source: ABC Introduction: Apache HTTP Server website: http://httpd.apache.org/ Protocol: ASL 2.0 Description:  The Apache HTTP Server is a powerful, efficient, and : extensible web server.Copy the code

(If no software name is added, the details of all packages are displayed)

3. Yum search

Find the software installation package by keyword, equivalent to you only know that a certain keyword in the package will be matched to you

[root@localhost ~]# yum search ftpFastestmirror, langpacks Loading mirror speeds from cached hostfile ========================= N/S matched: ftp ========================= ftp.x86_64 : The standard UNIX FTP (File Transfer Protocol) client tftp.x86_64 : The clientfor the Trivial File Transfer Protocol
            : (TFTP)
tftp-server.x86_64 : The server for the Trivial File Transfer
                   : Protocol (TFTP)
vsftpd.x86_64 : Very Secure Ftp Daemon
curl.x86_64 : A utility for getting files from remote servers (FTP,
            : HTTP, and others)
lftp.x86_64 : A sophisticated file transfer program
Copy the code

2.2.2 Yum Installation and Upgrade

1. Yum install

Yum install installs the HTTP service

[root@localhost ~]# yum install httpdLoaded plug-ins: fastestmirror, Langpacks Loading mirror speeds from cached hostfile is resolving dependencies --> checking transactions --> packages httpd.x86_640.2.4.6-67.el7.centos will be installed Httpd-tools = 2.4.6-67.el7.centos, It is required by the package httpd-2.4.6-67.el7.centos.x86_64 --> is handling dependencies /etc/mime.types, It is required by the package httpd-2.4.6-67.el7.centos.x86_64 --> is handling dependencies libaprutil-1.so.0()(64bit), It is required by the package httpd-2.4.6-67.el7.centos.x86_64 --> handling dependencies libapr-1.so.0()(64bit), It is required by the package httpD-2.4.6-67.el7.centos.x86_64 --> Checking transactions --> 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.6-67.el7.centos will be installed --> package Mailcap.noarch.0.2.1.41-2.el7 will be installed --> Resolve dependencies to complete dependency resolution = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = version Package structure size of the source = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = are installing: HTTPD x86_64 2.4.6-67.el7.centos ABC 2.6m Apr-util x86_64 1.4.8-3.el7 ABC 103 k httpd-tools x86_64 2.4.6-6.el7 Mailcap noarch 2.1.41-2. 31 k el7 ABC transaction profile = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 1 installation package Is this OK [Y/D /N]: y Downloading Packages: Downloading -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- a total of 78 MB/s | 3.0 MB 00:00 Running transaction check  Running transactiontest
Transaction testX86_64 1/5: Apr-util-1.5.2-6.el7.x86_64 1/5: ApR-util-1.5.2-6.el7.x86_64 2/5: ApR-util-1.5.2-6.el7.x86_64 Httpd-tools-2.4.6-67.el7.centos.x86_64 3/5 Installing: mailCap-2.1.41-2.el7.noarch 4/5 installing: mailcap-2.1.41-2.el7.noarch 4/5 installing: Httpd-2.4.6-67.el7.centos.x86_64 1/5 verification: httpd-2.4.6-67.el7.centos.x86_64 1/5 verification: httpd-2.4.6-67.el7.centos.x86_64 1/5 verification: httpd-2.4.6-67.el7.centos.x86_64 1/5 verification: httpd-2.4.6-67.el7.centos.x86_64 1/5 verification: Mailcap-2.1.41-2.el7.noarch 2/5 validation: apr-1.4.8-3.el7.x86_64 3/5 validation: httpd-tools-2.4.6-67.el7.centos. X86_64 4/5 validation: apR-1.4.8-3.el7.x86_64 Apr-util-1.5.2-6.el7.x86_64 5/5 installed: httpd.x86_64 0:24.6-67.el7.centos installed as dependency: X86_64 0:1.4.8-3.el7 apr-util. X86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:24.6-67. el7.centos mailcap.noarch Finished 2-0. 1.41-2. El7!Copy the code
2. yum update

Update package group, can be a single or all after the specific package group name is a single update, do not add is all update.

But first you have to have the updated package library or you can’t update it.

[root@localhost yum.repos.d]# yum upgrade Fastestmirror, langpacks Loading mirror speeds from cached hostfile * epel: Mirrors.tuna.tsinghua.edu.cn is resolve dependencies -- -- -- -- -- > > is checking affairs package GeoIP. X86_64. 0.1.5.0-11. El7 will be upgraded - > package Geoip.x86_64.0.1.5.0-14.el7 will be updated --> Dependency geoipupdate is being processed, It is required by software package geoIP-1.5.0-14.el7.x86_64 --> software package modemManager.x86_64.0.1.6.0-2.el7 will be upgraded --> software package Modemmanager.x86_64.0.1.6.10-4.el7 will be updated --> software package modemManager-glib.x86_64.0.1.6.0-2.el7 will be upgraded --> software package Modemmanager-glib. X86_64.0.1.6.10-4.el7 will be updated --> package NetworkManager.x86_64.1.1.8.0-9.el7 will be upgraded --> package Networkmanager.x86_64.1.1.18.8-2.el7_9 will be updated --> software package NetworkManager-adsl.x86_64.1.1.8.0-9.el7 will be upgraded --> software package Networkmanager-adsl.x86_64.1.1.18.8-2.el7_9 will be updated --> software package NetworkManager-bluetooth.x86_64.1.1.8.0-9.el7 will be upgraded --> software package NetworkManager-bluetooth.x86_64.1.1.18.8-2.el7_9 will be updated --> software package NetworkManager-glib. X86_64.1.1.8.0-9.el7 will be upgraded --> software package Networkmanager-glib.x86_64.1.1.18.8-2.el7_9 will be updated --> software package NetworkManager-libnm.x86_64.1.1.8.0-9.el7 will be upgraded --> software package Networkmanager-libnm.x86_64.1.1.18.8-2.el7_9 will be updated --> package networkManager-ppp.x86_64.1.1.8.0-9.el7 will be upgraded --> package Networkmanager-team.x86_64.1.1.8.8-9.el7_9 will be updated --> package networkManager-team.x86_64.1.1.8.0-9.el7 will be upgraded --> package Networkmanager-team.x86_64.1.1.18.8-2.el7_9 will be updated --> Software package NetworkManager-tui.x86_64.1.1.8.0-9.el7 will be upgraded --> Software package Networkmanager-tui.x86_64.1.1.18.8-2.el7_9 will be updated --> package networkManager-wifi.x86_64.1.1.8.0-9.el7 will be updated --> package NetworkManager-wifi.x86_64.1.1.18.8-2.el7_9 will be updated --> package NetworkManager-wwan.x86_64.1.1.8.0-9.el7 will be updated --> package NetworkManager-wwan.x86_64.1.1.18.8-2.el7_9 will be updated --> package packageKit.x86_64.0.1.1.5-1.el7.centos will be updated --> package Centos will be updated --> packageKit-command-not -found. X86_64.0.1.1.5 -1.el7.centos will be upgraded --> Package packageKit-command-not -found. X86_64.0.1.1.10-2.el7.centos will be updated --> package Packagekit-glib. X86_64. 0.1.5-1.el7.centos will be updated --> Package packageKit-glib. X86_64 PackageKit-gstreamer-plugin.x86_64.0.1.1.5-1.el7.centos will be upgraded --> package Packagekit-gstreamer-plugin.x86_64.0.1.1.10-2.el7.centos will be updated --> package Centos will be upgraded --> PackageKit- gtk3-module.x86_64.0.1.5-1.el7.centos will be upgraded --> PackageKit-gtk3-module.x86_64.0.1.1.10-2.el7.centos will be upgraded --> PackageKit-gtk3-module.x86_64.0.1.1.10-2.el7.centos will be upgraded Centos will be updated --> PackageKit-yum. X86_64. 0.1.5-1.el7.centos will be updated --> PackageKit-yum --> Software package abrt.x86_64.0.2.1.11-48.el7.centos will be upgraded --> Software package abrt.x86_64.0.2.1.11-60.el7.centos will be updated --> Software package Abrt-addon-ccpp.x86_640.2.1.11-48.el7.centos will be upgraded --> Software package abrt-Addon-ccpp.x86_640.2.1.11-60. el7.centos will be updated --> Software package abrt-Addon-kerneloops.x86_64.0.2.1.11-48.el7.centos will be upgraded --> software package Centos will be updated --> software package abrt-addon-pstoreoops.x86_64.0.2.1.11-48.el7.centos Centos will be updated --> software package abrt-addon-pstoreoops.x86_64.0.2.1.11-60.el7.centos will be updated --> software package Centos will be upgraded --> Software package abrt-addon-python.x86_64.0.2.1.11-60.el7.centos will be updated --> Software package abrt-Addon-vmcmore.x86_64.0.2.1.11-48.el7.centos will be upgraded --> software package abrt-Addon-vmcmore.x86_64.0.2.1.11-60 Centos will be updated --> Software package abrt-Addon-xorg.x86_64.0.2.1.11-48.el7.centos will be updated --> Software package Centos will be updated --> Software package abrt-cli.x86_64.0.2.1.11-48.el7.centos will be upgraded --> Software package Centos will be updated --> Software package ABRt-console-notification.x86_64.0.2.1.11-48.el7. Centos will be upgraded --> Centos will be updated --> Software package ABRt-dbus.x86_64.0.2.1.11-48.el7.centos will be updated Upgrade --> Software package abrt-dbus.x86_64.0.2.1.11-60.el7.centos will be updated --> Software package abrt-desktop.x86_64.0.2.1.11-48.el7.centos will be updated --> Centos will be updated --> Software package abrt-gui.x86_64.0.2.1.11-48.el7.centos will be upgraded --> Software package Centos will be updated --> Software package abrt-gui-libs.x86_64.0.2.1.11-48.el7.centos will be upgraded --> Software package Abrt-gui-libs.x86_64.0.2.1.11-60.el7.centos will be updatedCopy the code
3. yum groupupdate

Group package updates are similar to individual installation package updates.

There is no updated package group in the example so it cannot be installed.

[root@localhost yum.repos.d]# yum groupupdate Loaded plug-ins: FastestMirror, LangPacks Not installed group info file Maybe Run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * epel: mirror.sjtu.edu.cn Maybe run: Yum Groups mark install (see man yum) There is no package that can be installed or upgraded in the specified groupCopy the code

2.2.3 Uninstalling software

1. Yum remove

You must add a software name when uninstalling installed software

[root@localhost yum.repos.d]# yum remove Fastestmirror, langPacks Error: Need to specify list of packages for remove [root@localhost yum.repos. D]# yum remove httpdLoaded plug-ins: fastestmirror, Langpacks is dealing with dependencies --> checking transactions --> package httpd.x86_640.2.4.6-67.el7.centos will be removed --> Resolve dependencies complete Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was 14:  curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"Dependencies to solve = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = source size Package framework version = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = are deleted: HTTPD x86_64 2.4.6-67.el7.centos @ ABC 9.4m transaction summary = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = remove 1 package installation size: 9.4 M whether to continue? [Y /N] : Y Downloading Packages: Running Transaction Check Running Transactiontest
Transaction testSucceeded Running Transaction Deleting: httpd-2.4.6-67.el7.centos.x86_64 1/1 Verification: Httpd-2.4.6-67.el7.centos. X86_64 1/1 delete: httpd.x86_64 0:24.6-67.el7.centos end!Copy the code
2. yum history

View historical usage records

[root@localhost yum.repos.d]# yum history Loaded plug-ins: fastestmirror, Langpacks ID login | | | | the date and time by the end-user change number -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 5  | root <root> | 2021-06-24 00:02 | Erase | 1 4 | root <root> | 2021-06-23 11:03 | Install | 1 3 | root <root> | The 2021-06-23 11:03 | Install | | 1 2 root < root > | 2021-06-23 11:03 | Install | | 5 1 system < empty > | 2021-06-15 when | Install | 1318history list

Copy the code

Select ID 1,2,3,4,5

You can uninstall using Yum History undo 4, which compares remove to remove all dependencies

The example unloads 4

[root@localhost yum.repos.d]# yum history undo 4Loaded plug-ins: fastestmirror, langpacks Undoing transaction 4, From Wed Jun 23 11:03:382021 install vsftpd-3.0.2-22.el7.x86_64@abc Resolving dependencies --> checking transactions --> Package Vsftpd.x86_64.0.3.0.2-22.el7 would be removed --> Resolve dependencies complete Could not retrieve Mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was 14:  curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"Dependencies to solve = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = source size Package framework version = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = are deleted: VSFTPD x86_64 3.0.2-22.el7@abc 348k = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = remove 1 package installation size: 348 k whether to continue? [Y /N] : Y Downloading Packages: Running Transaction Check Running Transactiontest
Transaction testX86_64 1/1 Verify vsftpd-3.0.2-22.el7.x86_64 1/1 Delete: Vsftpd.x86_64 0:3.0.2-22.el7 End! [root@localhost yum.repos.d]# yum history info 4
What did you install for the fourth time

Copy the code

Yum History is the uninstallation record

[root@localhost yum.repos.d]# yum history Loaded plug-ins: fastestmirror, Langpacks ID login | | | | the date and time by the end-user change number -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 6  | root <root> | 2021-06-24 00:11 | Erase | 1 5 | root <root> | 2021-06-24 00:02 | Erase | 1 4 | root <root> | 2021-06-23 11:03 | Install | 1 3 | root <root> | 2021-06-23 11:03 | Install | 1 2 | root <root> | 2021-06-23 11:03 | 1 | Install | 5 system < empty > | 2021-06-15 when | Install | 1318history list
Copy the code

3. The way to build the warehouse

FTP service: ftp://ip Address/site path

HTTP service: http://domain name or IP address/site path

Local directory: file:/// MNT (where the third/is the root directory)

4. Build yum local repository (local source) + extended repository (extended source)

1, mount /dev/sr0/mnt 2, CD /etc/yum-repos. D / 3, mkdir bak 4, mv *. Repo bak 5, vim local.repo [local] ## Name =local baseurl=file:///mnt gpgcheck=0 enabled=1 [epel] ## name=epel baseurl=https://mirrors.aliyun.com/epel/$releasever/x86_64 # # ali https://mirrors.cloud.tencent.com/epel/$releasever/x86_64 # # # # of tencent address alignment! https://mirrors.huaweicloud.com/epel/$releasever/x86_64 # # huawei https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/x86_64 tsinghua gpgcheck = 0 # # 6, yum clean all && yum makecacheCopy the code

5. Set up HTTP Intranet web yum repository #### requires two VMS!

RPM -q HTTPD ## Yum install HTTPD -y 2, systemctl start HTTPD 3, systemctl stop firewalld.service setenforce 0 4, CD /var/www/html 5, mount /dev/sr0 /var/ WWW/HTML /centos7/ Repo [HTTP] name=centos7 2, mkdir bak 3, mv *. Repo bak/ 4, vim http.repo [HTTP] name=centos7 Baseurl = http://192.168.58.5/centos7/ (address is the iP address of the server 1) gpgcheck = 0. 5, systemctl stop firewalld service setenforce 0 6, yum Clean all && yum makecache 7, RPM -q Check the uninstalled software and test the installationCopy the code

6. Set up FTP Intranet local warehouse #### Requires two VMS!

Server: Run the following command to install VSFTPD: yum install VSFTPD -y 2, systemctl stop firewalld.service setenforce 0 3, systemctl start VSFTPD 4, CD /var/ftp.conf 5, mount /dev/sr0 /var/ftp-centos7/client Repo [FTP] name=centos7 4, /etc/ypm.repos. D / 3, mkdir bak 4, mv *. Repo bak/ 5, vim ftp.repo [FTP] name=centos7 Baseurl = ftp://192.168.58.5/centos7/ (address is the iP address of your server) gpgcheck = 0, 6, yum clean all && yum makecache 7, the RPM - q view did not install the software, installation testCopy the code

7. The NFS Shared

1. Introduction of NFS

Network File System (NFS) NFS is a Network File System protocol based on TCP/IP transmission, originally developed by Sun. Using the NFS protocol, clients can access shared resources on a remote server as if they were accessing a local directory. NFS is also a protocol supported by NAS storage devices.

The implementation of NFS services relies on the Remote Process Call (RPC) mechanism to complete the mapping Process from Remote to local. In CentOS 7, you need to install the nfS-utils and rpcbind software packages to provide NFS share services. The former is used for NFS share publishing and access, and the latter is used for RPC support. To manually load the NFS share service, you need to enable rpcbind and then NFS.

Features: TCP/IP transmission network file low security, simple and easy to operate suitable for LAN environment

1.1 NFS principle

1.2NFS Software Introduction

Package: NFS-utils (both server and client)

Related packages: rpcbind(must), tcp_wappers

NFS port 2049

RPC port number 111

Configuration file: /etc/exports

2. Setup process

[root@localhost httpd]#systemctl stop firewalld [root@localhost httpd]#setenforce 0 [root@localhost share]#yum install [root@localhost HTTPD]#mkdir /share # create shared directory [root@localhost HTTPD]# CD /share/ [root@localhost share]#chmod -r 799 /exports / # root@localhost share]#vim /etc/exports /export 192.168.91.0/24(rw,sync,no_root_squash) No root permission [root@localhost ~]# systemctl start rpcbind [root@localhost ~]# systemctl start NFS [root@localhost ~]#exports -vr # Take effect without restart [root@localhost share]#exportfs -v # View detailed NFS information # Exportfs can be used to manage NFS -v View all NFS files on the local machine -r Reread configuration files -a Output all shares/shares on the local machine 192.168.91.0/24 (sync, wdelay, hide, no_subtree_check, the SEC = sys, rw, secure, no_root_squash, no_all_squash) root @ localhost ~ # netstat -anpt | grep rpc [root@localhost ~]# showmount -e Export list for localhost.localdomain: / opt/below 192.168.7.0/24 / var/FTP/pub 192.168.4.110, 192.168.4.11 # # check released native NFS Shared directory client/root @ localhost ~ # mount 192.168.7.250: / opt/below the/var/WWW/HTML # server address The colon Shared folder local mount point/root @ localhost ~ # vi/etc/fstab... / / omitted some information 192.168.7.250: / opt/below the/var/WWW/HTML NFS defaults, _netdev 0 0 # automatically mount showmount -e hostname (see remote host NFS Shared) # force mount [root@localhost ~]# umount /mnt t umount. nfs: /mnt : device is busy [root@localhost ~]# umount -lf /mntCopy the code