{"id":4119,"date":"2015-01-23T19:58:40","date_gmt":"2015-01-23T11:58:40","guid":{"rendered":"http:\/\/rmohan.com\/?p=4119"},"modified":"2015-01-23T19:58:40","modified_gmt":"2015-01-23T11:58:40","slug":"nfs-server-centos-6-5","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=4119","title":{"rendered":"NFS SERVER Centos 6.5"},"content":{"rendered":"<p>yum install -y nfs-utils rpcbind<\/p>\n<p>Environmental instructions<\/p>\n<p>nfs server system: CentOS 6.5 x86_64<br \/>\nnfs server IP: 192.168.1.10<br \/>\nnfs client system: CentOS 6.5 x86_64<br \/>\nnfs client IP: 192.168.1.12<\/p>\n<p>Install the NFS server (192.168.1.10)<\/p>\n<p>Step-1: install nfs-utils and rpcbind, run the following command:<\/p>\n<p>yum install -y nfs-utils rpcbind<\/p>\n<p>Step-2: specify a fixed port for NFS, run the following command:<br \/>\nvi \/etc\/sysconfig\/nfs<br \/>\nRQUOTAD_PORT=30001<br \/>\nLOCKD_TCPPORT=30002<br \/>\nLOCKD_UDPPORT=30002<br \/>\nMOUNTD_PORT=30003<br \/>\nSTATD_PORT=30004<\/p>\n<p>Step-3: Open the firewall above the port, run the following command:<\/p>\n<p>iptables  -I INPUT -p tcp &#8211;dport 111 -j ACCEPT<br \/>\niptables  -I INPUT -p udp &#8211;dport 111 -j ACCEPT<br \/>\niptables  -I INPUT -p tcp &#8211;dport 2049 -j ACCEPT<br \/>\niptables  -I INPUT -p udp &#8211;dport 2049 -j ACCEPT<br \/>\niptables  -I INPUT -p tcp &#8211;dport 30001:30004 -j ACCEPT<br \/>\niptables  -I INPUT -p udp &#8211;dport 30001:30004 -j ACCEPT<br \/>\nservice iptables save<br \/>\nservice iptables restart<\/p>\n<p>Step-4: Set SELinux for the licensing status, run the following command:<br \/>\nvi \/etc\/selinux\/config<br \/>\nSELINUX=enforcing<\/p>\n<p>SELINUX=permissive<\/p>\n<p>setenforce 0<\/p>\n<p>Step-5: Create a shared directory, run the following command:<\/p>\n<p>mkdir -p \/data\/nfs_share<\/p>\n<p>above command will create a shared directory \/data\/nfs_share<\/p>\n<p>Step-6:Configuring exports file, run the following command:<\/p>\n<p>vi \/etc\/exports<\/p>\n<p>a new row at the end of the above documents, as follows:<br \/>\n\/data\/nfs_share 192.168.1.12(rw,sync,no_root_squash)<br \/>\n\/data\/nfs_share *(ro)<\/p>\n<p>This line means that only 192.168.1.12 client can to read and write permission to mount the shared directory, other clients read-only privileges to mount.<\/p>\n<p>Step-7: Start NFS-related services, run the following command:<br \/>\nchkconfig nfs on<br \/>\nchkconfig rpcbind on<\/p>\n<p>root@server ~]# chkconfig rpcbind on<br \/>\n[root@server ~]# service nfs start<br \/>\nservice rpcbind start<br \/>\nStarting NFS services:                                     [  OK  ]<br \/>\nStarting NFS mountd:                                       [FAILED]<br \/>\nStarting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connectio                                                        n refused)<br \/>\nrpc.nfsd: unable to set any sockets for nfsd<br \/>\n                                                           [FAILED]<br \/>\n[root@server ~]# service rpcbind start<br \/>\nStarting rpcbind:                                          [  OK  ]<br \/>\n[root@server ~]# service rpcbind start<br \/>\n[root@server ~]# service nfs start<br \/>\nStarting NFS services:                                     [  OK  ]<br \/>\nStarting NFS mountd:                                       [  OK  ]<br \/>\nStarting NFS daemon:                                       [  OK  ]<br \/>\nStarting RPC idmapd:                                       [  OK  ]<br \/>\n[root@server ~]# service nfs restart<br \/>\nShutting down NFS daemon:                                  [  OK  ]<br \/>\nShutting down NFS mountd:                                  [  OK  ]<br \/>\nShutting down NFS services:                                [  OK  ]<br \/>\nShutting down RPC idmapd:                                  [  OK  ]<br \/>\nStarting NFS services:                                     [  OK  ]<br \/>\nStarting NFS mountd:                                       [  OK  ]<br \/>\nStarting NFS daemon:                                       [  OK  ]<br \/>\nStarting RPC idmapd:                                       [  OK  ]<\/p>\n<p>service nfs start<br \/>\nservice rpcbind start<\/p>\n<p>Step-8: the relevant port inspection of NFS is already enabled, run the following command:<br \/>\nservice iptables status<br \/>\nrpcinfo -p localhost<\/p>\n<p>2. Install NFS client (192.168.1.12)<\/p>\n<p>NFS client does not need to start the NFS service, but you need to install nfs-utils, run the following command:<br \/>\nyum install -y nfs-utils autofs<\/p>\n<p>3. Manually mount the NFS share<\/p>\n<p>Step-1: determine the mount point, run the following command:<br \/>\nshowmount -e 192.168.1.10 -e option to display the export list NFS server-side.<\/p>\n<p>Step-2: Create the mount directory, run the following command:<br \/>\n mkdir -p \/root\/remote_dir<\/p>\n<p>\/root\/remote_dir for the mount point directory shared directory.<\/p>\n<p>Step-3: Mount the shared directory, run the following command:<br \/>\nmount -t nfs 192.168.1.10:\/data\/nfs_share \/root\/remote_dir<\/p>\n<p>remote_dir which, -t option specifies that the type of the file system for nfs.<\/p>\n<p>Step-4: After sharing the end catalog, unload the shared directory, run the following command:<br \/>\numount \/root\/remote_dir<\/p>\n<p>4. boot automatically mount<\/p>\n<p>Adding to the fstab file to mount the entries of the shared directory, you can achieve startup automatically mount, but then the connection with the NFS server will always be active. Run the following command:<\/p>\n<p>mkdir -p \/root\/remote_dir<\/p>\n<p>vi \/etc\/fstab<\/p>\n<p>at the end of the above documents to join mount entries shared directory, as follows:<br \/>\n192.168.1.10:\/data\/nfs_share \/root\/remote_dir nfs defaults 0 0<\/p>\n<p>where the first five fields Set to 0 to the shared directory file system does not use the dump command to dump the first six field is set to 0 indicates that the shared directory file system does not need to use the fsck command to check.<\/p>\n<p>In addition, you can use the automounter (autofs) achieve on-demand to automatically mount a network shared directory. When the share is no longer used, and inactivity certain time automounter will share unmounting.<\/p>\n<p>5. Demand automatically mount (special map)<\/p>\n<p>When the autofs service is running, the system exists in a file called \/ special directory net, but the directory will appear empty. Step NFS client through a special map-demand automatically mount the shared directory is as follows:<\/p>\n<p>Step-1: Modify the timeout period of inactivity, run the following command:<\/p>\n<p>vi \/etc\/sysconfig\/autofs<br \/>\nTIMEOUT=300<br \/>\nTIMEOUT=600<br \/>\nthe above file TIMEOUT = 300 replaced TIMEOUT = 600 is the timeout inactivity by five minutes modified to 10 minutes.<br \/>\nAfter configuration is complete, <\/p>\n<p>restart the autofs service: service autofs restart<\/p>\n<p>Step-2: access network shared directory, run the following command:<br \/>\ncd \/net\/192.168.1.10\/data\/nfs_share When you run the above command, <\/p>\n<p>autofs will automatically mount an NFS server in a network shared directory. <\/p>\n<p>Step-3: Uninstall the mounted network share, the details are as follows:<br \/>\nAll files and directories under \/net\/192.168.1.10\/data\/nfs_share stop use and the timeout expires after (10 minutes),<br \/>\nautofs will unload the shared directory.<\/p>\n<p>6. Demand automatically mount (an indirect map)<\/p>\n<p>Step-1: Modify the timeout period of inactivity, run the following command:<\/p>\n<p>vi \/etc\/sysconfig\/autofs<br \/>\n the above file <\/p>\n<p>TIMEOUT=300<br \/>\nreplaced<br \/>\nTIMEOUT=600<\/p>\n<p>is the timeout inactivity by five minutes modified to 10 minutes.<\/p>\n<p>Step-2: the establishment of a shared directory mount point of the parent directory, run the following command:<\/p>\n<p>mkdir -p \/root\/demo<\/p>\n<p>Step-3: Configure shared parent directory directory mount point, run the following command:<br \/>\nvi \/etc\/auto.master<br \/>\nthe content of the file are as follows:<\/p>\n<p>\/root\/demo    \/etc\/auto.demo<\/p>\n<p>is the parent directory mount point, this directory is always visible in the system, by autofs service monitoring, to determine whether the &#8220;need&#8221; to mount \/ create subdirectories mount point.<br \/>\n\/etc\/auto.demo for a single configuration file that contains the autofs service under this parent directory management subdirectory mount point list.<\/p>\n<p>Step-4: Configure shared directory mount point directory, run the following command:<br \/>\nvi \/etc\/auto.demo<\/p>\n<p>the content of the file are as follows: remote_dir -rw 192.168.1.10:\/data\/nfs_share which, remote_dir subdirectory mount point, <\/p>\n<p>this directory is not normally visible only when the autofs service creates this directory and<br \/>\nWhen after Mount sharing them directly naming \/ access, it will become visible. -rw to mount a network share when you want to use the mount option.<br \/>\n192.168.1.10:\/data\/nfs_share need to mount an NFS server and shared directories.<\/p>\n<p>remote_dir -rw 192.168.1.10:\/data\/nfs_share<\/p>\n<p>Step-5: Restart the autofs service, run the following command:<\/p>\n<p>service autofs restart<\/p>\n<p>Step-6: access to network shared directory, run the following command:<br \/>\ncd \/root\/demo\/remote_dir<\/p>\n<p>After running the above command, autofs will automatically create a mount point directory and mount the shared directory.<\/p>\n<p>Step-7: offload network shared directory, the details are as follows:<\/p>\n<p>All files and directories under \/root\/demo \/remote_dir Stop use<br \/>\nand the timeout expires after (10 minutes), autofs will unload the shared directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>yum install -y nfs-utils rpcbind<\/p>\n<p>Environmental instructions<\/p>\n<p>nfs server system: CentOS 6.5 x86_64 nfs server IP: 192.168.1.10 nfs client system: CentOS 6.5 x86_64 nfs client IP: 192.168.1.12<\/p>\n<p>Install the NFS server (192.168.1.10)<\/p>\n<p>Step-1: install nfs-utils and rpcbind, run the following command:<\/p>\n<p>yum install -y nfs-utils rpcbind<\/p>\n<p>Step-2: specify a fixed port for NFS, run the [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,50],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4119"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4119"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4119\/revisions"}],"predecessor-version":[{"id":4120,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4119\/revisions\/4120"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}