Linux-nfs File System

Source: Internet
Author: User


NFS, Network File system. A System shares directories and files with others on the network. By using NFS, users and programs can access local

Files on the system.
use: Share Files
Advantages: Save disk space
Composition: one server and one or more client computers



(Service side)

[[email protected] ~]# yum install nfs-untils-y installation Service
[[email protected] ~]# Systemctl start NFS(shared) (Do not restart the service, otherwise the client will be stuck)

#注: Port 111?
Ss-antlupe | grep 111 to see if the 111 Port is open



Join the following three services

[[email protected] ~]# firewall-cmd--permanent--add-service=NFS

[Email protected] ~]# firewall-cmd--permanent--add-service=rpc-bind

[Email protected] ~]# firewall-cmd--permanent--add-service=mountd

Remember: After operation, Reload

[Email protected] ~]# Firewall-cmd--reload
Success



When the above is ready, create a shared directory on the server

[Email protected] ~]# mkdir/westos/nfs-p? Create (Share) directory
[Email protected] ~]# vim/etc/exports? Edit File
[Email protected] ~]# Cat/etc/exports
/westos/nfs? * (sync)? <----sync to client
[Email protected] ~]#
[[email protected] ~]# exportfs-rv Refresh
Exporting *:/westos/nfs




Client

Find the device on the server and mount it as follows:

[[email protected] ~]# showmount-e 172.25.12.10 Discovery (server side) device

Export list for 172.25.12.10:?? See the 10 host device
/WESTOS/NFS *



*) Auto mount, uninstall on client as follows

[[email protected] ~]# yum install autofs.x86_64-y installation Service (automatically hang up, uninstall)

[[email protected] ~]# systemctl start autofs start service ( /net directory will be generated automatically)

[Email protected] ~]# ls-ld/net? View Permissions
Drwxr-xr-x 2 root root 0 Dec? 9 20:01/net


[[email protected] ~]# rpm-qc autofs This command to view the configuration file


[Email protected] nfs]# vim/etc/sysconfig/autofs? Editing a configuration file (7.0)

Note:vim/etc/autofs.conf?? Version 7.2

You can change the mount time as above

[Email protected] nfs]# systemctl restart Autofs.service? Restart Service

For example, if you want to change the position of the mount point, you can do the following.


*) cd/westos/(Linux)/NFS implementation mount in this directory


(Service side)

[Email protected] ~]# vim/etc/exports? Edit this file
[Email protected] ~]# EXPORTFS-RV
Exporting *:/westos/linux/nfs
Exportfs:failed to stat/westos/linux/nfs:no such file or directory
[[email protected] ~]# mkdir-p/westos/linux/nfs Create a directory that you now need to mount
[[email protected] ~]# EXPORTFS-RV Refresh
Exporting *:/westos/linux/nfs
[[Email protected]sktop ~]# Rm-fr/westos/nfs before deleting the


Client

[Email protected] nfs]# vim/etc/auto.master? Edit the configuration file ( eventually hanging in the top-level directory of the point )



[[email protected] nfs]# vim/etc/auto.nfs write mount information in the specified file



[[email protected] nfs]# systemctl restart Autofs.service Restart Service


Test:

[Email protected] nfs]# mount? Viewing mount information



*) enable client host to write


(Service side)

[Email protected] ~]# vim/etc/exports? Edit File
[Email protected] ~]# cat/etc/exports (2 ')
/westos/nfs? * (SYNC,RW)? Join Permissions RW
[Email protected] ~]# EXPORTFS-RV? Refresh
Exporting *:/westos/nfs

[[email protected] ~]# cd/westos/nfs/cut to this directory
[Email protected] nfs]# ls-ld/westos/nfs/
Drwxr-xr-x 2 root root 6 Dec? 9 07:45/westos/nfs/Other people do not have permission to write
[[email protected] nfs]# chmod 777/westos/nfs/? give permission
[Email protected] nfs]# ls-ld/westos/nfs/
DRWXRWXRWX 2 root root 6 Dec? 9 07:45/westos/nfs/Other people have permission to write




*) Specify identity creation file

[Email protected] nfs]# Vim/etc/exports

[Email protected] nfs]# EXPORTFS-RV
Exporting *:/westos/nfs
[Email protected] nfs]# Cat/etc/exports
/westos/nfs? * (sync,rw,anonuid=1001,anongid=1001) specify identity creation file
Indicates that the client new file belongs to the specified group and user


If the ID specified above is the same as the user, the created file belongs to that user.

*) Hyper-family identity write

[Email protected] nfs]# Vim/etc/exports


[Email protected] nfs]# EXPORTFS-RV
Exporting *:/westos/nfs
[Email protected] nfs]# Cat/etc/exports
/westos/nfs? * (Sync,rw,anonuid=1001,anongid=1001,no_root_squash)? A hyper-user identity (no conversion) indicates that the client is using the device to create a new file as root and the file is root



Linux-nfs File System

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.