I. Introduction TO Services for NFS
NFS is the network file system. The main function is to allow different servers to share files or directories across the network. NFS clients are typically application servers (such as web, load balancing, and so on) that can be mounted to mount the NFS server-side shared directory to the NFS client local directory. NFS relies on protocol with RPC (remote Procedure Call) during text transfer. NFS itself does not provide the protocol and function of transmitting information, but it can use the network to share functions such as pictures, videos, attachments and so on. The RPC service needs to be started wherever NFS is used, whether it is the server or Client of NFS. NFS and RPC relationships: it can be understood that NFS is a network file system (likened to renting a homeowner), while RPC is responsible for the transmission (intermediary) of information, the client (equivalent to renting a tenant)
Second, the system environment
[Email protected] ~]# Cat/etc/redhat-release # #查看系统版本信息
CentOS Release 6.7 (Final)
[Email protected] ~]# Uname-r # #查看内核信息
2.6.32-573.el6.x86_64
[Email protected] ~]# Uname-m # #查看系统是32位还是64位的
x86_64
Third, service-side configuration
Before starting the NFS service, you first start the RPC service (CentOS5 is the Portmap service, CentOS6.6 later is the Rpcbind service), or the NFS server cannot register with the RPC service. In addition, if the RPC service restarts, the original and some NFS ports are lost, so as long as the RPC service restarts, the NFS service restarts the new random port number for the RPC to reregister. After the general modification of the NFS configuration file, do not need to restart the service, direct smooth restart, command:/etc/init.d/nfs reload or EXPORTFS-RV can be modified/etc/exports effective. /etc/init.d/nfs Reload's role is: Let the request has reached the server to him, but did not reach the server's request, it broke off. The equivalent of we go to the station car, the car is about to start, already on the bus can start normally, did not catch the car there is no way to go with the car.
To deploy the NFS service, you need to install the following package:
1) Main program of NFS-UTILS:NFS service
2) Rpcbing:nfs can be considered as an RPC main program, before starting any RPC program, you need to do the port and function mapping work
1) View the NFS packages
[Email protected] ~]# Rpm-qa nfs-utils rpcbind
NFS and RPC are not installed by default and require Yum installation
2) CentOS6.7 does not install software packages by default, you can install NFS software using the Yum install nfs-utils rpcbind-y command
[email protected] ~]# Yum install nfs-utils rpcbind-y
[Email protected] ~]# Rpm-qa nfs-utils rpcbind
Nfs-utils-1.2.3-70.el6_8.2.x86_64
Rpcbind-0.2.0-12.el6.x86_64
3) Start the NFS service
First step: Start the RPC service first
[Email protected] ~]#/etc/init.d/rpcbind start #启动rpc服务
[Email protected] ~]#/etc/init.d/rpcbind status #查看rpc服务状态
Rpcbind (PID 4269) is running ...
Step Two: Start the NFS service
[Email protected] ~]#/etc/init.d/nfs start #启动nfs服务
[Email protected] ~]#/ETC/INIT.D/NFS status #查看nfs服务状态
RPC.SVCGSSD has stopped
RPC.MOUNTD (PID 3282) is running ...
NFSD (PID 3298 3297 3296 3295 3294 3293 3292 3291) running ...
Rpc.rquotad (PID 3277) is running ...
You must start the RPC service before you start the NFS service, and if you start Service for NFS, you will fail when you start the services, as indicated below
[[email protected] ~]#/etc/init.d/nfs start
Start NFS service: [OK]
Disable NFS quotas: Unable to register service: RPC: unable to receive; errno = Deny connection
Rpc.rquotad:unable to register (Rquotaprog, Rquotavers, UDP).
Failed
Start NFS mountd: [Failed]
To start the NFS daemon:
[[email protected] ~]# rpcinfo-p 192.168.8.7 #查看NFS服务向rpc注册的端口信息, the main port number is: 111
Program vers Proto Port service
100000 4 TCP 111 Portmapper
100000 3 TCP 111 Portmapper
100000 2 TCP 111 Portmapper
100000 4 UDP 111 Portmapper
100000 3 UDP 111 Portmapper
100000 2 UDP 111 Portmapper
100011 1 UDP 875 Rquotad
100011 2 UDP 875 Rquotad
100011 1 TCP 875 Rquotad
100011 2 TCP 875 Rquotad
Step three: Check if boot is self-booting
[[email protected] ~]# chkconfig NFS on
[Email protected] ~]# chkconfig rpcbind on
[[email protected] ~]# Chkconfig--list NFS
NFS 0: Shutdown 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off
[Email protected] ~]# chkconfig--list rpcbind
Rpcbind 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off
[Email protected] ~]# Tail-2/etc/rc.local
/etc/init.d/rpcbind start
/etc/init.d/nfs start
In the work, most are unified in accordance with the operation and maintenance specifications to the service of the start command into the/etc/rc.local, instead of using chkconfig to manage, all services once boot from the boot must be put into/etc/rc.local. The advantage is that once the people who manage this server leave the business migration can be easily through the/etc/rc.local to see the server corresponding to the relevant services, can be convenient operation and maintenance management.
4) Configuration of NFS server configuration files
The NFS Default profile path is:/etc/exports, the file is empty by default. The format of the/etc/exports configuration file is:
NFS shared Directory for NFS client address (parameter 1, parameter 2)
[[Email protected] Desktop]# cat/etc/exports
#/media/u1 * (rw,no root squash)
/MEDIA/U1 192.168.8.7/23 (rw,sync) # #一条配置搞定NFS配置文件
Where:/MEDIA/U1 is the server-side shared directory 192.168.8.7/23 the client IP address of the shared directory
NFS Shared directory: The actual directory to be shared for the NFS server side, using the decision path, such as (/MEDIA/U1). Note The local permissions on the shared directory require read and write permissions, make sure that the local directory can be read and written to NFS client addresses by users of NFS clients: The NFS client address for an accessible shared directory that is authorized for NFS server-side, can be a separate IP address or host name, domain name, or the address of the entire network segment. Create the/MEDIA/U1 directory, and both the owner and the group are: Nfsnobody, where nfsnobody is the default user when installing Service for NFS
[Email protected] ~]# mkdir/media/u1-p
[Email protected] ~]# chown-r Nfsnobody:nfsnobody/media
[Email protected] ~]# Ls-ld/media
Drwxr-xr-x 6 nfsnobody nfsnobody 4096 December 8 20:17/media
[Email protected] ~]#/etc/init.d/nfs Reload
[[email protected] ~]# showmount-e 192.168.8.7 # #本地测试, indicating successful service-side test
Export list for 192.168.8.7:
/MEDIA/U1 192.168.8.7/23
Iv. Client Configuration
1. As with the client and server, install the NFS and RPM installation packages as well. (Configuration See server side)
2. The client needs to start the RPC service, join the boot-up and do not need to start the NFS service. (Configuration See server side)
3. Testing
First step: Ping, can ping the server-side IP address
[[Email protected] Desktop]# ping 192.168.8.7
PING 192.168.8.7 (192.168.8.7) bytes of data.
Bytes from 192.168.8.7:icmp_seq=1 ttl=64 time=0.010 ms
Bytes from 192.168.8.7:icmp_seq=2 ttl=64 time=0.010 ms
Bytes from 192.168.8.7:icmp_seq=3 ttl=64 time=0.010 ms
Bytes from 192.168.8.7:icmp_seq=4 ttl=64 time=0.011 ms
^c
---192.168.8.7 ping statistics---
4 packets transmitted, 4 received, 0% packet loss, time 3213MS
RTT Min/avg/max/mdev = 0.010/0.010/0.011/0.002 ms
Step two: Telnet Server port 111
[[Email protected] ~]# Telnet 192.168.8.7 111
Trying 192.168.8.7 ...
Connected to 192.168.8.7.
Escape character is ' ^] '.
Step Three: Showmount server
[Email protected]/]# showmount-e 192.168.8.7
Export list for 192.168.8.7:
/MEDIA/U1 192.168.8.7/23
Fourth step: Mount, File Share
[Email protected] ~]# mount-t NFS 192.168.8.7:/media/u1/media/tmsusb/
Fifth step: See if the mount is successful
[Email protected]/]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/vg_lfg1307kstmsv-lv_root 55G 11G 42G 21%/
Tmpfs 3.9G 176K 3.9G 1%/DEV/SHM
/DEV/SDA1 485M 40M 421M 9%/boot
/dev/sdb 8.9T 6.2T 2.3T 74%/lms-data
192.168.8.7:/MEDIA/U1 917G 559G 312G 65%/media/tmsusb
Indicates that the client test was successful and the configuration completed.
Server-Side Desktop one-click Mount:
#!/bin/bash ssh lfg1-307-kstmsv ' umount-f/media/tmsusb ' ssh lfg1-307-kstmsv ' umount/media/tmsusb ' ssh LFG1-307-KSTMSV ' Mount-t NFS 192.168.8.7:/media/u1/media/tmsusb/' ssh lfg1-307-kstmsv ' ls-r-l/media/tmsusb '
Server-Side Desktop one-click Uninstall:
#!/bin/bashssh lfg1-307-kstmsv ' umount-f/media/tmsusb ' ssh lfg1-307-kstmsv ' umount/media/tmsusb ' umount-f/media/ U1umount/media/u1
NFS File System detailed http://www.linuxidc.com/Linux/2016-06/131940.htm
Ubuntu 12.04 Installing NFS server http://www.linuxidc.com/Linux/2012-09/70728.htm
Using NFS remote shared resources based on lamp platform to realize site building http://www.linuxidc.com/Linux/2016-07/133510.htm
File Server NFS Configuration detailed http://www.linuxidc.com/Linux/2013-06/86542.htm
Build NFS Network File System server http://www.linuxidc.com/Linux/2013-07/87367.htm under Ubuntu
NFS1.3 installation in CentOS 7.2 http://www.linuxidc.com/Linux/2016-10/135970.htm
Ubuntu 14.04 Installation Configure NFS server http://www.linuxidc.com/Linux/2016-04/129848.htm
Installation and configuration of Linux Server for NFS