CentOS 6 installation of NFS and key configuration detailed

Source: Internet
Author: User
Tags chmod mkdir centos iptables

NFS is a network file system that allows multiple machines to share a file resource that accesses a single host.
NFS may be used in the following situations:
1. Multiple PCs share printers, CD-ROMs, and other resources using the same PC.
2, multiple clients to access the same network resources, to ensure that access to the same resource is not different.
3, Web applications, if you need to access certain domain names to another server, you can configure the folder under the domain name through NFS to the target server.

The following Records centos6.* NFS installation and configuration:

To install NFS, there must be more than two machines, one for the host and the other as the client.

Main:
172.26.11.100
Client:
172.26.11.74

First, install on the primary server:

The code is as follows Copy Code
Yum-y Install Nfs-utils Rpcbind

#建立需要共享的文件目录:
Mkdir/data/share
echo '/data/share/1.txt ' >
Chmod-r 777/data/share

#配置文件设置:
Vim/etc/exports
######################
#表示共享目录为/data/share,172.26.11.0-172.26.11.254 range IP Access, access is readable writable rw,root user
/data/share 172.26.11.0/24 * (Insecure,rw,async,no_root_squash)

######################

#设置开机启动
Chkconfig NFS On
#手动启动nfs, note that you need to start Rpcbind before you start NFS
/etc/init.d/rpcbind start
/etc/init.d/nfs start

Firewall for #配置针对NFS server
Vim/etc/sysconfig/nfs
################################
# Port Rquotad should listen on.
rquotad_port=875
# TCP Port RPC.LOCKD should listen on.
lockd_tcpport=32803
# UDP Port RPC.LOCKD should listen on.
lockd_udpport=32769
# Port RPC.MOUNTD should listen on.
mountd_port=892
###############################
Rpcinfo-p localhost
Service NFS Restart
Rpcinfo-p localhost

Vim/etc/sysconfig/iptables
###################################
...

: Rh-firewall-1-input-[0:0]
-A input-j Rh-firewall-1-input
-A forward-j Rh-firewall-1-input
-A rh-firewall-1-input-i lo-j ACCEPT
-A rh-firewall-1-input-p ICMP--icmp-type any-j ACCEPT
-A rh-firewall-1-input-p 50-j ACCEPT
-A rh-firewall-1-input-p 51-j ACCEPT
-A rh-firewall-1-input-p UDP--dport 5353-d 224.0.0.251-j ACCEPT
-A rh-firewall-1-input-p udp-m UDP--dport 631-j ACCEPT
-A rh-firewall-1-input-p tcp-m tcp--dport 631-j ACCEPT
-A rh-firewall-1-input-m state--state established,related-j ACCEPT
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 111-j ACCEPT

...

##################################

/etc/init.d/iptables restart

Second, install on the client:

  code is as follows copy code

Yum-y Install nfs-utils rpcbind
 
#查看是否能访问172.26.11.100 NFS:
showmount-e 172.26.11.100
 
#建 The same directory:
Mkdir/data/share
chmod-r 777/data/share
#挂载到nfs服务器的目录:
mount-t NFS 172.26.11.100:/data/share / /data/share/
 
#查看是否能看到里面的1. txt
ls/data/share/
 
#设置开机自动挂载:
Echo mount-t NFS 172.26.11.100:/data/share/ /data/share/"  >>/etc/rc.d/rc.local
#重启机器:
Init 6

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.