Deploy YUM warehouse and NFS shared services

Keywords: Linux Operation & Maintenance CentOS

I. overview of YUM

1. Introduction to Yum warehouse

Software update mechanism of YuMe... za
● software update mechanism based on RPM package
● dependencies can be resolved automatically
● all software packages are provided by the centralized YUM software warehouse
yum is a software update mechanism based on RPM package (short for red hat package manager), which can automatically solve the dependencies between packages. It solves a lot of time for finding and installing dependent packages in daily work
Dependency occurs because linux itself takes the simplicity of the system as its own advantage. Therefore, all library files and compiled software packages are not installed when installing the operating system. Therefore, software package dependency will occur when installing software on the linux operating system. Yum is composed of warehouse and client, that is, the whole Yum is composed of two parts, so yum can be stored on two servers. It can also be stored on a server. Services can be provided by officials or by third parties, such as domestic Alibaba cloud, Sohu cloud, and some non-profit organizations such as schools. The official source is generally abroad, and the download speed must be limited. Manually changing to domestic cloud can greatly improve the download speed.

2. Implementation process

Create a yum repository (warehouse) on the yum server. Many rpm packages and related metadata files of the package are stored in the warehouse in advance (placed in the specific directory repodata). When the yum client installs the package using the yum/dnf tool, the metadata in repodata will be automatically downloaded to query whether there are related packages and dependencies in the remote data, Automatically find relevant packages from the warehouse, download and install them.

2, yum configuration files and commands

1.yum configuration file

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

[main]
cachedir=/var/cache/yum/$basearch/$releasever   //The cache directory $basearch of the RPM package downloaded from yum represents the hardware $releaser system version, such as 7
keepcache=0                     //Whether to save the cache. 0 means not to save and 1 means save
debuglevel=2                       //Just understand the debugging level
logfile=/var/log/yum.log               // Log file location
exactarch=1                            //Are different versions of rpm allowed
obsoletes=1                           //Can an update parameter allow the old version to run
gpgcheck=1                             //Authentication key
plugins=1                              //Allow plugin 1 to represent
installonly_limit=5                      //Save several kernels. 5 represents 5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release


yum of repo Variables available in the configuration file:
$releasever: current OS The major version number of the distribution version of, such as 8, 7, 6
$arch: CPU Architecture, such as: aarch64, i586, i686,x86_64 etc.
$basearch: System basic platform; i386, x86_64
$contentdir: Indicates a directory, for example: centos-8,centos-7
$YUM0-$YUM9:Custom variable

2. Warehouse setting file

Location: / etc/yum.repos.d/*.repo //yum warehouse file location
The default yum warehouse is the official yum source of centos. You need to be connected to the Internet to use it

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo

3. Log file

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

[root@localhost yum.repos.d]# cat /var/log/yum.log
Sep 28 09:54:44 Installed: 32:bind-9.9.4-50.el7.x86_64
 The installed software can be found

4.yum command details

commandNo keywordAdd keywords, packages, and package groups
yum listShow all available packagesSingle installable package
yum infoDisplays information about all available packagesIndividual specific information
yum search\Fuzzy search for all relevant information
yum whatprovides\Exact search
yum grouplistShow all available package groupsShow specific package groups
yum groupinfoShow all package group detailsDisplays specific information about a specific package group
yum install\Install specific packages
yum groupinstall\Install specific package groups
yum updateAll software upgradesSpecific software upgrade
yum group updateUpgrade all package groupsSpecific package group upgrade
yum remove\Uninstall specific software
yum groupremove\Uninstall specific package group software
yum historyView current operation history
yum history undoAdd the serial number and uninstall the software installed in the serial number\
yum history redoAdd a new serial number and perform the operations in the serial number\

4.1 query

4.1.1 yum list [software name]

The available installation packages are displayed. Without software name, all installed software packages, including those provided by the system, will be displayed

[root@localhost yum.repos.d]# yum list bind
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
bind.x86_64                                                              32:9.9.4-50.el7                                                               @1

4.1.2yum info [software name]

Show installation package details

[root@localhost yum.repos.d]# yum info bind
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
Name        : bind
Arch        : x86_64
Epoch       : 32
Version     : 9.9.4
Release     : 50.el7
Size        : 4.3 M
Repo        : installed
From repo   : 1
Summary     : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server
URL         : http://www.isc.org/products/BIND/
License     : ISC
Description : BIND (Berkeley Internet Name Domain) is an implementation of the DNS
            : (Domain Name System) protocols. BIND includes a DNS server (named),
            : which resolves host names to IP addresses; a resolver library
            : (routines for applications to use when interfacing with DNS); and
            : tools for verifying that the DNS server is operating properly.

4.1.3yum grouplist [package group name]

The query of the installation package group displays all the packages without the package group name

[root@localhost yum.repos.d]# yum grouplist
Loaded plugins: fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
Done

4.1.3 Yum search < keyword >

Search the software installation package according to the keywords, which means that you only know that a keyword in the package will be matched to you

4.1.4yum whatprovides < keywords >

You know a command but don't know the specific package. You can use this command to find it

4.1.5yum groupinfo < package group name >

Show all without package group name

4.2 installation and upgrade

4.2.1.yum install [software name]

Install the software package, such as yum install to install the http service

4.2.2 Yum groupinstall < package group name >

Package group installation is the same as yum install

[root@localhost ~]# yum groupinstall gnome desktop

#If it cannot be used, please upgrade it first
yum -y upgrade
#Reinstall
yum -y groups install "GNOME Desktop"

4.2.3yum update

The package group can be updated individually or completely, and the specific package group name added after it is a single update, or all updates without it.
But first you must have an updated package group library, otherwise you can't update it.

[root@localhost yum.repos.d]# yum upgrade 

4.3 software uninstall

4.3.1. Yum remove < software name >

You must add a software name to uninstall the installed software

4.3.2yum history

View usage history

[root@localhost yum.repos.d]# yum history
Loaded plugins: fastestmirror, langpacks
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     3 | root <root>              | 2021-09-28 11:03 | Install        |    1 
     2 | root <root>              | 2021-09-28 09:54 | Install        |    1   
     1 | System <unset>           | 2021-09-17 09:35 | Install        | 1372   
history list

To uninstall 3
[root@localhost yum.repos.d]# yum history undo 3

Reuse yum history  View an additional 4 record, which is the unloading record
[root@localhost yum.repos.d]# yum history
Loaded plugins: fastestmirror, langpacks
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     4 | root <root>              | 2021-09-28 11:03 | Erase       |    1 
     3 | root <root>              | 2021-09-28 11:03 | Install        |    1 
     2 | root <root>              | 2021-09-28 09:54 | Install        |    1   
     1 | System <unset>           | 2021-09-17 09:35 | Install        | 1372   
history list

If you regret uninstalling, you can use two methods

yum history redo 3 (Reinstall it)
yum history undo 4 (Renege on uninstallation is equal to reinstallation)

3, How to build a warehouse

How to provide software warehouse
FTP service: ftp://ip Address / path in site
HTTP service: http: / / domain name or ip address / path in the site
Local directory: File: / / absolute path( file:///mnt The third / here is the root directory)
FTP service settings
server setting

[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
[root@localhost yum.repos.d]# yum install vsftpd.x86_64 -y
[root@localhost yum.repos.d]#  cd /var/ftp/
[root@localhost ftp]# ls
pub
[root@localhost ftp]# mkdir zy other create zy and other folders
[root@localhost ftp]# ls
other  pub  zy
[root@localhost ftp]# CP - RF / mnt / * zy & copy the files in mnt directory to zy folder for background operation
[1] 3000
[root@localhost zy]# ls
CentOS_BuildTag  EFI  EULA  GPL  images  isolinux  LiveOS  Packages  repodata  RPM-GPG-KEY-CentOS-7  RPM-GPG-KEY-CentOS-Testing-7  TRANS.TBL
[root@localhost zy]# cd /var/ftp/other
[root@localhost other]# createrepo -g /opt/repodata/repomd.xml. / create a database file for the othe r
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost other]# ls
repodata
[root@localhost other]# systemctl start vsftpd start service

Client configuration

[root@localhost yum.repos.d]# yum install ftp -y
[root@localhost yum.repos.d]# systemctl stop firewalld.service 
[root@localhost yum.repos.d]# setenforce 0
[root@localhost yum.repos.d]# ftp 192.168.133.50
Connected to 192.168.133.50 (192.168.133.50).
220 (vsFTPd 3.0.2)
Name (192.168.133.50: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,133,50,184,99).
150 Here comes the directory listing.
drwxr-xr-x    3 0        0              22 Sep 30 07:11 other
drwxr-xr-x    2 0        0               6 Aug 03  2017 pub
drwxr-xr-x    8 0        0             220 Sep 30 06:56 zy
226 Directory send OK.
[root@localhost yum.repos.d]# mv *.repo bak
[root@localhost yum.repos.d]# ls
bak
[root@localhost yum.repos.d]# vim zy.repo


[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum install bind bind-u* -y
 Plug in loaded: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 Software package 32:bind-utils-9.9.4-50.el7.x86_64 Installed and the latest version
. . . . 

4, NFS share

1. Introduction to NFS

NFS (Network File System network file service)
NFS is a network file system protocol based on TCP/IP transmission, which was originally developed by Sun company.
By using the NFS protocol, clients can access shared resources in remote servers as if they were local directories
NFS is also a protocol that NAS storage devices must support. 1
NAS storage:
The implementation of NFS service depends on RPC(Remote Process Call) mechanism,
To complete the remote to local mapping process. In the CentOS7 system, NFS utils and rpcbind packages need to be installed to provide NFS sharing services,
The former is used for NFS share publishing and access, and the latter is used for RPC support.
When manually loading NFS shared services, you should start rpcbind first and then NFS.
characteristic:
Use TCP/IP to transmit network files
Low safety
Easy to operate
Suitable for LAN environment
Advantages of NFS: save local storage space, store commonly used data such as: / home directory on NFS server and can be accessed through network, which will reduce the utilization of local disk.

2. Principle

2. Construction process

First install a hard disk for backup

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# yum install nfs-utils.x86_ 64 -y install package
[root@localhost ~]# mkdir /mnt/zy
[root@localhost mnt]# vim /etc/exports

[root@localhost mnt]#  systemctl start rpcbind 
[root@localhost mnt]# systemctl start nfs 

It is better to use the exportfs -r command to restart the service, because the shared things cannot be disconnected

[root@localhost mnt]# exportfs -a
exportfs: No options for /mnt/zy *: suggest *(sync) to avoid warning
[root@localhost mnt]# exportfs -v
/mnt/zy       	<world>(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
   ro read-only    root_squash limit root       no_all_squash No restrictions for other users
[root@localhost mnt]# exportfs -r
exportfs: No options for /mnt/zy *: suggest *(sync) to avoid warning

[root@localhost mnt]# showmount -e view the NFS shared directory set locally
Export list for localhost.localdomain:
/mnt/zy *

Set up client

[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
[root@localhost ~]# mkdir /var/zy
[root@localhost ~]# mount 192.168.133.50:/mnt/zy /var/zy
[root@localhost ~]# df -Th
 file system                type      Capacity used available used% Mount point
/dev/mapper/centos-root xfs        50G  3.5G   47G    7% /
devtmpfs                devtmpfs  897M     0  897M    0% /dev
tmpfs                   tmpfs     912M     0  912M    0% /dev/shm
tmpfs                   tmpfs     912M  9.1M  903M    1% /run
tmpfs                   tmpfs     912M     0  912M    0% /sys/fs/cgroup
/dev/sda1               xfs        24G  179M   24G    1% /boot
/dev/mapper/centos-var  xfs       2.0G  1.5G  535M   74% /var
/dev/mapper/centos-home xfs        20G   33M   20G    1% /home
tmpfs                   tmpfs     183M   12K  183M    1% /run/user/42
tmpfs                   tmpfs     183M     0  183M    0% /run/user/0
192.168.133.50:/mnt/zy  nfs4      100G   33M  100G    1% /var/zy

Test process

On the host
[root@localhost ~]# cd /mnt/zy
[root@localhost zy]# ls
[root@localhost zy]# touch 1.txt
[root@localhost zy]# ls
1.txt
 On the client, it's in the shared folder
[root@localhost ~]# cd /var/zy
[root@localhost zy]# ls
1.txt
However, the client cannot create a new file because the server does not have set permissions
[root@localhost zy]# touch 12.txt                      
touch: could not be built"12.txt": Read-only file system 

Add permissions to host

[root@localhost mnt]# vim /etc/exports
/mnt/zy *(rw)
[root@localhost zy]# exportfs -r restart service

Then the file can be created on the client

[root@localhost zy]# touch 12.txt
[root@localhost zy]# ls
12.txt  1.txt
[root@localhost zy]# ll
 Total consumption 0
-rw-r--r--. 1 nfsnobody nfsnobody 0 9 June 30-19:56 12.txt             This file is created for anonymous users
-rwxrwxrwx. 1 root      root      0 9 June 30-19:46 1.txt
[fxy@localhost zy]$ ll
 Total consumption 0
-rw-r--r--. 1 nfsnobody nfsnobody 0 9 June 30-19:56 12.txt
-rwxrwxrwx. 1 root      root      0 9 June 30-19:46 1.txt
-rw-rw-r--. 1 fxy       fxy       0 9 June 30-20:18 fxy.txt       With normal users, you can add and own hosts
Test on host
vim /etc/exports                             
/mnt/zy *(rw,no_root_squash)                            to root Add permissions
[root@localhost zy]# exportfs -r

Test on client

[root@localhost ~]# cd /var/zy
[root@localhost zy]# touch 123.txt
[root@localhost zy]# ll
 Total consumption 0
-rw-r--r--. 1 root      root      0 9 June 30-20:27 123.txt
-rw-r--r--. 1 nfsnobody nfsnobody 0 9 June 30-19:56 12.txt
-rwxrwxrwx. 1 root      root      0 9 June 30-19:46 1.txt
-rw-rw-r--. 1 fxy       fxy       0 9 June 30-20:18 fxy.txt

Permanent mount
[root@localhost ~]# vi /etc/fstab 
...... //Omit some information 
192.168.133.50:/mnt/zy /var/zy nfs defaults,_netdev 0 0
#Auto Mount 
showmount -e Host name (view remote host) nfs (shared)

#Forced unmount
[root@localhost ~]# umount /mnt
t umount. nfs: /mnt : device is busy 
[root@localhost ~]# umount -lf /mnt

summary

Establishment of three kinds of warehouses
1. Local yum
2.ftp yum
3.http yum
yum basic commands
Establishment of NFS shared files

Posted by jil on Thu, 30 Sep 2021 17:19:04 -0700