Nfs 網絡文件系統

Nfs 網絡文件系統

作用 文件夾的共享 通過rpc(遠程進程調用)實現

#rpcinfo –查看進程調用的情況

1.服務器要有共享清單

#vim /etc/exports

--每行是一個共享的文件夾

共享目錄的絕對路徑 來源(權限和參數)

--來源可以是單個地址,地址範圍,fqdn或者*.abc.com

--權限 ro rw

--sync 同步,async異步

/abc *(ro,sync,no_root_squash)

--Abc可以是所有人ro權限的形式訪問,取消nfsnobody映射的關係

--默認登陸的用戶都是nobody身份登陸

2.#exportfs –rv

--執行共享清單

#service nfs start

 

Client

1.一般掛載

#mount 192.168.2.10:/abc /mnt/abc

#cd /mnt/abc

2.永久掛載

#vim /etc/fstab

192.168.2.10:/abc /mnt/abc          nfs        defaults,soft(允許報錯,hard不允許報錯),intr(允許中斷,nointr掛載不了不允許中斷)   0 0

#mount –a

3.自動掛載

#/vim /etc/auto.master

/mnt/abc  /etc/auto.misc –timeout=60

-----/etc/fstab 不需要寫入條件

#cp /etc/auto.misc /etc/auto.abc

#vim /etc/auto.abc

Server1    -rw,soft,intr        192.168.2.10:/abc

#servcie autofs restart

#cd /mnt/abc

#cd server1

---linux文件夾的共享方式,在linux-linuxlinux-unix系統間的共享

For example:

Nfs server:

[root@www ~]# rpcinfo

Usage: rpcinfo [ -n portnum ] -u host prognum [ versnum ]

       rpcinfo [ -n portnum ] -t host prognum [ versnum ]

       rpcinfo -p [ host ]

       rpcinfo -b prognum versnum

       rpcinfo -d prognum versnum

[root@www ~]#

[root@www ~]# rpcinfo -p 192.168.2.10

   program vers proto   port

    100000    2   tcp    111  portmapper

    100000    2   udp    111  portmapper

    100024    1   udp    665  status

100024    1   tcp    668  status

[root@www ~]# vim /etc/exports

/mnt/lwy 192.168.2.20(ro,sync)   

[root@www ~]# chown 777 /mnt/lwy/                                                

[root@www ~]# exportfs -rv

exporting 192.168.2.20:/root/lwy

[root@www ~]# service nfs start

Starting NFS services:                                     [  OK  ]

Starting NFS quotas:                                       [  OK  ]

Starting NFS daemon:                                       [  OK  ]

Starting NFS mountd:                                       [  OK  ]

[root@www ~]# vim lwy/hello.txt

hello myword

                                              

client

1.一般掛載

[root@target ~]# mount 192.168.2.10:/mnt/lwy /mnt

[root@target ~]# cd /mnt/

[root@target mnt]# ll

total 4

-rw-r--r-- 1 root root 13 Oct 21 17:53 hello.txt

[root@target mnt]# cat hello.txt

hello myword

2.永久掛載

[root@target ~]# umount /mnt

[root@target ~]# vim /etc/fstab

192.168.2.10:/mnt/lwy   /mnt                    nfs      defaults,soft,intr 0 0                             

[root@target ~]# mount –a

[root@target ~]# cat /mnt/hello.txt

hello myword

3.自動掛載

[root@target etc]# vim auto.master

/misc   /etc/auto.misc

/mnt    /etc/auto.misc --timeout=60

/net    -hosts

[root@target etc]# cp -p auto.misc auto.lwy

[root@target etc]# vim auto.lwy

test           -rw,soft,intr          192.168.2.10:/mnt/lwy                        

[root@target etc]# service autofs restart

Stopping automount:                                        [  OK  ]

Starting automount:                                        [  OK  ]

[root@target etc]# cd /mnt/test  --可以看到掛載的內容 ,退出掛載目錄60秒會自動卸載。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章