天天看點

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通路,這次進行了更正,上次出現了少少的配置錯誤。

<code>/u02/liyangjie</code> <code>10.0.0.161(rw,</code><code>sync</code><code>,no_root_squash,no_subtree_check) 10.0.0.196(rw,</code><code>sync</code><code>,no_root_squash,no_subtree_check) 10.0.0.168(rw,</code><code>sync</code><code>,no_root_squash,no_subtree_check)</code>

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.

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

繼續閱讀