部署YUM仓库及NFS共享

部署YUM仓库及NFS共享服务

结构

部署YUM仓库服务

  • 构建YUM软件仓库

  • 使用YUM工具管理软件包

NFS共享存储服务

  • 使用NFS发布共享资源

  • 在客户端访问NFS共享

  • NFS客户端mount的挂载

YUM(Yellow dog Updater Modified)

借助YUM软件仓库,可以完成安装,卸载、总的升级rpm包等,能够自动查找并解决rpm

包之间的依赖关系,而无需管理逐个手工的去安装rpm包。是管理员维护大量的Linux服务器

本地构建以个源服务器,可以大大缓解软件安装升级等对Internet的依赖。

基于RPM包构建的软件更新机制

所有软件包由集中的YUM软件仓库提供

可以自动解决依赖关系

软件仓库的提供方式

FTP服务:ftp://

HTTP服务:http://

本地目录:file://

RPM软件包的来源

CentOS发布的RPM包集合

第三方组织发布的RPM包集合

用户自定义的RPM包集合(数据包依赖关系数据库)

打开telnet客户端

yum -y install net-tools 最小安装默认没有此工具

fps出现弹窗,说明三次握手成功

YUM的配置文件

基本设置:/etc/yum.comf

仓库设置:/etc/yum.repos.d/&.repo

日志文件:/var/log/yum.log

createrepos -v #自动生成依赖关系

查询软件包

yum list [文件名]

yum info [文件名]

yum search <关键词>

查询软件包组

yum grouplist [软件名]

yum groupinfo <包组名>

升级

yum update

yum groupupdate

[root@localhost~]# yum -y install net-snmp

[root@localhost~]# yum -y groupinstall gnome-desktop

[root@localhost~]# yum -y update # -y表示自动确定

卸载软件

yum remove [软件名]

yum groupremove <包组名>

/var/cache/yum 缓存所在目录

####搭建本地YUM仓库#####

##环境准备##

1、配置IP地址

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33

BOOTPROTO=static ##修改

ONBOOT=yes ##修改

IPADDR=192.168.179.20 ##新增

NETMASK=255.255.255.0 ##新增

GATEWAY=192.168。179.2 ##新增

[root@localhost ~]# systemctl restart network ###重启网卡

[root@localhost ~]# ifconfig ##确认更改的IP地址是否生效

2、挂光盘

虚拟机中-设置-硬件-CD/DVD-设备状态(已连接和启动时连接勾选)-使用ISO文件要选中地址-确定

Centos设置 挂光盘

[root@localhost ~]# mount /dev/cdrom /mnt

mount: /dev/sr0 写保护,将以只读方式挂载

永久挂载

[root@localhost ~]# vi /etc/fstab ###下面配置参数是新增

/dev/cdrom /mnt iso9660 defaults 0 0

3、关防火墙

[root@localhost ~]# systemctl stop firewalld.service ##临时关闭

[root@localhost ~]# systemctl disable firewalld.service ##重启永久关闭

4、关核心防护

[root@localhost ~]# setenforce 0 ##临时关闭

[root@localhost ~]# vi /etc/sysconfig/selinux ##重启永久关闭

SELINUX=disabled ##更改

5、重启系统

[root@localhost ~]# init 6

[root@localhost ~]# cd /opt
[root@localhost opt]# ls
rh
[root@localhost opt]# cd /etc
[root@localhost etc]# cd yum
yum/         yum.repos.d/ 
[root@localhost etc]# cd yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Me
[root@localhost yum.repos.d]# mkdir backup
[root@localhost yum.repos.d]# ls
backup  CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  C
[root@localhost yum.repos.d]# mv C* backup
[root@localhost yum.repos.d]# ls
backup
[root@localhost yum.repos.d]# vim local.repo

[local]
name=local
baseurl=file:///mnt
gpgcheck=0

[root@localhost yum.repos.d]# ls
backup  local.repo
[root@localhost yum.repos.d]# rm -rf local.repo 
[root@localhost yum.repos.d]# vim local.repo
[root@localhost yum.repos.d]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost yum.repos.d]# df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sda3      xfs        36G  4.7G   32G  13% /
devtmpfs       devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs          tmpfs     1.9G     0  1.9G   0% /dev/shm
tmpfs          tmpfs     1.9G  9.2M  1.9G   1% /run
tmpfs          tmpfs     1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1      xfs       297M  157M  141M  53% /boot
tmpfs          tmpfs     378M  4.0K  378M   1% /run/user/42
tmpfs          tmpfs     378M   44K  378M   1% /run/user/1000
/dev/sr1       iso9660   4.3G  4.3G     0 100% /run/media/richard/CentOS 7 x86_64
/dev/sr0       iso9660   4.3G  4.3G     0 100% /mnt
tmpfs          tmpfs     378M     0  378M   0% /run/user/0
[root@localhost yum.repos.d]# vim /etc/fstab 
#添加永久挂载 /dev/cdrom /mnt iso9660 defaults 0 0
[root@localhost yum.repos.d]# yum clean all && yum makecache
Loaded plugins: fastestmirror, langpacks
Cleaning repos: local
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror, langpacks
local                                                            | 3.6 kB  00:00:00     
(1/4): local/group_gz                                            | 156 kB  00:00:00     
(2/4): local/filelists_db                                        | 3.1 MB  00:00:00     
(3/4): local/primary_db                                          | 3.1 MB  00:00:00     
(4/4): local/other_db                                            | 1.2 MB  00:00:00     
Determining fastest mirrors
Metadata Cache Created
[root@localhost yum.repos.d]# yum -y install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-67.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-67.el7.centos for package: httpd-2.4.6-67.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-67.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.x86_64
--> Running transaction check
---> 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 0:2.4.6-67.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package              Arch            Version                      Repository      Size
========================================================================================
Installing:
 httpd                x86_64          2.4.6-67.el7.centos          local          2.7 M
Installing for dependencies:
 apr                  x86_64          1.4.8-3.el7                  local          103 k
 apr-util             x86_64          1.5.2-6.el7                  local           92 k
 httpd-tools          x86_64          2.4.6-67.el7.centos          local           87 k
 mailcap              noarch          2.1.41-2.el7                 local           31 k

Transaction Summary
========================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
----------------------------------------------------------------------------------------
Total                                                       93 MB/s | 3.0 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                               1/5 
  Installing : apr-util-1.5.2-6.el7.x86_64                                          2/5 
  Installing : httpd-tools-2.4.6-67.el7.centos.x86_64                               3/5 
  Installing : mailcap-2.1.41-2.el7.noarch                                          4/5 
  Installing : httpd-2.4.6-67.el7.centos.x86_64                                     5/5 
  Verifying  : httpd-2.4.6-67.el7.centos.x86_64                                     1/5 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                          2/5 
  Verifying  : apr-1.4.8-3.el7.x86_64                                               3/5 
  Verifying  : httpd-tools-2.4.6-67.el7.centos.x86_64                               4/5 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                          5/5 

Installed:
  httpd.x86_64 0:2.4.6-67.el7.centos                                                    

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                         apr-util.x86_64 0:1.5.2-6.el7        
  httpd-tools.x86_64 0:2.4.6-67.el7.centos         mailcap.noarch 0:2.1.41-2.el7        

Complete!
[root@localhost yum.repos.d]# 

#####

####搭建线网YUM仓库#####

服务端:

[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# mkdir -p /var/ftp/centos7
[root@localhost ftp]# cp -rf /mnt/* /var/ftp/centos7/
[root@localhost ftp]# systemctl start vsftpdf
Failed to start vsftpdf.service: Unit not found.
[root@localhost ftp]# systemctl start vsftpd
[root@localhost ftp]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@localhost ftp]# setenforce 0
[root@localhost ftp]# systemctl stop firewalld
[root@localhost ftp]# 

客户端:

[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/sysconfig/selinux
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
total 28
-rw-r--r--. 1 root root 1664 Aug 30  2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Aug 30  2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Aug 30  2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Aug 30  2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Aug 30  2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Aug 30  2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 Aug 30  2017 CentOS-Vault.repo
[root@localhost yum.repos.d]# mkdir backup
[root@localhost yum.repos.d]# mv C* backup
[root@localhost yum.repos.d]# vim local.repo

[local]
name=local
baseurl=ftp://192.168.179.20/centos7
gpgcheck=0

[root@localhost yum.repos.d]# yum -y install dhcp
Loaded plugins: fastestmirror, langpacks
local                                                            | 3.6 kB  00:00:00     
(1/2): local/group_gz                                            | 156 kB  00:00:00     
(2/2): local/primary_db                                          | 3.1 MB  00:00:00     
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-58.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package        Arch             Version                          Repository       Size
========================================================================================
Installing:
 dhcp           x86_64           12:4.2.5-58.el7.centos           local           513 k

Transaction Summary
========================================================================================
Install  1 Package

Total download size: 513 k
Installed size: 1.4 M
Downloading packages:
dhcp-4.2.5-58.el7.centos.x86_64.rpm                              | 513 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 12:dhcp-4.2.5-58.el7.centos.x86_64                                   1/1 
  Verifying  : 12:dhcp-4.2.5-58.el7.centos.x86_64                                   1/1 

Installed:
  dhcp.x86_64 12:4.2.5-58.el7.centos                                                    

Complete!
[root@localhost yum.repos.d]# 

搭建在线YUM

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2023-03-10 02:04:18--  https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 222.186.149.91, 222.186.149.105, 222.186.149.90, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|222.186.149.91|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

100%[==============================================>] 2,523       --.-K/s   in 0.001s  

2023-03-10 02:04:18 (1.86 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]

[root@localhost yum.repos.d]# ls
backup  CentOS-Base.repo  local.repo
[root@localhost yum.repos.d]# mv local.repo backup/
[root@localhost yum.repos.d]# ls
backup  CentOS-Base.repo
[root@localhost yum.repos.d]# yum clean all && yum makecache
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror, langpacks
base                                                             | 3.6 kB  00:00:00     
extras                                                           | 2.9 kB  00:00:00     
updates                                                          | 2.9 kB  00:00:00     
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known"
Trying other mirror.
(1/10): base/7/x86_64/group_gz                                   | 153 kB  00:00:00     
(2/10): extras/7/x86_64/filelists_db                             | 276 kB  00:00:00     
(3/10): extras/7/x86_64/other_db                                 | 149 kB  00:00:00     
(4/10): base/7/x86_64/other_db                                   | 2.6 MB  00:00:04     
(5/10): updates/7/x86_64/filelists_db                            |  11 MB  00:00:15     
extras/7/x86_64/primary_db     FAILED                                          0:38 ETA 
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/511a574b4c3f907f9acfe5603566958fb6f09137292c5cd5d5d57c298864790f-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
base/7/x86_64/filelists_db     FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(6/10): extras/7/x86_64/primary_db                               | 249 kB  00:00:00     
updates/7/x86_64/primary_db    FAILED                                          
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/bc8950506fb13622afd9eb93c811884b6e2e7570afd5fac946f708ac01ae0cff-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(7/10): base/7/x86_64/primary_db                                 | 6.1 MB  00:00:07     
updates/7/x86_64/other_db      FAILED                                          0:15 ETA 
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/33c5109226f2c5e469c8519c6102af5a7fe9fa4064ef8621e296da454197f370-other.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(8/10): updates/7/x86_64/other_db                                | 1.3 MB  00:00:01     
(9/10): base/7/x86_64/filelists_db                               | 7.2 MB  00:00:08     
(10/10): updates/7/x86_64/primary_db                             |  20 MB  00:00:24     
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Metadata Cache Created
[root@localhost yum.repos.d]# yum -y install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-98.el7.centos.6 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-98.el7.centos.6 for package: httpd-2.4.6-98.el7.centos.6.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-98.el7.centos.6.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-98.el7.centos.6.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-98.el7.centos.6.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-98.el7.centos.6 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package             Arch           Version                       Repository       Size
========================================================================================
Installing:
 httpd               x86_64         2.4.6-98.el7.centos.6         updates         2.7 M
Installing for dependencies:
 apr                 x86_64         1.4.8-7.el7                   base            104 k
 apr-util            x86_64         1.5.2-6.el7                   base             92 k
 httpd-tools         x86_64         2.4.6-98.el7.centos.6         updates          94 k
 mailcap             noarch         2.1.41-2.el7                  base             31 k

Transaction Summary
========================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/apr-1.4.8-7.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for apr-1.4.8-7.el7.x86_64.rpm is not installed
(1/5): apr-1.4.8-7.el7.x86_64.rpm                                | 104 kB  00:00:00     
(2/5): apr-util-1.5.2-6.el7.x86_64.rpm                           |  92 kB  00:00:00     
Public key for httpd-tools-2.4.6-98.el7.centos.6.x86_64.rpm is not installed
(3/5): httpd-tools-2.4.6-98.el7.centos.6.x86_64.rpm              |  94 kB  00:00:00     
(4/5): mailcap-2.1.41-2.el7.noarch.rpm                           |  31 kB  00:00:00     
(5/5): httpd-2.4.6-98.el7.centos.6.x86_64.rpm                    | 2.7 MB  00:00:09     
----------------------------------------------------------------------------------------
Total                                                      315 kB/s | 3.0 MB  00:09     
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 From       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-7.el7.x86_64                                               1/5 
  Installing : apr-util-1.5.2-6.el7.x86_64                                          2/5 
  Installing : httpd-tools-2.4.6-98.el7.centos.6.x86_64                             3/5 
  Installing : mailcap-2.1.41-2.el7.noarch                                          4/5 
  Installing : httpd-2.4.6-98.el7.centos.6.x86_64                                   5/5 
  Verifying  : httpd-tools-2.4.6-98.el7.centos.6.x86_64                             1/5 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                          2/5 
  Verifying  : apr-1.4.8-7.el7.x86_64                                               3/5 
  Verifying  : httpd-2.4.6-98.el7.centos.6.x86_64                                   4/5 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                          5/5 

Installed:
  httpd.x86_64 0:2.4.6-98.el7.centos.6                                                  

Dependency Installed:
  apr.x86_64 0:1.4.8-7.el7                          apr-util.x86_64 0:1.5.2-6.el7       
  httpd-tools.x86_64 0:2.4.6-98.el7.centos.6        mailcap.noarch 0:2.1.41-2.el7       

Complete!
[root@localhost yum.repos.d]# 

###上述服务端的yum仓库是有依赖关系的,如果没有依赖关系,如何解决呢?###

##登录服务端 192.168.100.31##

[root@localhost centos7]# cd /var/ftp/centos7/

[root@localhost centos7]# rm -rf * ####线网 中 这是高危命令,不要乱敲###

#Xftp上传rpm软件包#这边用第三方的rpm包源 没有依赖关系

登录192.168.100.31 进入/var/ftp/centos7/ 的目录上传第三方 yum 源。没有repodata ,接下来解决依赖关系

##解决依赖关系,生成软件包关系####repodata

rpm -ivh /mnt/Packages/createrepo-0.9.9-18.el6.noarch.rpm ###如果没装createrepo 安装createrepo##

解决依赖关系要先装deltarpm-3.5-* python-deltarpm-3.5* ###

[root@localhost centos7]# cd /var/ftp/centos7/

[root@localhost centos7]# createrepo -v ./ #####自动生成依赖关系,这个在那个目录。

实验如下:

服务机:

[root@localhost ftp]# cd /var/ftp/centos7/
[root@localhost centos7]# rm -rf *
[root@localhost centos7]# ls

客户机:

[root@localhost yum.repos.d]# yum -y install  httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-67.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================
 Package       Arch           Version                     Repository     Size
==============================================================================
Installing:
 httpd         x86_64         2.4.6-67.el7.centos         local         2.7 M

Transaction Summary
==============================================================================
Install  1 Package

Total download size: 2.7 M
Installed size: 9.4 M
Downloading packages:
httpd-2.4.6-67.el7.centos.x86_ FAILED                                          
ftp://192.168.179.20/centos7/Packages/httpd-2.4.6-67.el7.centos.x86_64.rpm: [Errno 14] FTP Error 550 - Server denied you to change to the given directory
Trying other mirror.


Error downloading packages:
  httpd-2.4.6-67.el7.centos.x86_64: [Errno 256] No more mirrors to try.

#####问题解决方案 ,如果vsftp有问题。刷下面配置参数####

[root@localhost /]# vi /etc/vsftpd/vsftpd.conf ####编辑vsftpd.conf

##############清空里面内容,刷下面脚本这是开启匿名访问的#######

anonymous_enable=YES

#anon_upload_enable=YES

#anon_mkdir_write_enable=YES

#anon_other_write_enable=YES

anon_umask=022

local_enable=YES

local_max_rate=102400

chroot_local_user=yes

write_enable=YES

local_umask=022

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

#######################vsftp服务开启和查看状态###############################

[root@localhost vsftpd]# systemctl start vsftpd

[root@localhost vsftpd]# systemctl status vsftpd

#######################在连接虚拟机,使用ftp工具登录#######

在另外一台装ftp 客户端测试下

rpm -ivh /mnt/Packages/ftp-*

输入IP地址:192.168.32.11 (这是虚拟机服务器的IP地址)

账号:ftp

密码:空的 #密码不要输入

#进去后,做相关的下载、删除测试。

#################设置客户端######

cd /etc/yum.repos.d

ls

vi local.repo

####

[yum]

name=centos6

baseurl=ftp://192.168.32.187/centos7

enabled=1 ##0 不开启

gpgcheck=0 ##0不验证

[yum]

name=docker

baseurl=ftp://192.168.32.187/docker

enabled=1 ##0 不开启

gpgcheck=0 ##0不验证

####

在yum.repos.d 中有些不用的yum文件,个人建议放到其他目录中

在里面新建个backup文件,其他的文件都移到这个文件夹中

####

####

设置本地文件源yum

####

[yum]

name=centos

baseurl=file:///mnt ###这边也可以写成file:/mnt

enabled=1 ##0 不开启

gpgcheck=0 ##0不验证

[Local]

name=CentOS-$releasever - Base

baseurl=file:///mnt

enabled=1

gpgcheck=0

Network File System 网络文件系统

依赖于RPC(远程过程调用)

系统服务:nfs/rpcbind

1. 安装nfs-utils、rpcbind软件包

2. 设置共享目录

NFS服务:

2台

一台服务器:nfs-utils rpcbind

vi /etc/exports

/opt/share 20.0.0.0/24(ro,sync)

/opt/share1 20.0.0.54(rw,sync)

一台客户机:mount

yum -y install nfs-utils

systemctl start rpcbind//先启动

systemctl start nfs//后启动

mount 20.0.0.55:/opt/share /opt/share

mount 20.0.0.55:/opt/share1 /opt/share1

#####关于读写权限#######

一个是配置文件(vi /etc/exports (rw,sync))

一个是文件目录权限 (参考所用程序账户来决定)

环境准备、配置服务端

[root@localhost ~]# yum -y install nfs-utils rpcbind
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 12310.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 201 M RSS (1.5 GB VSZ)
    Started: Fri Mar 10 02:21:28 2023 - 03:38 ago
    State  : Sleeping, pid: 12310
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 201 M RSS (1.5 GB VSZ)
    Started: Fri Mar 10 02:21:28 2023 - 03:40 ago
    State  : Sleeping, pid: 12310
^C

Exiting on user cancel.
[root@localhost ~]# rm -rf /var/run/yum.pid 
[root@localhost ~]# yum -y install nfs-utils rpcbind
Loaded plugins: fastestmirror, langpacks
base                                                             | 3.6 kB  00:00:00     
extras                                                           | 2.9 kB  00:00:00     
updates                                                          | 2.9 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.3.0-0.48.el7 will be updated
---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be an update
---> Package rpcbind.x86_64 0:0.2.0-42.el7 will be updated
---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package            Arch            Version                      Repository        Size
========================================================================================
Updating:
 nfs-utils          x86_64          1:1.3.0-0.68.el7.2           updates          413 k
 rpcbind            x86_64          0.2.0-49.el7                 base              60 k

Transaction Summary
========================================================================================
Upgrade  2 Packages

Total size: 473 k
Total download size: 413 k
Downloading packages:
No Presto metadata available for updates
warning: /var/cache/yum/x86_64/7/updates/packages/nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm is not installed
nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm                            | 413 kB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : rpcbind-0.2.0-49.el7.x86_64                                          1/4 
  Updating   : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64                                  2/4 
  Cleanup    : 1:nfs-utils-1.3.0-0.48.el7.x86_64                                    3/4 
  Cleanup    : rpcbind-0.2.0-42.el7.x86_64                                          4/4 
  Verifying  : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64                                  1/4 
  Verifying  : rpcbind-0.2.0-49.el7.x86_64                                          2/4 
  Verifying  : rpcbind-0.2.0-42.el7.x86_64                                          3/4 
  Verifying  : 1:nfs-utils-1.3.0-0.48.el7.x86_64                                    4/4 

Updated:
  nfs-utils.x86_64 1:1.3.0-0.68.el7.2           rpcbind.x86_64 0:0.2.0-49.el7          

Complete!
[root@localhost ~]# vim /etc/exports
[root@localhost ~]# netstat -anpu | grep rpcbind
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# netstat -anpu | grep rpcbind
udp        0      0 0.0.0.0:880             0.0.0.0:*                           14698/rpcbind       
udp        0      0 0.0.0.0:111             0.0.0.0:*                           14698/rpcbind       
udp6       0      0 :::880                  :::*                                14698/rpcbind       
udp6       0      0 :::111                  :::*                                14698/rpcbind       
[root@localhost ~]# mkdir /opt/pub
[root@localhost ~]# chown nfsnobody /opt/pub/

配置客户端:

[root@localhost ~]# yum -y install nfs-utils rpcbind
Loaded plugins: fastestmirror, langpacks
base                                                             | 3.6 kB  00:00:00     
extras                                                           | 2.9 kB  00:00:00     
updates                                                          | 2.9 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.3.0-0.48.el7 will be updated
---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be an update
---> Package rpcbind.x86_64 0:0.2.0-42.el7 will be updated
---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package            Arch            Version                      Repository        Size
========================================================================================
Updating:
 nfs-utils          x86_64          1:1.3.0-0.68.el7.2           updates          413 k
 rpcbind            x86_64          0.2.0-49.el7                 base              60 k

Transaction Summary
========================================================================================
Upgrade  2 Packages

Total size: 473 k
Total download size: 413 k
Downloading packages:
No Presto metadata available for updates
warning: /var/cache/yum/x86_64/7/updates/packages/nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm is not installed
nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm                            | 413 kB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : rpcbind-0.2.0-49.el7.x86_64                                          1/4 
  Updating   : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64                                  2/4 
  Cleanup    : 1:nfs-utils-1.3.0-0.48.el7.x86_64                                    3/4 
  Cleanup    : rpcbind-0.2.0-42.el7.x86_64                                          4/4 
  Verifying  : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64                                  1/4 
  Verifying  : rpcbind-0.2.0-49.el7.x86_64                                          2/4 
  Verifying  : rpcbind-0.2.0-42.el7.x86_64                                          3/4 
  Verifying  : 1:nfs-utils-1.3.0-0.48.el7.x86_64                                    4/4 

Updated:
  nfs-utils.x86_64 1:1.3.0-0.68.el7.2           rpcbind.x86_64 0:0.2.0-49.el7          

Complete!
[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/sysconfig/selinux
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
total 28
-rw-r--r--. 1 root root 1664 Aug 30  2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Aug 30  2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Aug 30  2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Aug 30  2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Aug 30  2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Aug 30  2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 Aug 30  2017 CentOS-Vault.repo
[root@localhost yum.repos.d]# mkdir backup
[root@localhost yum.repos.d]# mv C* backup
[root@localhost yum.repos.d]# vim local.repo
[root@localhost yum.repos.d]# yum -y install dhcp
Loaded plugins: fastestmirror, langpacks
local                                                            | 3.6 kB  00:00:00     
(1/2): local/group_gz                                            | 156 kB  00:00:00     
(2/2): local/primary_db                                          | 3.1 MB  00:00:00     
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-58.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package        Arch             Version                          Repository       Size
========================================================================================
Installing:
 dhcp           x86_64           12:4.2.5-58.el7.centos           local           513 k

Transaction Summary
========================================================================================
Install  1 Package

Total download size: 513 k
Installed size: 1.4 M
Downloading packages:
dhcp-4.2.5-58.el7.centos.x86_64.rpm                              | 513 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 12:dhcp-4.2.5-58.el7.centos.x86_64                                   1/1 
  Verifying  : 12:dhcp-4.2.5-58.el7.centos.x86_64                                   1/1 

Installed:
  dhcp.x86_64 12:4.2.5-58.el7.centos                                                    

Complete!
[root@localhost yum.repos.d]# vim local.repo
[root@localhost yum.repos.d]# 
Socket error Event: 32 Error: 10053.
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(备用1) at 18:11:22.

Type `help' to learn how to use Xshell prompt.
[C:\~]$ 

Connecting to 192.168.179.21:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Thu Mar  9 18:19:08 2023
[root@localhost ~]# yum -y install nfs-utils.x86_64 rpcbind.x86_64 
Loaded plugins: fastestmirror, langpacks
base                                                             | 3.6 kB  00:00:00     
extras                                                           | 2.9 kB  00:00:00     
updates                                                          | 2.9 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.3.0-0.48.el7 will be updated
---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be an update
---> Package rpcbind.x86_64 0:0.2.0-42.el7 will be updated
---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package            Arch            Version                      Repository        Size
========================================================================================
Updating:
 nfs-utils          x86_64          1:1.3.0-0.68.el7.2           updates          413 k
 rpcbind            x86_64          0.2.0-49.el7                 base              60 k

Transaction Summary
========================================================================================
Upgrade  2 Packages

Total size: 473 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/updates/packages/nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : rpcbind-0.2.0-49.el7.x86_64                                          1/4 
  Updating   : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64                                  2/4 
  Cleanup    : 1:nfs-utils-1.3.0-0.48.el7.x86_64                                    3/4 
  Cleanup    : rpcbind-0.2.0-42.el7.x86_64                                          4/4 
  Verifying  : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64                                  1/4 
  Verifying  : rpcbind-0.2.0-49.el7.x86_64                                          2/4 
  Verifying  : rpcbind-0.2.0-42.el7.x86_64                                          3/4 
  Verifying  : 1:nfs-utils-1.3.0-0.48.el7.x86_64                                    4/4 

Updated:
  nfs-utils.x86_64 1:1.3.0-0.68.el7.2           rpcbind.x86_64 0:0.2.0-49.el7          

Complete!
[root@localhost ~]# 
[root@localhost ~]# systemctl start rpcbind.service 
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# showmount -e 192.168.179.20
Export list for 192.168.179.20:
/usr/share 192.168.179.0/24
/opt/pub   192.168.179.21
[root@localhost ~]# mount 192.168.179.20:/usr/share /media
[root@localhost ~]# ls /usr
bin  etc  games  include  lib  lib64  libexec  local  sbin  share  src  tmp
[root@localhost ~]# df -hT
Filesystem                Type      Size  Used Avail Use% Mounted on
/dev/sda3                 xfs        38G  4.7G   34G  13% /
devtmpfs                  devtmpfs  898M     0  898M   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       297M  157M  141M  53% /boot
tmpfs                     tmpfs     183M  8.0K  183M   1% /run/user/42
tmpfs                     tmpfs     183M     0  183M   0% /run/user/0
tmpfs                     tmpfs     183M   32K  183M   1% /run/user/1000
192.168.179.20:/usr/share nfs4       36G  4.7G   32G  13% /media
[root@localhost ~]# cd /srv
[root@localhost srv]# ll
total 0
[root@localhost srv]# touch 1.txt
[root@localhost srv]# ls
1.txt
[root@localhost srv]# 
Socket error Event: 32 Error: 10053.
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(备用1) at 18:24:23.

Type `help' to learn how to use Xshell prompt.
[C:\~]$ 

Connecting to 192.168.179.21:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Thu Mar  9 18:19:08 2023
[root@localhost ~]# yum -y install nfs-utils rpcbind
Loaded plugins: fastestmirror, langpacks
base                                                             | 3.6 kB  00:00:00     
extras                                                           | 2.9 kB  00:00:00     
updates                                                          | 2.9 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.3.0-0.48.el7 will be updated
---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be an update
---> Package rpcbind.x86_64 0:0.2.0-42.el7 will be updated
---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package            Arch            Version                      Repository        Size
========================================================================================
Updating:
 nfs-utils          x86_64          1:1.3.0-0.68.el7.2           updates          413 k
 rpcbind            x86_64          0.2.0-49.el7                 base              60 k

Transaction Summary
========================================================================================
Upgrade  2 Packages

Total size: 473 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/updates/packages/nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : rpcbind-0.2.0-49.el7.x86_64                                          1/4 
  Updating   : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64                                  2/4 
  Cleanup    : 1:nfs-utils-1.3.0-0.48.el7.x86_64                                    3/4 
  Cleanup    : rpcbind-0.2.0-42.el7.x86_64                                          4/4 
  Verifying  : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64                                  1/4 
  Verifying  : rpcbind-0.2.0-49.el7.x86_64                                          2/4 
  Verifying  : rpcbind-0.2.0-42.el7.x86_64                                          3/4 
  Verifying  : 1:nfs-utils-1.3.0-0.48.el7.x86_64                                    4/4 

Updated:
  nfs-utils.x86_64 1:1.3.0-0.68.el7.2           rpcbind.x86_64 0:0.2.0-49.el7          

Complete!
[root@localhost ~]# systemctl s
set-default       show              start             suspend
set-environment   show-environment  status            switch-root
set-property      snapshot          stop              
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# showmount -e 192.168.179.20
Export list for 192.168.179.20:
/usr/share 192.168.179.0/24
/opt/pub   192.168.179.21
[root@localhost ~]# mount 192.168.179.20:/usr/share /media/
[root@localhost ~]# df -Th
Filesystem                Type      Size  Used Avail Use% Mounted on
/dev/sda3                 xfs        38G  4.7G   34G  13% /
devtmpfs                  devtmpfs  898M     0  898M   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       297M  157M  141M  53% /boot
tmpfs                     tmpfs     183M  8.0K  183M   1% /run/user/42
tmpfs                     tmpfs     183M     0  183M   0% /run/user/0
tmpfs                     tmpfs     183M   28K  183M   1% /run/user/1000
192.168.179.20:/usr/share nfs4       36G  4.4G   32G  13% /media
[root@localhost ~]# vim /etc/fstab 
[root@localhost ~]# init 6                #重启
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(备用1) at 18:29:49.

在客户端写入:

Type `help' to learn how to use Xshell prompt.
[C:\~]$ 

Connecting to 192.168.179.21:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Fri Mar 10 02:24:53 2023 from 192.168.179.1
[root@localhost ~]# cd /srv
[root@localhost srv]# ll
total 0
[root@localhost srv]# touch 1.txt
[root@localhost srv]# ls
1.txt
[root@localhost srv]# 

服务端查看:

[root@localhost ~]# cd /opt/pub/
[root@localhost pub]# ls
1.txt
[root@localhost pub]# ll
total 0
-rw-r--r--. 1 nfsnobody nfsnobody 0 Mar 10 02:30 1.txt
[root@localhost pub]# 
####搭建NFS共享服务###
##环境准备##
1、准备2台centos服务器
192.168.100.31 ###服务端
192.168.100.32 ###客户端
##配置服务端192.168.100.31 ##
yum -y install nfs-utils rpcbind
vi /etc/exports
/usr/share 192.168.100.0/24(ro,sync)
/opt/pub 192.168.100.32(rw,sync)
systemctl start rpcbind //先启动
systemctl start nfs //后启动
netstat -anpu | grep rpcbind //UDP 111端口在监听
[root@localhost ~]# mkdir /opt/pub
chown nfsnobody /opt/pub/
##配置客户端192.168.100.32 ##
------------以下在客户端操作---------
yum install nfs-utils
systemctl start rpcbind //先启动
systemctl start nfs //后启动
[root@localhost ~]# showmount -e 192.168.100.31
Export list for 192.168.100.31:
/usr/share 192.168.100.0/24
/opt/pub 192.168.100.32
mount 192.168.100.31:/usr/share /media/
[root@localhost ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 50G 3.6G 47G 8% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 9.0M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-home xfs 245G 33M 245G 1% /home
/dev/sda1 xfs 1014M 179M 836M 18% /boot
tmpfs tmpfs 378M 32K 378M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
192.168.100.31:/usr/share nfs4 50G 3.9G 47G 8% /media
##配置服务端192.168.100.32 ##
--------以下实现自动挂载----------
vi /etc/fstab
192.168.100.31:/opt/pub /srv nfs defaults,_netdev 0 0
init 6 ###重启
##验证在192.168.100.32##
[root@localhost ~]# cd /srv/
[root@localhost srv]# ll
总用量 0
[root@localhost srv]# touch 1.txt
[root@localhost srv]# vi 1.txt
##验证在192.168.100.31##
[root@localhost ~]# cd /opt/pub/
[root@localhost pub]# ll
总用量 4
-rw-r--r-- 1 nfsnobody nfsnobody 11 1月 2 08:25 1.txt ####能写功能正常/opt/pub 192.168.100.32(rw,sync) 生效##

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

R1chArd_TvT

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值