Configure NFS and nfs in linux

Source: Internet
Author: User
Tags nfsd

Configure NFS and nfs in linux

1. Install nfs-utils

[Root @ server05 ftp] # yum install nfs-utils

Ii. Configuration

Create some files

[Root @ server05/] # mkdir common

[Root @ server05/] # cd common/

[Root @ server05 common] # cp/etc/passwd ./

[Root @ server05 common] # vim abc

[Root @ server05 common] # ls

Abc passwd

 

Edit configuration file

[Root @ server05 ~] # Vim/etc/exports

 

/Common 172.164.203 (rw)

 

Share/common with 172.164.203 and grant rw permission

Restart service

[Root @ server05 Desktop] # service nfs restart

Disable Firewall:

[Root @ server05 Desktop] # iptables-F

[Root @ server05 Desktop] # setenforce 0

On 172.164.203:

[Root @ station3 ~] # Showmount-e 172.164.103

Export list for 172.164.103:

/Common 172.164.203

The shared directory 172.164.103/common is displayed.

 

Any machine with the same network segment:

[Root @ station3 ~] # Showmount-e 172.164.103

Export list for 172.164.103:

/Common 172.164.203

So NFS is insecure.

 

Mount the common directory on 172.164.203

[Root @ station3/] # cd mnt/

[Root @ station3 mnt] # ls

Hgfs

[Root @ station3 mnt] # mkdir commonmmnt

[Root @ station3 mnt] # mount 17.04.103:/common/mnt/commonmmnt/

[Root @ station3 mnt] #

 

Mounted successfully

 

[Root @ station3 mnt] # cd commonmmnt/

[Root @ station3 commonmmnt] # ls

Abc passwd

 

You can see the Mount content.

 

To 172.164.103

[Root @ server05 Desktop] # vim/etc/exports

Changed:

/Common 172.164.0/24 (rw, sync)

 

# Sync can be mounted on hosts of the same network segment to indicate synchronization.

 

Save and exit

[Root @ server05/] # chmod o + w common/

Restart service

To 172.164.203, Unmount and remount

[Root @ station3 commonmmnt] # cd ..

[Root @ station3 mnt] # umount/mnt/commonmmnt/

[Root @ station3 mnt] # mount 17.04.103:/common/mnt/commonmmnt/

 

[Root @ station3 commonmmnt] # mkdir nfsdis

[Root @ station3 commonmmnt] # ls

Abc nfsdis passwd

 

To 172.164.103

[Root @ server05/] # cd/common/

[Root @ server05 common] # ls

Abc nfsdis passwd

 

You can see that the folder you just created achieves synchronization.


NFS server configuration process

Before talking about the operation of nfs server, let's look at some things related to nfs server:
RPC (Remote Procedure Call)
NFS itself does not provide information transmission protocols and functions, but NFS allows us to share data over the network, because NFS uses some other transmission protocols. These Transport Protocol warriors use this RPC function. NFS itself is a program that uses RPC. NFS is also an rpc server. Therefore, the RPC service must be started wherever NFS is used, whether it is an nfs server or an nfs client. In this way, the SERVER and CLIENT can implement the corresponding program port through RPC. We can understand the relationship between RPC and NFS in this way: NFS is a file system, while RPC is responsible for information transmission.
DAEMONS to be started for NFS
Pc. nfsd: Mainly used to detect complex logon permissions.
Rpc. mountd: Responsible for the NFS file system. When the CLIENT logs on to the SERVER through rpc. nfsd, it manages the files accessed by clinet.
Nfs server requires two packages on the redhat linux platform: nfs-utils and PORTMAP.
Nfs-utils: provides two nfs daemons suites: rpc. nfsd and rpc. mountd.
Portmap: NFS can be regarded as an rpc server program. to start an rpc server program, you must do the corresponding work of the PORT, and such a task is completed by PORTMAP. In general, PortMap is used for PORT mapping.
I. server-side settings (taking LINUX as an example)
Server-side settings are all set in the/etc/exports file. The format is as follows:
Directory host name 1 or IP1 (parameter 1, parameter 2) host name 2 or IP2 (parameter 3, parameter 4)
The above format indicates that the same directory is shared to two different hosts, but the permissions and parameters provided to the two hosts are different. Therefore, the permissions obtained by the two hosts are set separately.
You can set the following parameters:
Rw: read/write permission;
Ro: Read-Only permission;
No_root_squash: if the user logging on to the NFS host is a ROOT user, the user has the ROOT permission. this parameter is insecure and is not recommended.
Root_squash: when the user logging on to the NFS host and using the shared directory is root, the user's permissions will be compressed into anonymous users, generally, his UID and GID will become the nobody identity;
All_squash: No matter what users log on to the NFS host, they will be reset to nobody.
Anonuid: sets all users logging on to the NFS host to the specified user id, which must exist in/etc/passwd.
Anongid: Same as anonuid, but changed to group ID!
Sync: data is synchronized to the storage.
Async: The data is temporarily stored in the memory and not directly written to the hard disk.
Insecure allows unauthorized access from this machine.
For example, you can edit/etc/exports as follows:
/Tmp * (rw, no_root_squash)
/Home/public 192.168.0. * (rw) * (ro)
/Home/test 192.168.0.100 (rw)
/Home/linux * .the9.com (rw, all_squash, anonuid = 40, anongid = 40)
Set ...... the remaining full text>
 
Linux nfs configuration problems, urgent !!!!

"No route to the Host", do you understand? Routing ah, routing, the so-called routing, is the network path from machine A to machine B. Can you ping it? The configuration is correct, but you have to ensure that the two machines can communicate. It seems that the client cannot find the server.
Supplementary answer:
Can I ping the other party? You should use basic ifconfig. The configuration files involved include/etc/sysconfig/network/config /*
/Etc/hosts
/Etc/resolv. conf
/Etc/networks
/Etc/nsswitch. conf
A client in a peer network uses the IP address of the server as the gateway. If you pass through a vro, set a static route on the vro.
Supplementary answer:
Are you using a router? Setting static routes on a vro does not work. You can directly use a cross-line peer-to-peer connection to test whether NFS works. If you can work, the problem still lies in the router.
OK. Add the read and run bits to all the other bits in the shared file path. Command is
Chmod-R 755/nfsroot/pmp-root

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.