Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

File sharing: NFS

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

NFS: network File system (netwok file system)

To provide a network file system platform, it is necessary to send control instructions for file transfer with the help of RPC (remote procedure call) protocol.

Release time: 1984

Company: SUN Company. A typical product is JAVA. SUN is acquired by Oracle

NFS software:

Nfs-utils 、 rpcbind

Note: if you have installed the centos desktop environment, both packages are already installed.

If you have installed the centos minimum environment, you need to install these two packages manually.

NSF deployment: (generic deployment of network deployment)

0. Turn off the security feature and check the status:

1. Check to see if the software is installed, and if not, install the software.

two。 Start the service and allow boot to start automatically

3. Set up the shared directory and reload the settings.

4. Do local (internal test) access test, do remote (public test) access test.

Turn off network security

Systemctl stop firewalld; setenforce 0

Systemctl status firewalld; getenforce

NFS installation

Check to see if rpm-Q nfs-utils rpcbind is installed

Installation: yum install-y nfs-utils rpcbind

View the file list of the software: rpm-qll nfs-utils

Check the list of configuration files: rpm-qc nfs-utils

NFS service management

Restart the service: systemctl restart nfs rpcbind

Allow start-up auto-start: systemctl enable nfs rpcbind

View service status: systemctl status nfs rpcbind

Share the required files (by modifying the / etc/exports shared configuration file. )

The syntax of the exports configuration file is as follows: man exports looks up the EXAMPLE example in help.

Vim / etc/exports

Absolute path to the shared directory 1 customer hostname or IP (sharing option) n customer hostname or IP (sharing option)

/ usr* (ro) 192.168.11.13 (rw)... (* represents any ip) opt* (rw,no_root_squash) 192.168.11.0 Compact 24 (rw)... (192.168.11.0 Universe 24 represents a network segment)

Sharing options:

Ro (common option) readable ReadOnly

Rw (common option) readable and writable read + write

Sync (common option) synchronous transfer

Async (common option) asynchronous transfer

No_root_squash (commonly used option) does not map root to nfsnobody anonymous users, that is, let root access the share with its own identity and permissions

No_all_squash (enabled by default) does not map all users to nfsnobody anonymous users, that is, let all users access the share with their own identities and permissions

Root_squash maps root to nfsnobody anonymous users (enabled by default)

All_squash maps all users to nfsnobody anonymous users

Anonuid anonymous user's uid number

Anongid anonymous user's gid number

Other configuration files for nfs: (for knowledge only, no need to modify)

Cat / var/lib/nfs/etab records the complete settings selection for the nfs share, which is derived from the / etc/exports file. When the nfs service is restarted, the contents of the etab file are automatically updated.

Smoothly restart the nfs service: exportfs-rav or systemctl reload nfs (reload without affecting other users)

Exportfs command option: man exportfs

-r re-share all directories

-a turn on or cancel all directory shares.

-v outputs details. Show what you are doing when sharing or unsharing.

-f in "new" mode, refresh anything other than the kernel shared table.

Local (internal test) query shared resource list: showmount-e 127.0.0.1

Showmount option: man showmount

-an or-- all displays the customer hostname and mount point directory in a format such as host:dir.

-d or-- directories displays only the name of the directory mounted by the customer.

-e or-- exports displays the output list of the NFS server.

Smooth restart of systemctl reload nfs

Local (internal test) mount access test: showmount-e 127.0.0.1

Query the list of shared resources in different places (public trial):

Create a mount point: mkdir-pv / mynfs

Mount: mount-t nfs 192.168.11.11:/usr / mynsf

Check disk space usage status: df-hT

Access the NFS share in Win7/10:

1. Install the nfs client (client) program.

Run Win+R-- > control Control Panel-- > programs-- > turn on or off the windows feature-- > NFS Services-- > check "NFS client"-- > OK.

two。 Run Win+R-- > cmd-- > enter the following command.

Check the list of shared resources: showmount-e 192.168.11.11

Mount shared resources to K disk: mount 192.168.11.11:/usr k:

Open sharing: win+E--- > double-click the K disk icon

Note: [root@node01 ~] # showmount

Clnt_create: RPC: Program not registered

The nfs service is interrupted due to network reasons. Restart the nfs service and then re-mount on the client side.

The solution is: systemctl restart nfs

Service nfs restart or / etc/rc.d/init.d/nfs restart is also available

Additional operation 1: uninstall shared k disk: right-click the K disk icon-- > disconnect additional operation 2: the a.txt permissions after viewing touch are as follows:

-rw-r--r--. 1 nfsnobody nfsnobody January 21 10:49 a.txt

Description: the owner and group of a.txt are anonymous user accounts of nfsnobody.

2 elements to consider for file sharing permissions:

1. The user's access to the directory itself.

two。 The access permissions set when the directory is shared.

Warning: if a user wants to be readable and writable when accessing the share, both permissions must be readable and writable.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report