Supplement to YUM warehouse of Linux network service and NFS sharing service

One, YUM

The predecessor of YUM is YUP (Yellow dog Updater, software updater for Yellow dog Linux). It was originally developed by TSS (Terra Soft Solutions, INC) using Python language, and later by the Linux development team of Duck University. Make improvements and name it YUM (Yellow dog Updater Modified).

1、YUM (Yellow dog Updater Modified)

  • Software update mechanism based on RPM package
  • Can resolve dependencies automatically
  • All software packages are provided by the centralized YUM software warehouse

Insert picture description here

2. The method of providing software warehouse network source

  • Network source
    FTP service: ftp://…
    HTTP service: http://…
  • Local source
    Local directory: file://...

3. The source of the RPM package

  • A collection of RPM packages released by CentOS
  • A collection of RPM packages released by third-party organizations
  • User-defined RPM package collection

4. Build a CentOS 7 software warehouse

  • The RPM package comes from the CentOS 7 DVD disc
  • Provide to the client via FTP (install and enable the vsftpd service)
mkdir -p /var/ftp/CentOS7
cp -rf /dev/cdrom/*  /var/ftp/CentOS7

rpm -ivh /dev/cdrom/Packages/vsftp-3.0.2-21.el7.x86_64.rpm
systemctl start vsftpd
systemctl enabled vsftpd

5. Join the unofficial RPM package group in the software warehouse

  • Include all other RPM packages that have dependencies
  • Need to use createrepo tool to build repodata data file warehouse
mkdir -p  /var/ftp/other
cd /var/ftp/other                #非官方的RPM要先放入该目录下
createrepo -g /dev/cdrom/repodata/repomd.xml ./

6. Visit YUM warehouse

  • Specify the YUM warehouse location for the client
  • Configuration file location: /etc/yum.repos.d/centos7.repo
vim /etc/yum.repos.d/centos7.repo
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7      #软件校验公钥
name=Other RPM Packages

7. Overview of Yum tool

About the YUM command

  • Provided by package yum-3.4.3-150.el7.centos.noarch
  • Used to access YUM warehouse, query, download and install, uninstall software package
    ■YUM configuration file
  • Basic settings: /etc/yum.conf
  • Warehouse settings: /etc/yum.repos.d/*.repo
  • Log file: /var/log/yum.log

2. NFS shared storage service

1. Related concepts

NFS is a network file system protocol based on TCP/IP transmission. By using the NFS protocol, the client can access the shared resources in the remote server as if it were accessing a local directory.
For most load balancing clusters, it is a common practice to use the NFS protocol to share data storage. NFS is also a protocol that NAS storage devices must support. However, because NFS does not have a user authentication mechanism, and the data is transmitted in plain text on the network, the security is very poor, and it can only be used in a local area network.
The implementation of the NFS service relies on the RPC (Remote Process Call) mechanism to complete the remote-to-local mapping process, so it is necessary to install the nfs-utils and rpcbind software packages to provide NFS sharing services.
nfs-utils is used for NFS share publishing and access
rpcbind for RPC support

2. NFS service configuration file

The NFS configuration file is /etc/exports and the
format is:

共享的目录位置   客户机地址(权限选项)

Three, NFS service configuration demonstration

1. Use NFS to publish shared resources in the file server

(1) Install the nfs-utils and rpcbind software packages

rpm -q rpcbind nfs-utils 
yum -y install nfs-utils rpcbind

Insert picture description here
(2) Set up a shared directory

mkdir -p /opt/wwwroot
chmod 777 /opt/wwwroot

vim /etc/exports

客户机地址可以是主机名、IP 地址、网段地址,允许使用“*”、 “?”通配符。
“rw” 表示允许读写,“ro” 表示为只读。
sync :表示同步写入到内存与硬盘中。
no_root_squash : 表示当客户机以root身份访问时赋予本地root权限(默认是root_squash)。
root_squash :表示客户机用root用户访问该共享目录时,将root用户映射成匿名用户。

all_squash :所有访问用户都映射为匿名用户或用户组。
async :将数据先保存在内存缓冲区中,必要时才写入磁盘。
no_subtree_check :即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率。

Insert picture description here
(3) Start the NFS service program When
manually loading the NFS sharing service, you should start rpcbind first, and then start nfs

systemctl start rpcbind
systemctl start nfs
systemctl enable rpcbind
systemctl enable nfs

netstat -anpt | grep 111 #Check whether rpcbind port 111 is open, rpcbind uses tcp port 111 by default
Insert picture description here
Insert picture description here

(4) View the NFS shared directory published by this machine

exportfs -rv			#发布共享
showmount -e            #查看共享

Insert picture description here

2. Access NFS shared resources in the client

(1) Install the nfs-utils and rpcbind software packages

rpm -q rpcbind nfs-utils 
yum -y install nfs-utils rpcbind
systemctl start rpcbind
systemctl enable rpcbind

systemctl stop firewalld.service 
setenforce 0

#查看 NFS 服务器端共享了哪些目录
showmount -e

Insert picture description here
(2) Mount the NFS shared directory

mkdir /myshare
mount /myshare
vim /etc/fstab    /myshare    nfs defaults,_netdev  0  0

_netdev :表示挂载设备需要网络
mount -a     #挂载 fstab 中的所有文件系统

df -Th      #确认挂载结果

Manually mount
Insert picture description here

Insert picture description here

如果服务器端NFS服务突然间停掉了,而客户端正在挂载使用时,在客户端就会出现执行 df -h 命令卡死的现象。这个时候直接使用umount 命令是无法直接卸载的,需要加上 -lf 选项才能卸载。
umount -lf /myshare

Insert picture description here
(4) Check whether the file is shared or not
Insert picture description here
(5) Forcibly uninstall NFS

如果服务器端NFS服务突然间停掉了,而客户端正在挂载使用时,在客户端就会出现执行 df -h 命令卡死的现象。这个时候直接使用umount 命令是无法直接卸载的,需要加上 -lf 选项才能卸载。
umount -lf /myshare

Guess you like