centos6.6 64-bit installation of NFS file sharing system

Source: Internet
Author: User
Tags root access nfsd

First, the environment introduction:

Server: CentOS 192.168.1.1

Client: CentOS 192.168.1.22

Second, installation:

Installation Configuration for NFS:

CentOS 5:

Yum-y Install Nfs-utils Portmap

CentOS 6 (in CentOS 6.3, the Portmap service is the responsibility of Rpcbind):

Yum-y Install Nfs-utils Rpcbind

Third, server-side configuration:

1. Create a shared directory:

[Email protected]/]# mkdir/usr/local/test

2. NFS File configuration:

[Email protected]/]# Vi/etc/exports

#增加一行:

/usr/local/test/192.168.1.22 (Rw,no_root_squash,no_all_squash,sync)

: x save exit;

To make the configuration effective:

[Email protected]/]# Exportfs-r

Note: Configuration file Description:

/usr/local/test/is a shared directory, using an absolute path.

192.168.1.226 (Rw,no_root_squash,no_all_squash,sync) is the client's address and permissions, the address can be a network segment, an IP address or a domain name, the domain name supports wildcard characters, such as: *. Youxia.com, there is no space between the address and permission, the permission description:

Rw:read-write, can read and write;

Ro:read-only, read-only;

Sync: The file is written to both the hard disk and memory;

Async: Files are staged in memory instead of directly to memory;

No_root_squash:nfs the client connects to the server, if root is used, it also has root access to the directory shared by the server. Obviously it's not safe to turn it on.

Root_squash:nfs the client connects to the server, if root is used, then the directory shared by the server, with anonymous user rights, usually he will use nobody or nfsnobody identity;

All_squash: Regardless of which user is used by the NFS client to connect to the server, the directory shared by the server has anonymous user rights;

Anonuid: The UID value of the anonymous user, usually nobody or nfsnobody, can be set at this point;

Anongid: The GID value of the anonymous user.

3. Start:

CENTOS6:

[[Email protected]/]# service Rpcbind start

Starting rpcbind: [OK]

[[Email protected]/]# Service NFS Start

Starting NFS services: [OK]

Starting NFS quotas: [OK]

Starting NFS mountd: [OK]

Stopping RPC IDMAPD: [OK]

Starting RPC IDMAPD: [OK]

Starting NFS daemon: [OK]

[Email protected]/]#

CentOS 5

[[Email protected]/]# service Portmap start

[[Email protected]/]# Service NFS Start

[Email protected]/]#

Iv. Client Mount:

1. Create a directory to mount:

[Email protected] ~]# mkdir/usr/local/test

[Email protected] ~]#

2. Test mount:

[Email protected] ~]# showmount-e 192.168.1.225

Export list for 192.168.1.225:

/usr/local/test 192.168.1.226

[Email protected] ~]#

If shown: RPC mount export:RPC:Unable to receive; errno = No route to host, you need to shut down the firewall on the server (verbose later).

3. Mount:

[Email protected] ~]# mount-t NFS 192.168.1.225:/usr/local/test/usr/local/test

[email protected] ~]# mount

/dev/mapper/volgroup-lv_root on/type ext4 (rw)

Proc On/proc type proc (rw)

Sysfs On/sys type SYSFS (rw)

Devpts on/dev/pts type devpts (rw,gid=5,mode=620)

Tmpfs ON/DEV/SHM type TMPFS (rw)

/DEV/SDA1 on/boot type EXT4 (rw)

None On/proc/sys/fs/binfmt_misc type Binfmt_misc (rw)

Sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

NFSD ON/PROC/FS/NFSD type NFSD (rw)

192.168.1.225:/usr/local/test On/usr/local/test type NFS (rw,vers=4,addr=192.168.1.225,clientaddr=192.168.1.226)

[Email protected] ~]#

If the message is displayed, the Mount succeeds!

4. Test:

The client generates a file:

[Email protected]/]# cd/usr/local/test/

[Email protected] test]# echo "Hello NFS Test" >>test

[email protected] test]# LL

Total 4

-rw-r--r--1 root root 9 13:24 test

[Email protected] test]#

Service-side check:

[Email protected]/]# cd/usr/local/test/

[email protected] test]# LL

Total 4

-rw-r--r--1 root root 9 13:24 test

[Email protected] test]#

Mount success!

V. Lifting the Mount:

[Email protected] ~]# umount/usr/local/test

[email protected] ~]# mount

/dev/mapper/volgroup-lv_root on/type ext4 (rw)

Proc On/proc type proc (rw)

Sysfs On/sys type SYSFS (rw)

Devpts on/dev/pts type devpts (rw,gid=5,mode=620)

Tmpfs ON/DEV/SHM type TMPFS (rw)

/DEV/SDA1 on/boot type EXT4 (rw)

None On/proc/sys/fs/binfmt_misc type Binfmt_misc (rw)

Sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

NFSD ON/PROC/FS/NFSD type NFSD (rw)

[Email protected] ~]#

If you encounter: Umount.nfs:/usr/local/test:device is busy

May use the command:

[Email protected]/]# fuser-m-v/usr/local/test

User Process number Permission command

/usr/local/test/: Root 2798. C.. bash

Root 2996.. C.. su

[Email protected]/]# kill-9 2798


[Email protected]/]# kill-9 2996


[Email protected]/]# umount/usr/local/test

[Email protected]/]#

Vi. server-side firewall settings (NFS-enabled anti-wall configuration):

1, modify the/etc/service, add the following (port number must be under 1024, and not occupied)

# Local Services

Mountd 1011/tcp #rpc. Mountd

Mountd 1011/udp #rpc. Mountd

Rquotad 1012/tcp #rpc. Rquotad

Rquotad 1012/udp #rpc. Rquotad

2. Restart the Linux NFS service


Service NFS Restart

3. RPC-related ports have been fixed at this time, you can add firewall rules for Linux NFS


#portmap

/sbin/iptables-a input-s 192.168.1.0/254-p TCP--dport 111-j ACCEPT

/sbin/iptables-a input-s 192.168.1.0/254-p UDP--dport 111-j ACCEPT

#nfsd

/sbin/iptables-a input-s 192.168.1.0/254-p TCP--dport 2049-j ACCEPT

/sbin/iptables-a input-s 192.168.1.0/254-p UDP--dport 2049-j ACCEPT

#mountd

/sbin/iptables-a input-s 192.168.1.0/254-p TCP--dport 1011-j ACCEPT

/sbin/iptables-a input-s 192.168.1.0/254-p UDP--dport 1011-j ACCEPT

#rquotad

/sbin/iptables-a input-s 192.168.1.0/254-p TCP--dport 1012-j ACCEPT

/sbin/iptables-a input-s 192.168.1.0/254-p UDP--dport 1012-j ACCEPT

#rpc. statd

/sbin/iptables-a input-s 192.168.1.0/254-p TCP--dport 32768-j ACCEPT

/sbin/iptables-a input-s 192.168.1.0/254-p UDP--dport 32768-j ACCEPT


---The TCP method succeeds-------------------------------------------

-A input-m state--state new-m tcp-p TCP--dport 111-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 2049-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 1011-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 1012-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 32768-j ACCEPT

The client encountered a problem at the time of mounting, perhaps the network is not very stable, NFS is the default UDP protocol, replaced by the TCP protocol:

Mount-t NFS 192.168.1.225:/usr/local/test/usr/local/test-o Proto=tcp-o nolock


This article is from the "Tangjilinux" blog, make sure to keep this source http://1132818999.blog.51cto.com/10422963/1685945

centos6.6 64-bit installation of NFS file sharing 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.