Linux--Deploy YUM warehouse and NFS service (deploy Yum source warehouse, use Yum tool to manage software packages, NFS shared storage service, realize directory sharing)


1. Deploy YUM Warehouse Service

1.YUM overview

  • The predecessor of YUM is YUP (Yellow dog Updater, the software updater of Yellow dog Linux). It was originally developed by TSS (Terra Soft Solutions, INC) using the python language, and later improved by the Linux development team at Dunk University, named YUM (Yellow dog Updater Modified)
  • With the help of YUM software warehouse, tasks such as installation, uninstallation, and automatic upgrade of rpm packages can be completed, and the dependencies between rpm packages can be automatically found and resolved without the need for an administrator to manually install each rpm package one by one, so that management More comfortable when maintaining a large number of Linux servers
  • Especially in a local network with a large number of Linux hosts, building a source server can greatly alleviate the dependence on the Internet such as software installation and upgrades

2. Prepare the network installation source (server side) and configure the software warehouse location (client side)

  • To successfully use the YUM mechanism to update software and software, a software warehouse containing various rpm installation package files is required. The server that provides the software warehouse is also called the "source" server.
  • In the client, as long as the address and other information of the software warehouse are correctly specified, the software can be installed or updated through the corresponding "source" server
  • Here is just a brief introduction to theoretical knowledge. For practical operations, you can go to my last blog, which is written in detail, and has everything you need to deploy local YUM source warehouses and online YUM source warehouses.

3. Use yum tools to manage software packages

  • Let's introduce how to use yum tool to query, install, upgrade and uninstall software packages

3.1 Query software package

  • Query the package list-yum list
    • Get the installation status of the software in the system, or directly query the list of software packages available in the software warehouse
    • yum list installd means only list the installed packages in the system
    • yum list available means to list only packages that are available (not yet installed) in the software warehouse
    • yum list updates can list the packages that can be upgraded
[root@localhost ~]# yum list http
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
错误:没有匹配的软件包可以列出
[root@localhost ~]# yum list httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
已安装的软件包
httpd.x86_64             2.4.6-67.el7.centos              @local
[root@localhost ~]# 
  • Query the description information of the package-yum info package name
[root@localhost ~]# yum info httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
已安装的软件包
名称    :httpd
架构    :x86_64
版本    :2.4.6
发布    :67.el7.centos
大小    :9.4 M
源    :installed
来自源:local
简介    : Apache HTTP Server
网址    :http://httpd.apache.org/
协议    : ASL 2.0
描述    : The Apache HTTP Server is a powerful, efficient, and
         : extensible web server.

[root@localhost ~]# 

  • Query the specified package-yum search
  • When you need to find a related software package based on a certain keyword, you can execute "yum search keyword", the default is to search only based on the package name and description information
  • If you execute "yum search all keywords", you can expand the search scope

3.2 Install, upgrade, and uninstall software packages

  • Use the yum tool to install and upgrade the software package, respectively through the subcommands install, update to complete, the operation object is the specified package name (there can be multiple)
  • When the operation is executed, the dependency between the software packages will be automatically checked and resolved. During the operation, the user will be prompted to press the y key to confirm the installation or upgrade operation. If you want to automatically determine it, you can add the "-y" option after the yum command
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# yum -y install mysql
已加载插件:fastestmirror, langpacks
local                                    | 3.6 kB     00:00     
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.56-2.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================
 Package      架构        版本                 源          大小
================================================================
正在安装:
 mariadb      x86_64      1:5.5.56-2.el7       local      8.7 M

事务概要
================================================================
安装  1 软件包

总下载量:8.7 M
安装大小:49 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 1:mariadb-5.5.56-2.el7.x86_64               1/1 
  验证中      : 1:mariadb-5.5.56-2.el7.x86_64               1/1 

已安装:
  mariadb.x86_64 1:5.5.56-2.el7                                 

完毕!
[root@localhost ~]# 

  • When using the yum tool to uninstall the package, use the subcommand remove to complete
[root@localhost ~]# yum -y remove mysql
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.56-2.el7 将被 删除
--> 解决依赖关系完成

依赖关系解决

================================================================
 Package      架构        版本                源           大小
================================================================
正在删除:
 mariadb      x86_64      1:5.5.56-2.el7      @local       49 M

事务概要
================================================================
移除  1 软件包

安装大小:49 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : 1:mariadb-5.5.56-2.el7.x86_64               1/1 
  验证中      : 1:mariadb-5.5.56-2.el7.x86_64               1/1 

删除:
  mariadb.x86_64 1:5.5.56-2.el7                                 

完毕!
[root@localhost ~]# 


2. NFS shared storage service

1. Overview of NFS

  • NFS is a network file system protocol based on TCP/IP transmission, originally developed by the sun company. By using the NFS protocol, the NFS client can access the shared resources in the remote server like 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 the local area network.

2. Use NFS to publish shared resources

2.1 NFS application scenarios

  • The realization of the NFS service relies on the RPC (Remote Process Call) mechanism. RPC acts as an intermediary between the NFS client and the NFS server to complete the remote-to-local mapping process
  • So you need to install nfs-utils, rpcbind package to provide NFS sharing service, the former is used for NFS sharing publishing and access, the latter is used for RPC support

2.2 Install nfs-utils, rpcbind software packages

  • Generally speaking, the system has been installed by default
[root@localhost ~]# yum -y install nfs-utils rpcbind        ##安装软件包以来提供NFS共享服务
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
软件包 1:nfs-utils-1.3.0-0.48.el7.x86_64 已安装并且是最新版本
软件包 rpcbind-0.2.0-42.el7.x86_64 已安装并且是最新版本
无须任何处理

2.3 Set up shared directory

mark

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

2.4 Start NFS sharing service program

  • When manually loading the NFS sharing service, you should start rpcbind and then nfs
[root@localhost opt]# systemctl start rpcbind
[root@localhost opt]# systemctl start nfs
[root@localhost opt]# systemctl enable rpcbind
[root@localhost opt]# systemctl enable nfs

2.5 View the NFS shared directory published by this machine

[root@localhost opt]# exportfs -rv
exporting        ##f发布共享 192.168.126.0/24:/opt/xcf123
[root@localhost opt]# showmount -e        ##查看共享文件
Export list for localhost.localdomain:
/opt/xcf123 192.168.126.0/24

3. Access NFS shared resources in the client

  • The previous one was 7-1, I will create a 7-2 as a client

3.1 Install nfs-utils, rpcbind package, and start rpcbind service

mark

[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl enable rpcbind

3.2 View which directories are shared on the NFS server

  • The old way, turn off the firewall first
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
[root@localhost ~]# showmount -e 192.168.126.11        ##查看NFS服务端共享的目录
Export list for 192.168.126.11:
/opt/xcf123 192.168.126.0/24

3.3 Manually mount the NFS shared directory

  • Create a resource shared directory in the client, and then mount the server shared directory on the resource shared directory created by the client
    mark
  • Then you can realize the sharing of resources between the client and the server
    mark
  • Go back to the server /opt/xcf shared directory and check to confirm whether it is synchronized
    mark

3.4 fstab auto mount

mark
mark
mark

3.5 Forcibly uninstalling NFS

  • If the server-side NFS service suddenly stops while the client is being mounted and used, the client will get stuck when executing the df -h command
  • At this time, you cannot uninstall directly by using the umount command directly, you need to add the -lf option to uninstall
  • Let’s simulate, just turn off 7-1 and try the water at 7-2
    mark
  • ctrl + c cut out and try again
    mark
    became

Guess you like

Origin blog.csdn.net/weixin_51486343/article/details/111141944
Recommended