centos7搭建nfs

#服务端

centos7.2 

#

yum install nfs-utils  rpcbind -y

chmod -R 777 /u02/liyangjie

#start the server

systemctl enable rpcbind

systemctl enable nfs-server

systemctl enable nfs-lock

systemctl enable nfs-idmap

systemctl start rpcbind

systemctl start nfs-server

systemctl start nfs-lock

systemctl start nfs-idmap

vim /etc/exports

#添加如下内容,允许10.0.0.161 10.0.0.196 10.0.0.168 这几个ip访问,这次进行了更正,上次出现了少少的配置错误。

1
/u02/liyangjie 10.0.0.161(rw,sync,no_root_squash,no_subtree_check) 10.0.0.196(rw,sync,no_root_squash,no_subtree_check) 10.0.0.168(rw,sync,no_root_squash,no_subtree_check)

#

systemctl restart nfs-server

firewall-cmd --permanent --zone=public --add-service=nfs

firewall-cmd --reload



#客户端NFS client end

yum install nfs-utils

#Now create the NFS directory mount point as follows:

mkdir -p /mnt/nfs/home

mkdir -p /mnt/nfs/var/nfsshare

#Start the services and add them to boot menu.

systemctl enable rpcbind

systemctl enable nfs-server

systemctl enable nfs-lock

systemctl enable nfs-idmap

systemctl start rpcbind

systemctl start nfs-server

systemctl start nfs-lock

systemctl start nfs-idmap

Next we will mount the NFS shared content in the client machine as shown below:

mount -t nfs 10.0.0.10:/u02/liyangjie /mnt/nfs/home/



#设置开机挂载

# Permanent NFS mounting

We need to mount the NFS share at client end permanent that it must be mounted even after reboot. So we need to add the NFS-share in /etc/fstab file of client machine as follows:

nano /etc/fstab

Add the entries like this:

[...]

10.0.0.10:/u02/liyangjie    /mnt/nfs/home   nfs defaults 0 0 



注释:查看了外国的一篇文章,简单搭建了nfs服务



#相关命令

exportfs -rv  重新共享所有目录并输出详细信息



本文转自 yanconggod 51CTO博客,原文链接:http://blog.51cto.com/yanconggod/1889740

上一篇:搜索引擎系统的原理和实践


下一篇:关于bboss-persistent持久层框架通过jndi引用外部数据源(datasource)