CentOS NFS服務(wù)器的創(chuàng)建
不少系統(tǒng)中,都有NFS的需要。那么在一些不產(chǎn)用以及開發(fā)系統(tǒng)中如何添加NFS平臺呢?這里我們就來講解一下CentOS的NFS服務(wù)器的創(chuàng)建。希望對大家有所幫助。CentOS下搭建NFS平臺的具體過程:
1、先在VM下裝一個CentOS作為NFS服務(wù)器(nfs-server.example.com),再克隆一個作為NFS客戶端(nfs-client.example.com),MINI安裝即可.
NFS服務(wù)器分配IP為192.168.1.100,NFS客戶端分配IP為192.168.1.200.
nfs-server.example.com配置如下:
[root@nfs-server ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=nfs-server.example.com[root@nfs-server ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.1.200 nfs-client.example.com nfs-client
nfs-client.example.com配置如下:
[root@nfs-client ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=nfs-client.example.com[root@nfs-client ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.1.100 nfs-server.example.com nfs-server2、配置NFS服務(wù)器(nfs-server.example.com)
默認(rèn)安裝下已經(jīng)裝好NFS服務(wù)了,所以只用開啟服務(wù)器即可.
[root@nfs-server ~]# chkconfig nfs on比如要共享/data/目錄:
[root@nfs-server ~]# mkdir /data
[root@nfs-server ~]# vi /etc/exports
/data/ 192.168.1.200(rw,no_root_squash,no_all_squash,sync)現(xiàn)在就可以啟動NFS服務(wù)了.
[root@nfs-server ~]# service nfs start3、配置NFS客戶端(nfs-client.example.com)
測試NFS服務(wù)器.
[root@nfs-client ~]# showmount -e nfs-server
Export list for share:
/data 192.168.1.200如果沒有出現(xiàn)以上信息,說明NFS服務(wù)器還沒配置正確,一般是IP設(shè)置錯誤.
MOUNT共享目錄/data:
[root@nfs-client ~]# mkdir /data
[root@nfs-client ~]# mount -t nfs 192.168.1.100:/data /data接下來就測試共享目錄/data是否可讀寫:
[root@nfs-client ~]# echo "hello world" > /data/test然后上NFS服務(wù)器看看是否有/data/test文件:)?
如果想NFS客戶端一開機(jī)就自動掛載共享目錄,只需修改/etc/fstab,加 入以下一句就可以了:
192.168.1.100:/data /data nfs rw 0 04、排錯參考
當(dāng)/etc/exports設(shè)置的權(quán)限,不符合client端的來源時,則會出現(xiàn)以下錯誤信息:
mount: hostname:/dir failed, reason given by server: Permission denied
然而必須注意的是,若在nfs server的/etc/hosts內(nèi)有設(shè)置IP與hostname的對照
則nfs會先把來源IP轉(zhuǎn)換成hostname,再與/etc/exports內(nèi)的設(shè)置做對比
若此時/etc/exports的設(shè)置使用IP而非hostname,則會產(chǎn)生? 法匹配的錯誤
? 此而出現(xiàn),雖然來源IP在/etc/exports已正確設(shè)置,卻仍然發(fā)生Permission denied的現(xiàn)象
解決方案是在/etc/exports內(nèi)采用hostname,避免使用IP,或者是設(shè)置正確的IP段.
來源:http://www.sofee.cn/blog/2006/09/29/46/