当前位置:   article > 正文

部署YUM仓库及NFS共享_yum install nfs-utils

yum install nfs-utils

部署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

  1. [root@localhost ~]# cd /opt
  2. [root@localhost opt]# ls
  3. rh
  4. [root@localhost opt]# cd /etc
  5. [root@localhost etc]# cd yum
  6. yum/ yum.repos.d/
  7. [root@localhost etc]# cd yum.repos.d/
  8. [root@localhost yum.repos.d]# ls
  9. CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Me
  10. [root@localhost yum.repos.d]# mkdir backup
  11. [root@localhost yum.repos.d]# ls
  12. backup CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo C
  13. [root@localhost yum.repos.d]# mv C* backup
  14. [root@localhost yum.repos.d]# ls
  15. backup
  16. [root@localhost yum.repos.d]# vim local.repo
  17. [local]
  18. name=local
  19. baseurl=file:///mnt
  20. gpgcheck=0
  21. [root@localhost yum.repos.d]# ls
  22. backup local.repo
  23. [root@localhost yum.repos.d]# rm -rf local.repo
  24. [root@localhost yum.repos.d]# vim local.repo
  25. [root@localhost yum.repos.d]# mount /dev/cdrom /mnt
  26. mount: /dev/sr0 is write-protected, mounting read-only
  27. [root@localhost yum.repos.d]# df -hT
  28. Filesystem Type Size Used Avail Use% Mounted on
  29. /dev/sda3 xfs 36G 4.7G 32G 13% /
  30. devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
  31. tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
  32. tmpfs tmpfs 1.9G 9.2M 1.9G 1% /run
  33. tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
  34. /dev/sda1 xfs 297M 157M 141M 53% /boot
  35. tmpfs tmpfs 378M 4.0K 378M 1% /run/user/42
  36. tmpfs tmpfs 378M 44K 378M 1% /run/user/1000
  37. /dev/sr1 iso9660 4.3G 4.3G 0 100% /run/media/richard/CentOS 7 x86_64
  38. /dev/sr0 iso9660 4.3G 4.3G 0 100% /mnt
  39. tmpfs tmpfs 378M 0 378M 0% /run/user/0
  40. [root@localhost yum.repos.d]# vim /etc/fstab
  41. #添加永久挂载 /dev/cdrom /mnt iso9660 defaults 0 0
  42. [root@localhost yum.repos.d]# yum clean all && yum makecache
  43. Loaded plugins: fastestmirror, langpacks
  44. Cleaning repos: local
  45. Cleaning up everything
  46. Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
  47. Cleaning up list of fastest mirrors
  48. Loaded plugins: fastestmirror, langpacks
  49. local | 3.6 kB 00:00:00
  50. (1/4): local/group_gz | 156 kB 00:00:00
  51. (2/4): local/filelists_db | 3.1 MB 00:00:00
  52. (3/4): local/primary_db | 3.1 MB 00:00:00
  53. (4/4): local/other_db | 1.2 MB 00:00:00
  54. Determining fastest mirrors
  55. Metadata Cache Created
  56. [root@localhost yum.repos.d]# yum -y install httpd
  57. Loaded plugins: fastestmirror, langpacks
  58. Loading mirror speeds from cached hostfile
  59. Resolving Dependencies
  60. --> Running transaction check
  61. ---> Package httpd.x86_64 0:2.4.6-67.el7.centos will be installed
  62. --> Processing Dependency: httpd-tools = 2.4.6-67.el7.centos for package: httpd-2.4.6-67.el7.centos.x86_64
  63. --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-67.el7.centos.x86_64
  64. --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.x86_64
  65. --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.x86_64
  66. --> Running transaction check
  67. ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
  68. ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
  69. ---> Package httpd-tools.x86_64 0:2.4.6-67.el7.centos will be installed
  70. ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
  71. --> Finished Dependency Resolution
  72. Dependencies Resolved
  73. ========================================================================================
  74. Package Arch Version Repository Size
  75. ========================================================================================
  76. Installing:
  77. httpd x86_64 2.4.6-67.el7.centos local 2.7 M
  78. Installing for dependencies:
  79. apr x86_64 1.4.8-3.el7 local 103 k
  80. apr-util x86_64 1.5.2-6.el7 local 92 k
  81. httpd-tools x86_64 2.4.6-67.el7.centos local 87 k
  82. mailcap noarch 2.1.41-2.el7 local 31 k
  83. Transaction Summary
  84. ========================================================================================
  85. Install 1 Package (+4 Dependent packages)
  86. Total download size: 3.0 M
  87. Installed size: 10 M
  88. Downloading packages:
  89. ----------------------------------------------------------------------------------------
  90. Total 93 MB/s | 3.0 MB 00:00
  91. Running transaction check
  92. Running transaction test
  93. Transaction test succeeded
  94. Running transaction
  95. Installing : apr-1.4.8-3.el7.x86_64 1/5
  96. Installing : apr-util-1.5.2-6.el7.x86_64 2/5
  97. Installing : httpd-tools-2.4.6-67.el7.centos.x86_64 3/5
  98. Installing : mailcap-2.1.41-2.el7.noarch 4/5
  99. Installing : httpd-2.4.6-67.el7.centos.x86_64 5/5
  100. Verifying : httpd-2.4.6-67.el7.centos.x86_64 1/5
  101. Verifying : mailcap-2.1.41-2.el7.noarch 2/5
  102. Verifying : apr-1.4.8-3.el7.x86_64 3/5
  103. Verifying : httpd-tools-2.4.6-67.el7.centos.x86_64 4/5
  104. Verifying : apr-util-1.5.2-6.el7.x86_64 5/5
  105. Installed:
  106. httpd.x86_64 0:2.4.6-67.el7.centos
  107. Dependency Installed:
  108. apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7
  109. httpd-tools.x86_64 0:2.4.6-67.el7.centos mailcap.noarch 0:2.1.41-2.el7
  110. Complete!
  111. [root@localhost yum.repos.d]#

#####

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

服务端:

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

客户端:

  1. [root@localhost ~]# systemctl stop firewalld.service
  2. [root@localhost ~]# setenforce 0
  3. [root@localhost ~]# vim /etc/sysconfig/selinux
  4. [root@localhost ~]# cd /etc/yum.repos.d/
  5. [root@localhost yum.repos.d]# ll
  6. total 28
  7. -rw-r--r--. 1 root root 1664 Aug 30 2017 CentOS-Base.repo
  8. -rw-r--r--. 1 root root 1309 Aug 30 2017 CentOS-CR.repo
  9. -rw-r--r--. 1 root root 649 Aug 30 2017 CentOS-Debuginfo.repo
  10. -rw-r--r--. 1 root root 314 Aug 30 2017 CentOS-fasttrack.repo
  11. -rw-r--r--. 1 root root 630 Aug 30 2017 CentOS-Media.repo
  12. -rw-r--r--. 1 root root 1331 Aug 30 2017 CentOS-Sources.repo
  13. -rw-r--r--. 1 root root 3830 Aug 30 2017 CentOS-Vault.repo
  14. [root@localhost yum.repos.d]# mkdir backup
  15. [root@localhost yum.repos.d]# mv C* backup
  16. [root@localhost yum.repos.d]# vim local.repo
  17. [local]
  18. name=local
  19. baseurl=ftp://192.168.179.20/centos7
  20. gpgcheck=0
  21. [root@localhost yum.repos.d]# yum -y install dhcp
  22. Loaded plugins: fastestmirror, langpacks
  23. local | 3.6 kB 00:00:00
  24. (1/2): local/group_gz | 156 kB 00:00:00
  25. (2/2): local/primary_db | 3.1 MB 00:00:00
  26. Loading mirror speeds from cached hostfile
  27. Resolving Dependencies
  28. --> Running transaction check
  29. ---> Package dhcp.x86_64 12:4.2.5-58.el7.centos will be installed
  30. --> Finished Dependency Resolution
  31. Dependencies Resolved
  32. ========================================================================================
  33. Package Arch Version Repository Size
  34. ========================================================================================
  35. Installing:
  36. dhcp x86_64 12:4.2.5-58.el7.centos local 513 k
  37. Transaction Summary
  38. ========================================================================================
  39. Install 1 Package
  40. Total download size: 513 k
  41. Installed size: 1.4 M
  42. Downloading packages:
  43. dhcp-4.2.5-58.el7.centos.x86_64.rpm | 513 kB 00:00:00
  44. Running transaction check
  45. Running transaction test
  46. Transaction test succeeded
  47. Running transaction
  48. Installing : 12:dhcp-4.2.5-58.el7.centos.x86_64 1/1
  49. Verifying : 12:dhcp-4.2.5-58.el7.centos.x86_64 1/1
  50. Installed:
  51. dhcp.x86_64 12:4.2.5-58.el7.centos
  52. Complete!
  53. [root@localhost yum.repos.d]#

搭建在线YUM

  1. [root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  2. --2023-03-10 02:04:18-- https://mirrors.aliyun.com/repo/Centos-7.repo
  3. Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 222.186.149.91, 222.186.149.105, 222.186.149.90, ...
  4. Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|222.186.149.91|:443... connected.
  5. HTTP request sent, awaiting response... 200 OK
  6. Length: 2523 (2.5K) [application/octet-stream]
  7. Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
  8. 100%[==============================================>] 2,523 --.-K/s in 0.001s
  9. 2023-03-10 02:04:18 (1.86 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
  10. [root@localhost yum.repos.d]# ls
  11. backup CentOS-Base.repo local.repo
  12. [root@localhost yum.repos.d]# mv local.repo backup/
  13. [root@localhost yum.repos.d]# ls
  14. backup CentOS-Base.repo
  15. [root@localhost yum.repos.d]# yum clean all && yum makecache
  16. Loaded plugins: fastestmirror, langpacks
  17. Cleaning repos: base extras updates
  18. Cleaning up everything
  19. Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
  20. Cleaning up list of fastest mirrors
  21. Loaded plugins: fastestmirror, langpacks
  22. base | 3.6 kB 00:00:00
  23. extras | 2.9 kB 00:00:00
  24. updates | 2.9 kB 00:00:00
  25. base/7/x86_64/primary_db FAILED
  26. 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"
  27. Trying other mirror.
  28. (1/10): base/7/x86_64/group_gz | 153 kB 00:00:00
  29. (2/10): extras/7/x86_64/filelists_db | 276 kB 00:00:00
  30. (3/10): extras/7/x86_64/other_db | 149 kB 00:00:00
  31. (4/10): base/7/x86_64/other_db | 2.6 MB 00:00:04
  32. (5/10): updates/7/x86_64/filelists_db | 11 MB 00:00:15
  33. extras/7/x86_64/primary_db FAILED 0:38 ETA
  34. 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"
  35. Trying other mirror.
  36. base/7/x86_64/filelists_db FAILED
  37. 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"
  38. Trying other mirror.
  39. (6/10): extras/7/x86_64/primary_db | 249 kB 00:00:00
  40. updates/7/x86_64/primary_db FAILED
  41. 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"
  42. Trying other mirror.
  43. (7/10): base/7/x86_64/primary_db | 6.1 MB 00:00:07
  44. updates/7/x86_64/other_db FAILED 0:15 ETA
  45. 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"
  46. Trying other mirror.
  47. (8/10): updates/7/x86_64/other_db | 1.3 MB 00:00:01
  48. (9/10): base/7/x86_64/filelists_db | 7.2 MB 00:00:08
  49. (10/10): updates/7/x86_64/primary_db | 20 MB 00:00:24
  50. Determining fastest mirrors
  51. * base: mirrors.aliyun.com
  52. * extras: mirrors.aliyun.com
  53. * updates: mirrors.aliyun.com
  54. Metadata Cache Created
  55. [root@localhost yum.repos.d]# yum -y install httpd
  56. Loaded plugins: fastestmirror, langpacks
  57. Loading mirror speeds from cached hostfile
  58. * base: mirrors.aliyun.com
  59. * extras: mirrors.aliyun.com
  60. * updates: mirrors.aliyun.com
  61. Resolving Dependencies
  62. --> Running transaction check
  63. ---> Package httpd.x86_64 0:2.4.6-98.el7.centos.6 will be installed
  64. --> Processing Dependency: httpd-tools = 2.4.6-98.el7.centos.6 for package: httpd-2.4.6-98.el7.centos.6.x86_64
  65. --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-98.el7.centos.6.x86_64
  66. --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-98.el7.centos.6.x86_64
  67. --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-98.el7.centos.6.x86_64
  68. --> Running transaction check
  69. ---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
  70. ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
  71. ---> Package httpd-tools.x86_64 0:2.4.6-98.el7.centos.6 will be installed
  72. ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
  73. --> Finished Dependency Resolution
  74. Dependencies Resolved
  75. ========================================================================================
  76. Package Arch Version Repository Size
  77. ========================================================================================
  78. Installing:
  79. httpd x86_64 2.4.6-98.el7.centos.6 updates 2.7 M
  80. Installing for dependencies:
  81. apr x86_64 1.4.8-7.el7 base 104 k
  82. apr-util x86_64 1.5.2-6.el7 base 92 k
  83. httpd-tools x86_64 2.4.6-98.el7.centos.6 updates 94 k
  84. mailcap noarch 2.1.41-2.el7 base 31 k
  85. Transaction Summary
  86. ========================================================================================
  87. Install 1 Package (+4 Dependent packages)
  88. Total download size: 3.0 M
  89. Installed size: 10 M
  90. Downloading packages:
  91. 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
  92. Public key for apr-1.4.8-7.el7.x86_64.rpm is not installed
  93. (1/5): apr-1.4.8-7.el7.x86_64.rpm | 104 kB 00:00:00
  94. (2/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:00
  95. Public key for httpd-tools-2.4.6-98.el7.centos.6.x86_64.rpm is not installed
  96. (3/5): httpd-tools-2.4.6-98.el7.centos.6.x86_64.rpm | 94 kB 00:00:00
  97. (4/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00
  98. (5/5): httpd-2.4.6-98.el7.centos.6.x86_64.rpm | 2.7 MB 00:00:09
  99. ----------------------------------------------------------------------------------------
  100. Total 315 kB/s | 3.0 MB 00:09
  101. Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  102. Importing GPG key 0xF4A80EB5:
  103. Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
  104. Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
  105. From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  106. Running transaction check
  107. Running transaction test
  108. Transaction test succeeded
  109. Running transaction
  110. Installing : apr-1.4.8-7.el7.x86_64 1/5
  111. Installing : apr-util-1.5.2-6.el7.x86_64 2/5
  112. Installing : httpd-tools-2.4.6-98.el7.centos.6.x86_64 3/5
  113. Installing : mailcap-2.1.41-2.el7.noarch 4/5
  114. Installing : httpd-2.4.6-98.el7.centos.6.x86_64 5/5
  115. Verifying : httpd-tools-2.4.6-98.el7.centos.6.x86_64 1/5
  116. Verifying : mailcap-2.1.41-2.el7.noarch 2/5
  117. Verifying : apr-1.4.8-7.el7.x86_64 3/5
  118. Verifying : httpd-2.4.6-98.el7.centos.6.x86_64 4/5
  119. Verifying : apr-util-1.5.2-6.el7.x86_64 5/5
  120. Installed:
  121. httpd.x86_64 0:2.4.6-98.el7.centos.6
  122. Dependency Installed:
  123. apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.el7
  124. httpd-tools.x86_64 0:2.4.6-98.el7.centos.6 mailcap.noarch 0:2.1.41-2.el7
  125. Complete!
  126. [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 ./ #####自动生成依赖关系,这个在那个目录。

实验如下:

服务机:

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

客户机:

  1. [root@localhost yum.repos.d]# yum -y install httpd
  2. Loaded plugins: fastestmirror, langpacks
  3. Loading mirror speeds from cached hostfile
  4. Resolving Dependencies
  5. --> Running transaction check
  6. ---> Package httpd.x86_64 0:2.4.6-67.el7.centos will be installed
  7. --> Finished Dependency Resolution
  8. Dependencies Resolved
  9. ==============================================================================
  10. Package Arch Version Repository Size
  11. ==============================================================================
  12. Installing:
  13. httpd x86_64 2.4.6-67.el7.centos local 2.7 M
  14. Transaction Summary
  15. ==============================================================================
  16. Install 1 Package
  17. Total download size: 2.7 M
  18. Installed size: 9.4 M
  19. Downloading packages:
  20. httpd-2.4.6-67.el7.centos.x86_ FAILED
  21. 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
  22. Trying other mirror.
  23. Error downloading packages:
  24. 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))

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

环境准备、配置服务端

  1. [root@localhost ~]# yum -y install nfs-utils rpcbind
  2. Loaded plugins: fastestmirror, langpacks
  3. Existing lock /var/run/yum.pid: another copy is running as pid 12310.
  4. Another app is currently holding the yum lock; waiting for it to exit...
  5. The other application is: PackageKit
  6. Memory : 201 M RSS (1.5 GB VSZ)
  7. Started: Fri Mar 10 02:21:28 2023 - 03:38 ago
  8. State : Sleeping, pid: 12310
  9. Another app is currently holding the yum lock; waiting for it to exit...
  10. The other application is: PackageKit
  11. Memory : 201 M RSS (1.5 GB VSZ)
  12. Started: Fri Mar 10 02:21:28 2023 - 03:40 ago
  13. State : Sleeping, pid: 12310
  14. ^C
  15. Exiting on user cancel.
  16. [root@localhost ~]# rm -rf /var/run/yum.pid
  17. [root@localhost ~]# yum -y install nfs-utils rpcbind
  18. Loaded plugins: fastestmirror, langpacks
  19. base | 3.6 kB 00:00:00
  20. extras | 2.9 kB 00:00:00
  21. updates | 2.9 kB 00:00:00
  22. Loading mirror speeds from cached hostfile
  23. * base: mirrors.ustc.edu.cn
  24. * extras: mirrors.ustc.edu.cn
  25. * updates: mirrors.ustc.edu.cn
  26. Resolving Dependencies
  27. --> Running transaction check
  28. ---> Package nfs-utils.x86_64 1:1.3.0-0.48.el7 will be updated
  29. ---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be an update
  30. ---> Package rpcbind.x86_64 0:0.2.0-42.el7 will be updated
  31. ---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be an update
  32. --> Finished Dependency Resolution
  33. Dependencies Resolved
  34. ========================================================================================
  35. Package Arch Version Repository Size
  36. ========================================================================================
  37. Updating:
  38. nfs-utils x86_64 1:1.3.0-0.68.el7.2 updates 413 k
  39. rpcbind x86_64 0.2.0-49.el7 base 60 k
  40. Transaction Summary
  41. ========================================================================================
  42. Upgrade 2 Packages
  43. Total size: 473 k
  44. Total download size: 413 k
  45. Downloading packages:
  46. No Presto metadata available for updates
  47. 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
  48. Public key for nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm is not installed
  49. nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm | 413 kB 00:00:00
  50. Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  51. Importing GPG key 0xF4A80EB5:
  52. Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
  53. Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
  54. Package : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
  55. From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  56. Running transaction check
  57. Running transaction test
  58. Transaction test succeeded
  59. Running transaction
  60. Updating : rpcbind-0.2.0-49.el7.x86_64 1/4
  61. Updating : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 2/4
  62. Cleanup : 1:nfs-utils-1.3.0-0.48.el7.x86_64 3/4
  63. Cleanup : rpcbind-0.2.0-42.el7.x86_64 4/4
  64. Verifying : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 1/4
  65. Verifying : rpcbind-0.2.0-49.el7.x86_64 2/4
  66. Verifying : rpcbind-0.2.0-42.el7.x86_64 3/4
  67. Verifying : 1:nfs-utils-1.3.0-0.48.el7.x86_64 4/4
  68. Updated:
  69. nfs-utils.x86_64 1:1.3.0-0.68.el7.2 rpcbind.x86_64 0:0.2.0-49.el7
  70. Complete!
  71. [root@localhost ~]# vim /etc/exports
  72. [root@localhost ~]# netstat -anpu | grep rpcbind
  73. [root@localhost ~]# systemctl start rpcbind
  74. [root@localhost ~]# systemctl start nfs
  75. [root@localhost ~]# netstat -anpu | grep rpcbind
  76. udp 0 0 0.0.0.0:880 0.0.0.0:* 14698/rpcbind
  77. udp 0 0 0.0.0.0:111 0.0.0.0:* 14698/rpcbind
  78. udp6 0 0 :::880 :::* 14698/rpcbind
  79. udp6 0 0 :::111 :::* 14698/rpcbind
  80. [root@localhost ~]# mkdir /opt/pub
  81. [root@localhost ~]# chown nfsnobody /opt/pub/

配置客户端:

  1. [root@localhost ~]# yum -y install nfs-utils rpcbind
  2. Loaded plugins: fastestmirror, langpacks
  3. base | 3.6 kB 00:00:00
  4. extras | 2.9 kB 00:00:00
  5. updates | 2.9 kB 00:00:00
  6. Loading mirror speeds from cached hostfile
  7. * base: mirrors.ustc.edu.cn
  8. * extras: mirrors.ustc.edu.cn
  9. * updates: mirrors.ustc.edu.cn
  10. Resolving Dependencies
  11. --> Running transaction check
  12. ---> Package nfs-utils.x86_64 1:1.3.0-0.48.el7 will be updated
  13. ---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be an update
  14. ---> Package rpcbind.x86_64 0:0.2.0-42.el7 will be updated
  15. ---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be an update
  16. --> Finished Dependency Resolution
  17. Dependencies Resolved
  18. ========================================================================================
  19. Package Arch Version Repository Size
  20. ========================================================================================
  21. Updating:
  22. nfs-utils x86_64 1:1.3.0-0.68.el7.2 updates 413 k
  23. rpcbind x86_64 0.2.0-49.el7 base 60 k
  24. Transaction Summary
  25. ========================================================================================
  26. Upgrade 2 Packages
  27. Total size: 473 k
  28. Total download size: 413 k
  29. Downloading packages:
  30. No Presto metadata available for updates
  31. 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
  32. Public key for nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm is not installed
  33. nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm | 413 kB 00:00:00
  34. Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  35. Importing GPG key 0xF4A80EB5:
  36. Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
  37. Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
  38. Package : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
  39. From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  40. Running transaction check
  41. Running transaction test
  42. Transaction test succeeded
  43. Running transaction
  44. Updating : rpcbind-0.2.0-49.el7.x86_64 1/4
  45. Updating : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 2/4
  46. Cleanup : 1:nfs-utils-1.3.0-0.48.el7.x86_64 3/4
  47. Cleanup : rpcbind-0.2.0-42.el7.x86_64 4/4
  48. Verifying : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 1/4
  49. Verifying : rpcbind-0.2.0-49.el7.x86_64 2/4
  50. Verifying : rpcbind-0.2.0-42.el7.x86_64 3/4
  51. Verifying : 1:nfs-utils-1.3.0-0.48.el7.x86_64 4/4
  52. Updated:
  53. nfs-utils.x86_64 1:1.3.0-0.68.el7.2 rpcbind.x86_64 0:0.2.0-49.el7
  54. Complete!
  55. [root@localhost ~]# systemctl stop firewalld.service
  56. [root@localhost ~]# setenforce 0
  57. [root@localhost ~]# vim /etc/sysconfig/selinux
  58. [root@localhost ~]# cd /etc/yum.repos.d/
  59. [root@localhost yum.repos.d]# ll
  60. total 28
  61. -rw-r--r--. 1 root root 1664 Aug 30 2017 CentOS-Base.repo
  62. -rw-r--r--. 1 root root 1309 Aug 30 2017 CentOS-CR.repo
  63. -rw-r--r--. 1 root root 649 Aug 30 2017 CentOS-Debuginfo.repo
  64. -rw-r--r--. 1 root root 314 Aug 30 2017 CentOS-fasttrack.repo
  65. -rw-r--r--. 1 root root 630 Aug 30 2017 CentOS-Media.repo
  66. -rw-r--r--. 1 root root 1331 Aug 30 2017 CentOS-Sources.repo
  67. -rw-r--r--. 1 root root 3830 Aug 30 2017 CentOS-Vault.repo
  68. [root@localhost yum.repos.d]# mkdir backup
  69. [root@localhost yum.repos.d]# mv C* backup
  70. [root@localhost yum.repos.d]# vim local.repo
  71. [root@localhost yum.repos.d]# yum -y install dhcp
  72. Loaded plugins: fastestmirror, langpacks
  73. local | 3.6 kB 00:00:00
  74. (1/2): local/group_gz | 156 kB 00:00:00
  75. (2/2): local/primary_db | 3.1 MB 00:00:00
  76. Loading mirror speeds from cached hostfile
  77. Resolving Dependencies
  78. --> Running transaction check
  79. ---> Package dhcp.x86_64 12:4.2.5-58.el7.centos will be installed
  80. --> Finished Dependency Resolution
  81. Dependencies Resolved
  82. ========================================================================================
  83. Package Arch Version Repository Size
  84. ========================================================================================
  85. Installing:
  86. dhcp x86_64 12:4.2.5-58.el7.centos local 513 k
  87. Transaction Summary
  88. ========================================================================================
  89. Install 1 Package
  90. Total download size: 513 k
  91. Installed size: 1.4 M
  92. Downloading packages:
  93. dhcp-4.2.5-58.el7.centos.x86_64.rpm | 513 kB 00:00:00
  94. Running transaction check
  95. Running transaction test
  96. Transaction test succeeded
  97. Running transaction
  98. Installing : 12:dhcp-4.2.5-58.el7.centos.x86_64 1/1
  99. Verifying : 12:dhcp-4.2.5-58.el7.centos.x86_64 1/1
  100. Installed:
  101. dhcp.x86_64 12:4.2.5-58.el7.centos
  102. Complete!
  103. [root@localhost yum.repos.d]# vim local.repo
  104. [root@localhost yum.repos.d]#
  105. Socket error Event: 32 Error: 10053.
  106. Connection closing...Socket close.
  107. Connection closed by foreign host.
  108. Disconnected from remote host(备用1) at 18:11:22.
  109. Type `help' to learn how to use Xshell prompt.
  110. [C:\~]$
  111. Connecting to 192.168.179.21:22...
  112. Connection established.
  113. To escape to local shell, press 'Ctrl+Alt+]'.
  114. Last login: Thu Mar 9 18:19:08 2023
  115. [root@localhost ~]# yum -y install nfs-utils.x86_64 rpcbind.x86_64
  116. Loaded plugins: fastestmirror, langpacks
  117. base | 3.6 kB 00:00:00
  118. extras | 2.9 kB 00:00:00
  119. updates | 2.9 kB 00:00:00
  120. Loading mirror speeds from cached hostfile
  121. * base: mirrors.bfsu.edu.cn
  122. * extras: mirrors.ustc.edu.cn
  123. * updates: mirrors.ustc.edu.cn
  124. Resolving Dependencies
  125. --> Running transaction check
  126. ---> Package nfs-utils.x86_64 1:1.3.0-0.48.el7 will be updated
  127. ---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be an update
  128. ---> Package rpcbind.x86_64 0:0.2.0-42.el7 will be updated
  129. ---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be an update
  130. --> Finished Dependency Resolution
  131. Dependencies Resolved
  132. ========================================================================================
  133. Package Arch Version Repository Size
  134. ========================================================================================
  135. Updating:
  136. nfs-utils x86_64 1:1.3.0-0.68.el7.2 updates 413 k
  137. rpcbind x86_64 0.2.0-49.el7 base 60 k
  138. Transaction Summary
  139. ========================================================================================
  140. Upgrade 2 Packages
  141. Total size: 473 k
  142. Downloading packages:
  143. 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
  144. Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  145. Importing GPG key 0xF4A80EB5:
  146. Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
  147. Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
  148. Package : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
  149. From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  150. Running transaction check
  151. Running transaction test
  152. Transaction test succeeded
  153. Running transaction
  154. Updating : rpcbind-0.2.0-49.el7.x86_64 1/4
  155. Updating : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 2/4
  156. Cleanup : 1:nfs-utils-1.3.0-0.48.el7.x86_64 3/4
  157. Cleanup : rpcbind-0.2.0-42.el7.x86_64 4/4
  158. Verifying : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 1/4
  159. Verifying : rpcbind-0.2.0-49.el7.x86_64 2/4
  160. Verifying : rpcbind-0.2.0-42.el7.x86_64 3/4
  161. Verifying : 1:nfs-utils-1.3.0-0.48.el7.x86_64 4/4
  162. Updated:
  163. nfs-utils.x86_64 1:1.3.0-0.68.el7.2 rpcbind.x86_64 0:0.2.0-49.el7
  164. Complete!
  165. [root@localhost ~]#
  166. [root@localhost ~]# systemctl start rpcbind.service
  167. [root@localhost ~]# systemctl start nfs
  168. [root@localhost ~]# showmount -e 192.168.179.20
  169. Export list for 192.168.179.20:
  170. /usr/share 192.168.179.0/24
  171. /opt/pub 192.168.179.21
  172. [root@localhost ~]# mount 192.168.179.20:/usr/share /media
  173. [root@localhost ~]# ls /usr
  174. bin etc games include lib lib64 libexec local sbin share src tmp
  175. [root@localhost ~]# df -hT
  176. Filesystem Type Size Used Avail Use% Mounted on
  177. /dev/sda3 xfs 38G 4.7G 34G 13% /
  178. devtmpfs devtmpfs 898M 0 898M 0% /dev
  179. tmpfs tmpfs 912M 0 912M 0% /dev/shm
  180. tmpfs tmpfs 912M 9.1M 903M 1% /run
  181. tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
  182. /dev/sda1 xfs 297M 157M 141M 53% /boot
  183. tmpfs tmpfs 183M 8.0K 183M 1% /run/user/42
  184. tmpfs tmpfs 183M 0 183M 0% /run/user/0
  185. tmpfs tmpfs 183M 32K 183M 1% /run/user/1000
  186. 192.168.179.20:/usr/share nfs4 36G 4.7G 32G 13% /media
  187. [root@localhost ~]# cd /srv
  188. [root@localhost srv]# ll
  189. total 0
  190. [root@localhost srv]# touch 1.txt
  191. [root@localhost srv]# ls
  192. 1.txt
  193. [root@localhost srv]#
  194. Socket error Event: 32 Error: 10053.
  195. Connection closing...Socket close.
  196. Connection closed by foreign host.
  197. Disconnected from remote host(备用1) at 18:24:23.
  198. Type `help' to learn how to use Xshell prompt.
  199. [C:\~]$
  200. Connecting to 192.168.179.21:22...
  201. Connection established.
  202. To escape to local shell, press 'Ctrl+Alt+]'.
  203. Last login: Thu Mar 9 18:19:08 2023
  204. [root@localhost ~]# yum -y install nfs-utils rpcbind
  205. Loaded plugins: fastestmirror, langpacks
  206. base | 3.6 kB 00:00:00
  207. extras | 2.9 kB 00:00:00
  208. updates | 2.9 kB 00:00:00
  209. Loading mirror speeds from cached hostfile
  210. * base: mirrors.bfsu.edu.cn
  211. * extras: mirrors.ustc.edu.cn
  212. * updates: mirrors.ustc.edu.cn
  213. Resolving Dependencies
  214. --> Running transaction check
  215. ---> Package nfs-utils.x86_64 1:1.3.0-0.48.el7 will be updated
  216. ---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be an update
  217. ---> Package rpcbind.x86_64 0:0.2.0-42.el7 will be updated
  218. ---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be an update
  219. --> Finished Dependency Resolution
  220. Dependencies Resolved
  221. ========================================================================================
  222. Package Arch Version Repository Size
  223. ========================================================================================
  224. Updating:
  225. nfs-utils x86_64 1:1.3.0-0.68.el7.2 updates 413 k
  226. rpcbind x86_64 0.2.0-49.el7 base 60 k
  227. Transaction Summary
  228. ========================================================================================
  229. Upgrade 2 Packages
  230. Total size: 473 k
  231. Downloading packages:
  232. 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
  233. Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  234. Importing GPG key 0xF4A80EB5:
  235. Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
  236. Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
  237. Package : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
  238. From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  239. Running transaction check
  240. Running transaction test
  241. Transaction test succeeded
  242. Running transaction
  243. Updating : rpcbind-0.2.0-49.el7.x86_64 1/4
  244. Updating : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 2/4
  245. Cleanup : 1:nfs-utils-1.3.0-0.48.el7.x86_64 3/4
  246. Cleanup : rpcbind-0.2.0-42.el7.x86_64 4/4
  247. Verifying : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 1/4
  248. Verifying : rpcbind-0.2.0-49.el7.x86_64 2/4
  249. Verifying : rpcbind-0.2.0-42.el7.x86_64 3/4
  250. Verifying : 1:nfs-utils-1.3.0-0.48.el7.x86_64 4/4
  251. Updated:
  252. nfs-utils.x86_64 1:1.3.0-0.68.el7.2 rpcbind.x86_64 0:0.2.0-49.el7
  253. Complete!
  254. [root@localhost ~]# systemctl s
  255. set-default show start suspend
  256. set-environment show-environment status switch-root
  257. set-property snapshot stop
  258. [root@localhost ~]# systemctl start rpcbind
  259. [root@localhost ~]# systemctl start nfs
  260. [root@localhost ~]# showmount -e 192.168.179.20
  261. Export list for 192.168.179.20:
  262. /usr/share 192.168.179.0/24
  263. /opt/pub 192.168.179.21
  264. [root@localhost ~]# mount 192.168.179.20:/usr/share /media/
  265. [root@localhost ~]# df -Th
  266. Filesystem Type Size Used Avail Use% Mounted on
  267. /dev/sda3 xfs 38G 4.7G 34G 13% /
  268. devtmpfs devtmpfs 898M 0 898M 0% /dev
  269. tmpfs tmpfs 912M 0 912M 0% /dev/shm
  270. tmpfs tmpfs 912M 9.1M 903M 1% /run
  271. tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
  272. /dev/sda1 xfs 297M 157M 141M 53% /boot
  273. tmpfs tmpfs 183M 8.0K 183M 1% /run/user/42
  274. tmpfs tmpfs 183M 0 183M 0% /run/user/0
  275. tmpfs tmpfs 183M 28K 183M 1% /run/user/1000
  276. 192.168.179.20:/usr/share nfs4 36G 4.4G 32G 13% /media
  277. [root@localhost ~]# vim /etc/fstab
  278. [root@localhost ~]# init 6 #重启
  279. Connection closing...Socket close.
  280. Connection closed by foreign host.
  281. Disconnected from remote host(备用1) at 18:29:49.

在客户端写入:

  1. Type `help' to learn how to use Xshell prompt.
  2. [C:\~]$
  3. Connecting to 192.168.179.21:22...
  4. Connection established.
  5. To escape to local shell, press 'Ctrl+Alt+]'.
  6. Last login: Fri Mar 10 02:24:53 2023 from 192.168.179.1
  7. [root@localhost ~]# cd /srv
  8. [root@localhost srv]# ll
  9. total 0
  10. [root@localhost srv]# touch 1.txt
  11. [root@localhost srv]# ls
  12. 1.txt
  13. [root@localhost srv]#

服务端查看:

  1. [root@localhost ~]# cd /opt/pub/
  2. [root@localhost pub]# ls
  3. 1.txt
  4. [root@localhost pub]# ll
  5. total 0
  6. -rw-r--r--. 1 nfsnobody nfsnobody 0 Mar 10 02:30 1.txt
  7. [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) 生效##

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/536990
推荐阅读
相关标签
  

闽ICP备14008679号