2018-05-09 Linux Learning

Source: Internet
Author: User
Tags chmod

14.1 NFS Introduction

NFS是Network File System的缩写NFS最早由Sun公司开发,分2,3,4三个版本,2和3由Sun起草开发,4.0开始Netapp公司参与并主导开发,最新为4.1版本NFS数据传输基于RPC协议,RPC为Remote Procedure Call的简写。NFS应用场景是:A,B,C三台机器上需要保证被访问到的文件是一样的,A共享数据出来,B和C分别去挂载A共享的数据目录,从而B和C访问到的数据和A上的一致

14.2 NFS server-side installation configuration

Yum install-y nfs-utils Rpcbind
Vim/etc/exports//Add the following:
/home/nfstestdir 192.168.133.0/24 (rw,sync,all_squash,anonuid=1000,anongid=1000)
After you save the configuration file, perform the following preparation actions
Mkdir/home/nfstestdir
chmod 777/home/nfstestdir
Systemctl Start Rpcbind
Systemctl Start NFS
Systemctl Enable Rpcbind
Systemctl Enable NFS

Operation Process

[[email protected] ~]# yum install -y nfs-utils[[email protected] ~]# vim /etc/exports/home/nfstestdir 192.168.106.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)[[email protected] ~]# mkdir /home/nfstestdir[[email protected] ~]# chmod 777 /home/nfstestdir[[email protected] ~]# systemctl start rpcbind[[email protected] ~]# systemctl start nfs[[email protected] ~]# systemctl enable rpcbind[[email protected] ~]# systemctl enable nfsCreated symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.

14.3 NFS Configuration options

NFS configuration options

rw 读写ro 只读sync 同步模式,内存数据实时写入磁盘async 非同步模式no_root_squash 客户端挂载NFS共享目录后,root用户不受约束,权限很大root_squash 与上面选项相对,客户端上的root用户收到约束,被限定成某个普通用户all_squash 客户端上所有用户在使用NFS共享目录时都被限定为一个普通用户anonuid/anongid 和上面几个选项搭配使用,定义被限定用户的uid和gid

Client Mount

yum install -y nfs-utilsshowmount -e 192.168.133.130     //该ip为NFS服务端ipmount -t nfs 192.168.133.130:/home/nfstestdir /mntdf -htouch /mnt/aminglinux.txtls -l /mnt/aminglinux.txt   //可以看到文件的属主和属组都为1000

Operation Process

Client

[[email protected] ~]# showmount -e 192.168.106.160clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)

Shutting down the server firewall

[[email protected] ~]# systemctl stop firewalld.service

Client
[Email protected] ~]# showmount-e 192.168.106.160
Export list for 192.168.106.160:
/home/nfstestdir 192.168.106.0/24

[[email protected] ~]# mount -t nfs 192.168.106.160:/home/nfstestdir /mnt[[email protected]-02 ~]# df -h文件系统                          容量  已用  可用 已用% 挂载点/dev/sda3                          26G  4.7G   22G   18% /devtmpfs                          902M     0  902M    0% /devtmpfs                             912M     0  912M    0% /dev/shmtmpfs                             912M  8.7M  903M    1% /runtmpfs                             912M     0  912M    0% /sys/fs/cgroup/dev/sda1                         197M  156M   42M   79% /boottmpfs                             183M     0  183M    0% /run/user/0192.168.106.160:/home/nfstestdir   26G  9.8G   17G   38% /mnt[[email protected] ~]# touch /mnt/aminglinux.txt[[email protected] ~]# ls -l /mnt/aminglinux.txt -rw-r--r--. 1 1000 1000 0 4月  10 01:28 /mnt/aminglinux.txt

2018-05-09 Linux Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.