首页 > 其他分享 >架设一台NFS服务器,并按以下要求配置

架设一台NFS服务器,并按以下要求配置

时间:2023-03-07 22:55:42浏览次数:30  
标签:node01 NFS upload nfs node1 服务器 kube root 架设

1、开放/nfs/shared目录,供所有用户查询资料;
2、开放/nfs/upload目录,该目录为192.168.11.0/24网段的主机的数据上传目录,并将所有该网段主机上传文件的所属者和所属组映射为nfs-upload,其UID和GID为2001;
3、将/home/tom(该目录为uid=1111,gid=1111的tom用户的家目录)目录仅共享给192.168.11.104这台主机上的jerry用户,jerry对该目录具有访问、新建和删除文件的权限。

服务端:
1、安装软件包
[root@kube-node1 ~]# yum install nfs-utils.x86_64  rpcbind.x86_64 -y

2、关闭防火墙,selinux
[root@kube-node1 ~]# systemctl stop firewalld.service
[root@kube-node1 ~]# systemctl is-active firewalld.service
inactive
[root@kube-node1 ~]# setenforce 0

3、修改exports文件
# 注意空格
[root@kube-node1 ~]# cat /etc/exports
/nfs/shared *(ro)
/nfs/upload 192.168.11.0/24(rw,all_squash,anonuid=2001,anongid=2001)
/home/tom 192.168.11.104(rw)

4、创建目录
[root@kube-node1 ~]# mkdir -p /nfs/{shared,upload}

5、创建用户和用户组
[root@kube-node1 ~]# groupadd tom -g 1111

[root@kube-node1 ~]# useradd tom -u 1111 -g 1111

[root@kube-node1 ~]# id tom
uid=1111(tom) gid=1111(tom) groups=1111(tom)

6、重启服务
[root@kube-node1 ~]# systemctl start rpcbind.service  nfs-server.service

7、查看清单
[root@kube-node1 nfs]# showmount -e 192.168.11.115
Export list for 192.168.11.115:
/nfs/shared *
/nfs/upload 192.168.11.0/24
/home/tom   192.168.11.104


8、去每个目录下创建一个文件
[root@kube-node1 ~]# cd /nfs/shared/
[root@kube-node1 shared]# echo this is file1 > file1
[root@kube-node1 shared]# ll
total 4
-rw-r--r--. 1 root root 14 Mar  7 22:01 file1


[root@kube-node1 shared]# cd /nfs/upload
upload/    uploadmul/
[root@kube-node1 shared]# cd /nfs/upload
[root@kube-node1 upload]# echo this is file2 > file2
[root@kube-node1 upload]# ll
total 4
-rw-r--r--. 1 root root 14 Mar  7 22:01 file2

[root@kube-node1 upload]# cd /home/tom/
[root@kube-node1 tom]# echo this is file3 > file3
[root@kube-node1 tom]# ll
total 4
-rw-r--r--. 1 root root 14 Mar  7 22:01 file3

9、修改权限
[root@kube-node1 tom]# cd /nfs/upload
[root@kube-node1 upload]# chmod o+w .
[root@kube-node1 upload]# cd /nfs/
[root@kube-node1 nfs]# ll
total 0
drwxr-xr-x. 2 root root 19 Mar  7 22:01 shared
drwxr-xrwx. 2 root root 19 Mar  7 22:01 upload

客户端:
1、安装软件
[root@node01 ~]# yum install nfs-utils.x86_64 rpcbind.x86_64 -y

2、创建目录文件
[root@node01 ~]# mkdir -p /client/{1,2,3}
[root@node01 ~]# cd /client/
[root@node01 client]# ll
total 0
drwxr-xr-x. 2 root root 6 Mar  8 22:04 1
drwxr-xr-x. 2 root root 6 Mar  8 22:04 2
drwxr-xr-x. 2 root root 6 Mar  8 22:04 3

3、挂载目录
[root@node01 client]# mount -t nfs 192.168.11.115:/nfs/shared  /client/1
[root@node01 client]# mount -t nfs 192.168.11.115:/nfs/upload  /client/2
[root@node01 client]# mount -t nfs 192.168.11.115:/home/tom  /client/3

4、查询nfs服务的输出清单
[root@node01 client]# showmount -e 192.168.11.115
Export list for 192.168.11.115:
/nfs/shared *
/nfs/upload 192.168.11.0/24
/home/tom   192.168.11.104

5、创建用户和用户组
[root@node01 client]# groupadd nfs-upload -g 2001
[root@node01 client]# useradd nfs-upload -u 2001 -g 2001
[root@node01 client]# useradd jerry -u 1111
[root@node01 client]# id nfs-upload
uid=2001(nfs-upload) gid=2001(nfs-upload) groups=2001(nfs-upload)
[root@node01 client]# id jerry
uid=1111(jerry) gid=1111(jerry) groups=1111(jerry)

测试:
目录1:
[root@node01 client]# cd 1
[root@node01 1]#
[root@node01 1]# ll
total 4
-rw-r--r--. 1 root root 14 Mar  7 22:01 file1
[root@node01 1]# cat file1
this is file1

目录2:
客户端:
[root@node01 1]# cd  /client/2/
# 里面原来一个文件
[root@node01 2]# ll
total 4
-rw-r--r--. 1 root root 14 Mar  7 22:01 file2

#创建一个文件
[root@node01 2]# touch file-nfs
[root@node01 2]# ll
total 4
-rw-r--r--. 1 root       root       14 Mar  7 22:01 file2
-rw-r--r--. 1 nfs-upload nfs-upload  0 Mar  7 22:16 file-nfs

#删除原来的file2文件,在服务端看效果
[root@node01 2]# rm -rf file2
[root@node01 2]# ll
total 0
-rw-r--r--. 1 nfs-upload nfs-upload 0 Mar  7 22:16 file-nfs

服务端:
[root@kube-node1 nfs]# cd /nfs/upload/
[root@kube-node1 upload]# ll
total 0
-rw-r--r--. 1 2001 2001 0 Mar  7 22:16 file-nfs

目录3:
客户端:
#切换到jerry
[root@node01 ~]# su - jerry
[jerry@node01 ~]$
[jerry@node01 ~]$ cd /client/3/

#原来只有一个文件
[jerry@node01 3]$ ll
total 4
-rw-r--r--. 1 root root 14 Mar  7 22:01 file3
[jerry@node01 3]$ cat file3
this is file3

#创建一个文件
[jerry@node01 3]$ touch file3-jerry
[jerry@node01 3]$ ll
total 4
-rw-r--r--. 1 root  root  14 Mar  7 22:01 file3
-rw-rw-r--. 1 jerry jerry  0 Mar  7 22:20 file3-jerry
#删除一个文件,服务端看效果
[jerry@node01 3]$ rm -rf file3
[jerry@node01 3]$ ll
total 0
-rw-rw-r--. 1 jerry jerry 0 Mar  7 22:20 file3-jerry

服务端:
[root@kube-node1 upload]# cd /home/tom/
[root@kube-node1 tom]# ll
total 0
-rw-rw-r--. 1 tom tom 0 Mar  7 22:20 file3-jerry

标签:node01,NFS,upload,nfs,node1,服务器,kube,root,架设
From: https://www.cnblogs.com/sre-chan/p/17190061.html

相关文章

  • 35 openEuler搭建repo(yum)服务器-创建、更新本地repo源
    35openEuler搭建repo(yum)服务器-创建、更新本地repo源使用mount挂载,将openEuler的ISO发布包openEuler-22.03-LTS-everything-x86_64-dvd.iso创建为本地repo源,并能够对repo......
  • Ubuntu服务器ssh缓慢问题解决
    Ubuntu服务器ssh缓慢问题解决现象:ssh登陆或su-账号时间较长 排查:1、查看了/var/log/syslog未发现明显报错2、查看/var/log/auth.log发现有pam_systemd:Failedtocreate......
  • NFS共享
    NFS是NetworkFileSystem的简称,它可以让客户端直接挂载使用1.安装nfs-utils包[root@server~]#yuminstall-ynfs-utils2.创建共享目录[root@server~]#mkdir/bee3.写......
  • 服务器软硬磁盘阵列
    概述: RAID(RedundantArrayofInexpensiveDisks)称为廉价磁盘冗余阵列。RAID的基本思想是把多个便宜的小磁盘组合到一起,组合为一个大磁盘组,使性能达到或超过一个容量巨......
  • 周期/定时运行+进程守护工具,服务器维护利器
    周期/定时运行+进程守护工具,服务器维护利器 大家好,很久没写博客了,最近在部署网站的时候,需要将写成console运算模块一并部署到服务器上。然而Windows自带的任务计划程......
  • Linux - 本机与服务器文件互传(rz&sz)
    软件版本:secureCRTVersion8.7.3(build2279)rz和sz都是使用Zmodem文件传输协议。rz:ReceiveZmodemsz:SendZmodem#centOS安装命令$yum-yinstal......
  • 用MiniPC搭建个人服务器
    用MiniPC搭建个人服务器 最近突然对小型电子产品产生的兴趣,经过一段时间调查,最终选择从迷你PC下手。因为类似树莓派的产品,还是有一定的上手门槛的。开发板类的产品也......
  • 部署服务器
    date:2023-02-21category:-部署tag:-服务器部署-finalShell项目部署到服务器下载finalShell项目bulid打包压缩dist文件夹为zip格式配置如下,密码是......
  • linux服务器qps查询,查看当前linux服务器的QPS
    https://blog.csdn.net/weixin_42119281/article/details/116595205 QPS:每秒查询率(QPS,Queries-per-second)是对一个特定的查询服务器在规定时间内所处理流量多少的......
  • 服务器和电脑主机的区别?
    服务器主要应用于企业和个人的工作中,和家用的主机不同,服务器的任务是保证任何时候用户都能够通过终端顺利访问服务器,并传输和共享服务器中的数据。 1.服务器最重要的并......