Describes the specific configuration of the NFS Service

A, NFS introduction
         1. Concept: Its main function is to allow the network can share files or directories each other between different host systems. NFS server
                      -side shared data directory to mount the NFS client on the local system (that is, under a mount point). NFS from the passenger
                       terminal of its own disk partition or directory, like households, while the directory server is actually tamper segment.
                  Use the windows system like NFS network file system, network shares, were it a security, network drive mappings,
                  this is where the samba Linux and similar services.
          2.NFS in the enterprise application scenarios
                   in scenes work in enterprise cluster architecture, NFS network file sharing systems are generally used to store video, images,
                   attachments and other static resource files
Second, why the need for shared storage
   1. solve the shared storage multiple servers require data synchronization operations, that is, the existence of files on shared storage backend server, accessed via the front-end web server.
   Tip: Small and Medium Enterprises Internet companies generally do not buy expensive hardware store, if large companies developed rapidly, it may be a temporary storage buy Top websites pressure, when the site continues to increase concurrency, hardware store expansion is relatively strenuous.
Three, NFS mounts principle Details
    Tip: mount the source target
                     mount remote address: / shared directory / mount directory
    Question: nfs transmission port is not fixed, resulting in the client does not know which port data transfer
    solutions: that is RPC (Chinese consciousness is the Remote Procedure Call) protocol / service to achieve,
Fourth, what is the RPC (middleman )
    because NFS support We are quite many different functions will use a different program to start, a start function is activated for each of a number of ports to transfer data, thus NFS port corresponding to the function not fixed but randomly selected port to transfer data. RPC will need
five or nfs clients to read and write the whole process simple principle
   1. First turn on RPC service
   2. Start NFS service, then register to start RPC server port
   3. Customer service requests nfx
   4.RPC returned to the client port
   5. the client took the RPC request to port to transfer data
six, NFS software
   to deploy nfs service to install the following packages
   * nfs-utils: this is the main NFS service
     include rpc.nfsd, rpc.mountd two daemons and related the documentation and execute command files.
   * portmap: cen5 following rpc main program
   * rpcbind rpc main program is cen6 below
seven, NFS configuration
     1. First check the installation of the package:
[root@localhost ~]# rpm -aq nfs-utils portamp rpcbind

 

  2. Then install:

 

[root@localhost ~]# yum install nfs-utils portmap rpcbind -y     /客户和服务端都需要安装

 

 

 

      3.启动RPC服务:
[root@nfskhd ~]# /etc/init.d/rpcbind start ****RPC默认端口10000

 


      4.查看rpc服务进程是否存在:
[root@nfskhd ~]# ps -ef|grep rpc

 


      5.查看rpc有没有房源:
[root@nfskhd ~]# rpcinfo -p localhost

 


      6.启动NFS服务:
[root@nfskhd ~]# /etc/init.d/nfs start 然后再看RPC服务

 


      7.设置开机自启动RPC和NFS:
[root@nfskhd ~]# chkconfig nfs  rpcbind       on

 


      8.检查:
[root@nfskhd ~]# chkconfig --list nfs

注意****客户端就开启rpc服务就行***

 ***nfs的配置文件在/etc/exports***
 

      9.创建一个需要共享出去的文件夹:
mkdir /date

 

  
  10.打开nfs配置文件:
vi /etc/exports
 #shard data for bbs by oldboy at 20190808
 /data 192.168.157.131/24(rw,sync)      #ro的话是只读权限#async这个是写入到缓存
 共享目录   共享的网段      (权限,同步到本地磁盘)

 


      11.检查一下配置文件:
cat /etc/exports

 

 
      12.重启一下nfs服务:
/etc/init.d/nfs reload

 


      13.在本机检查能否共享:
showmount -e localhost###这里注意被访问的NFS服务器上的防火墙没有添加规则,向iptables里面添加以下查看的所有端口即可

 


       14.检查客户机能否查看共享:
 showmount -e 192.168.157.130 

 


       15.在客户端进行挂载:
mount -t nfs 192.168.157.130:/data /mnt

 


        16.到/mnt下面去查看是否共享成功了 
cd /mnt     
 ls

注意:刚才给/data的权限是共享读写权限但是这个文件夹本身对其他用户不开放写权限如果客户要在/data下创建文件可以把客户端的所属组改为服务器然后把/data文件的所属组权限改为rw就可以了

 

  17.如果每次开机后都想自动挂载nfs的话:
ehco "mount -t nfs 192.168.157.130:/data /mnt">>/etc/rc.local

 


 
 

Guess you like

Origin www.cnblogs.com/zrxuexi/p/11321785.html