linux nfs實踐

msdnchina發表於2011-10-24

linux nfs實踐
以下是nfs伺服器(需要共享出目錄來的那個機器)上的操作
修改/etc/exports,要將/home/work目錄共享出來
[root@rhel4u6 work]# cat /etc/exports
/home/work 192.168.179.* (rw,sync,no_root_squash)

[root@rhel4u6 home]# /etc/rc.d/init.d/portmap start
Starting portmap: [ OK ]
[root@rhel4u6 home]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]

[root@rhel4u6 work]# exportfs
exportfs: No host name given with /home/work

(rw,sync,wdelay,hide,nocrossmnt,secure,no_root_squash,no_all_squash,subtree_check,secure_locks,map

ping=identity,anonuid=-2,anongid=-2), suggest *

(rw,sync,wdelay,hide,nocrossmnt,secure,no_root_squash,no_all_squash,subtree_check,secure_locks,map

ping=identity,anonuid=-2,anongid=-2) to avoid warning
/home/work 192.168.179.*
/home/work


[root@rhel4u6 work]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 28G 15G 12G 56% /
none 232M 0 232M 0% /dev/shm


[root@rhel4u6 work]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:BC:EF:F1
inet addr:192.168.179.40 Bcast:192.168.179.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:febc:eff1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:839 errors:0 dropped:0 overruns:0 frame:0
TX packets:614 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:78907 (77.0 KiB) TX bytes:71583 (69.9 KiB)
Base address:0x2000 Memory:d8920000-d8940000

到一個linux客戶端去mount:

[root@localhost ~]# mount -t nfs 192.168.179.40:/home/work /mnt/haha

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 13G 9.8G 2.2G 83% /
tmpfs 270M 154M 116M 58% /dev/shm
192.168.179.40:/home/work
28G 15G 12G 56% /mnt/haha

透過修改/etc/fstab檔案可以實現開機自動掛載nfs目錄

192.168.179.40:/home/work /mnt/haha nfs defaults 0 0

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/161195/viewspace-1055923/,如需轉載,請註明出處,否則將追究法律責任。

相關文章