构造NFS
一、設備nfs-utils
伺服器:
[root@server05?ftp]#?yum?install?nfs-utils
這時會自己主動安裝rpcbind需將此服務重新啟動nfs服務才干啟動
client安裝nfs-utils
二、配置
創(chuàng)建一些文件
[root@server05?/]#?mkdir?common
[root@server05?/]#?cd?common/
[root@server05?common]#?cp?/etc/passwd?./
[root@server05?common]#?vim?abc
[root@server05?common]#?ls
abc??passwd
?
編輯配置文件
[root@server05?~]#?vim?/etc/exports?
?
/common??172.168.4.203(rw)
?
將?/common?共享給172.168.4.203?并賦予rw?權(quán)限
重新啟動服務
[root@server05?Desktop]#?service?nfs?restart
關(guān)閉防火墻:
[root@server05?Desktop]#?iptables?-F
[root@server05?Desktop]#?setenforce?0
在?172.168.4.203?上:
[root@station3?~]#?showmount?-e?172.168.4.103
Export?list?for?172.168.4.103:
/common?172.168.4.203
能夠看到?172.168.4.103?共享的文件夾/common?
?
隨便一臺同網(wǎng)段的機器?:
[root@station3?~]#?showmount?-e?172.168.4.103
Export?list?for?172.168.4.103:
/common?172.168.4.203
都能夠看到?所以說NFS是不安全的
?
在172.168.4.203上掛載common文件夾
[root@station3?/]#?cd?mnt/
[root@station3?mnt]#?ls
hgfs
[root@station3?mnt]#?mkdir?commonmmnt
[root@station3?mnt]#?mount?172.168.4.103:/common?/mnt/commonmmnt/
[root@station3?mnt]#?
?
成功掛載
?
[root@station3?mnt]#?cd?commonmmnt/
[root@station3?commonmmnt]#?ls
abc??passwd
?
能夠看到掛載的內(nèi)容
?
到172.168.4.103上?
[root@server05?Desktop]#?vim?/etc/exports
改為:
/common??172.168.4.0/24(rw,sync)
?
#同一網(wǎng)段的主機都能夠掛載?sync代表同步
?
保存退出
[root@server05?/]#?chmod?o+w?common/
重新啟動服務
到172.168.4.203上,卸載并又一次掛載
[root@station3?commonmmnt]#?cd?..
[root@station3?mnt]#?umount?/mnt/commonmmnt/
[root@station3?mnt]#?mount?172.168.4.103:/common?/mnt/commonmmnt/
?
[root@station3?commonmmnt]#?mkdir?nfsdis
[root@station3?commonmmnt]#?ls
abc??nfsdis??passwd
?
到172.168.4.103上
[root@server05?/]#?cd?/common/
[root@server05?common]#?ls
abc??nfsdis??passwd
?
能夠看到剛才創(chuàng)建的目錄?實現(xiàn)了同步
######################################################################
二、自己主動掛載
在172.168.4.203?上
[root@server05?common]#?yum?install?autofs
配置:
[root@server05?common]#?vim?/etc/auto.master?
在第9行加入
/mnt??/etc/auto.nfs
創(chuàng)建/etc/auto.nfs內(nèi)容為:
abc -fstype=nfs 192.168.4.103:/common/share
以上兩個文件配置的意思是:當訪問/mnt時。運行/etc/auto.nfs。將192.168.4.103:/common/share?掛載到本機的abc下,abc的位置是/mnt/abc
?
重新啟動服務
[root@server203?/]#?service?autofs?restart
Stopping?automount:????????????????????????????????????????[??OK??]
Starting?automount:????????????????????????????????????????[??OK??]
[root@server203?/]#?cd?/mnt/abc
[root@server203?abc]#?ll
total?4
-rw-r--r--.?1?root?root?1913?Oct?11?05:33?passwd
便可看到服務端放在/common/share?下的passwd文件
?
高級玩法:
將/etc/auto.nfs內(nèi)容改為:
* -fstype=nfs 192.168.4.103:/common/&
意思是在/mnt下cd到?x?,右邊的&?就等于x?就將192.168.4.103:/common/x?掛載到本地的/mnt/x?下,前提是服務端有x所代表的文件
?
?
版權(quán)聲明:本文博主原創(chuàng)文章,博客,未經(jīng)同意不得轉(zhuǎn)載。
本文轉(zhuǎn)自mfrbuaa博客園博客,原文鏈接:http://www.cnblogs.com/mfrbuaa/p/4864926.html,如需轉(zhuǎn)載請自行聯(lián)系原作者
總結(jié)
- 上一篇: 支付测试用例
- 下一篇: canvas三环加载进度条