CentOS 6.4x64 Build NFS Service

Source: Internet
Author: User

A network File system (Nfs,networkfilesystem) is a mechanism to mount a partition (directory) on a remote host to a local system through Network File system support, Users can manipulate the shared partition (directory) of a remote host on the local system as if it were a local partition.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6C/64/wKiom1VIXkvxVtvgAAEq1MeSNwA007.jpg "title=" NFS. JPG "alt=" Wkiom1vixkvxvtvgaaeq1mesnwa007.jpg "/>

First, the environment

System: CentOS 6.4x64 bit minimized installation

nfs-server:192.168.3.54

nfs-client:192.168.3.55

Ii. server-side installation of NFS services

NFS packages are provided by nfs-utils and depend on the Rpcbind service

[email protected] ~]# Yum install nfs-utils rpcbind-y

Configure the/etc/exports file to share the/data/nfs

[[email protected] ~]# Vim/etc/exports/data/nfs 192.168.3.0/24 (rw,sync,all_squash) #sync to keep data synchronized, that is, to write data synchronously to memory and hard disk. This can lead to a decrease in efficiency #all_squash maps all users who use the NFS server share directory to anonymous accounts

After configuration is ready to start the service, you need to start the Rpcbind before you start NFS

[[email protected] ~]# service rpcbind startstarting rpcbind:                                             [  OK  ][[email protected] ~]# service nfs  startstarting nfs services:  exportfs: failed to stat /data/nfs:  no such file or directory                                                               [  OK   ]starting nfs quotas:                                         [  OK  ]Starting NFS mountd:                                         [   OK  ]Starting NFS daemon:                                         [  ok  ]starting  RPC idmapd:                                         [  ok  ] #上面的报错信息, prompting us to create a data share directory without a data share directory [[Email protected] ~]# mkdir  -p /data/nfs# Restart NFS service [[email protected] ~]# service nfs restartshutting  down NFS daemon:                                    [  OK  ]Shutting down NFS mountd:                                    [  ok  ]shutting  down NFS quotas:                                   [   OK  ]Shutting down NFS services:                                  [  OK  ]Shutting down RPC  idmapd:                                   [   OK  ]Starting NFS services:                                       [  ok  ]starting nfs  quotas:                                        [   OK  ]Starting NFS mountd:                                         [  ok  ]starting  NFS daemon:                                         [  OK  ]Starting RPC idmapd:                                         [  ok   ]


To avoid an impact on the experimental process, we closed the iptables

[[Email protected] ~]# service iptables stop

Third, client configuration

The client only needs to install Nfs-utils

[email protected] ~]# Yum install nfs-utils-y

See what data sharing services are available on server side 192.168.3.54

[[email protected] ~]# showmount-e 192.168.3.54Export list for 192.168.3.54:/data/nfs 192.168.3.0/24

Mount the NFS directory to the/MNT directory

[[email protected] ~]# df -hfilesystem             Size  Used Avail Use% Mounted on/dev/sda3               18G  1.3G    16g   8% /tmpfs                  495m     0  495m   0% / dev/shm/dev/sda1             194m    28m  156m  16% /boot# mount the 192.168.3.54:/data/nfs to the/MNT directory using the NFS protocol [[email  protected] ~]# mount -t nfs 192.168.3.54:/data/nfs /mnt# Viewing Mount results [[email  protected] ~]# df -hfilesystem             Size  Used avail use% mounted on/dev/sda3               18G  1.3G   16G   8% /tmpfs                  495M      0  495M   0% /dev/shm/dev/sda1              194M   28M  156M  16%  /boot192.168.3.54:/data/nfs                        18G  1.6G   16G   10% /mnt

Test: Create a file under the/mnt directory Nfs-client.txt

[[email protected] ~]# Cd/mnt[[email protected] mnt]# touch nfs-client.txttouch:cannot Touch ' nfs-client.txt ': Permissio N denied# result display permission denied, although we gave RW permission in/etc/exports, but the directory itself does not have write permission

Modify permissions for Nfs-server-side/data/nfs

#nfs默认使用的用户是匿名用户nfsnobody, we modify the owner to nfsnobody [[email protected] ~]# chown-r nfsnobody/data/nfs/[[email protected] ~]# Ll/data/total 8drwxr-xr-x 2 nfsnobody root 4096 May 5 14:19 NFS

Re-create the file on the nfs-client side nfs-client

[[email protected] mnt]# Pwd/mnt[[email protected] mnt]# touch nfs-client.txt #现在能够正常创建文件了 [[email protected] mnt]# Lltot Al 0-rw-r--r--1 nfsnobody nfsnobody 0 May 5 14:36 nfs-client.txt

Viewing files on the nfs-server side

[Email protected] ~]# ll/data/nfs/total 0-rw-r--r--1 nfsnobody nfsnobody 0 May 5 14:36 nfs-client.txt

Create a file Nfs-server.txt file on the nfs-server side

[Email protected] ~]# Touch/data/nfs/nfs-server.txt

Viewing results on the nfs-client side

[[email protected] mnt]# ll/mnt/total 0-rw-r--r--1 nfsnobody nfsnobody 0 May 5 14:36 nfs-client.txt-rw-r--r--1 root Root 0 May 5 14:40 nfs-server.txt


Note: After modifying/etc/exports on the nfs-sever side, to reload the configuration file using/etc/init.d/nfs reload, never restart the NFS service using restart. Because the NFS server at work may be providing data sharing services to multiple servers, restarting the NFS service with restart will cause the write operation of the front-end program to fail, which is intolerable.


This article is from the "ly36843" blog, please be sure to keep this source http://ly36843.blog.51cto.com/3120113/1642063

CentOS 6.4x64 Build NFS Service

Related Article

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.