當前位置:首頁 » 操作系統 » linux的nfs配置

linux的nfs配置

發布時間: 2022-09-05 08:21:07

1. 在linux下怎樣配置NFS(網路文件系統的配置和實現文件共享)

方法/步驟
首先確認自己的伺服器上面是否有portmap和nfs包,一般情況下都會有.
查詢命令:
rpm
-qa
|
grep
portmap
rpm
-qa
|
grep
nfs
如果有就接著向下走
啟動portmap和nfs,但是portmap的先於nfs啟動,因為portmap為nfs動態分配埠
查看是有啟動正常用如下命令
prcinfo
-p
如果看到portmap和nfs表示啟動正常
設置你要共享的文件和目錄
編輯vi
/etc/exports
格式如下:
共享目錄
允許訪問的主機ip(許可權)
輸出共享目錄和文件
1.要不重啟nfs服務
2.使用exportfs
-rv命令
接著到另一台伺服器上面去掛載nfs伺服器輸出的文件和目錄
1.新建你要掛載的目錄
2.查看nfs伺服器的輸出目錄
showmount
-e
nfs的ip
掛載目錄或文件
格式如下:
mount
nfs伺服器地址:/usr/local/web
/mnt/websites
查看掛載結果
df
-h
測試共享時候成功,在web1上面下面的掛載目錄下面新建一個文件然後隨便寫點東西看web2上面時候同步
卸載目錄的命令:
umount
/mnt/websites

2. 如何在linux操作系統中配置NFS伺服器

1.
服務端安裝:
1.setup
2.System
Services
3.分別選中portmap與nfs
4.service
portmap
restart
5.service
nfs
restart
許可權文件配置示例:
1.vi
/etc/exports
2.寫入/usr/www/
192.168.153.133(rw,no_root_squash,sync)
/usr/local/www指本地路徑
192.168.153.133遠程IP
(rw,no_root_squash,sync)讀寫並許可權過渡
3.service
nfs
restart

3. linux nfs 配置問題,急!!!!

「沒有到主機的路由」,看明白沒?路由啊、路由,所謂路由,就是由A機到B機的網路途徑,你ping能通不?看配置是沒錯,不過你要保證兩台機器能通訊呀,貌似客戶機找不到伺服器哦
補充回答:
能ping到對方么?基本的ifconfig你應該會用吧,涉及到的配置文件有/etc/sysconfig/network/config/*
/etc/hosts
/etc/resolv.conf
/etc/networks
/etc/nsswitch.conf
對等網路的客戶機用伺服器的IP做網關,如果你經過了一台路由器,在路由器上設置靜態路由
補充回答:
你們是通過了一台路由器?去路由器設置靜態路由,實在不行,直接用交叉線對等連接兩台機器測試NFS是否工作。如果能工作,問題還是出在路由器上
OK,你把共享的文件路徑上所有的文件夾other位上都加上讀和運行位試試。命令是
chmod -R 755 /nfsroot/pmp-root

4. 在linux下配置NFS伺服器,設置可以被掛載的目錄為:/nfsboot

NFS(網路文件系統)服務可以將遠程Linux系統上的文件共享資源掛載到本地主機的目錄上,從而使得本地主機(Linux客戶端)基於TCP/IP協議,像使用本地主機上的資源那樣讀寫遠程Linux系統上的共享文件。配置NFS服務

5. 如何配置linux內核具有nfs的功能

1、使用的技術

NFS

2、測試環境

NFS伺服器:192.168.255.18

NFS客戶端:192.168.255.11

操作系統:REDHAT4

3、NFS伺服器配置

(1)配置 /etc/hosts.deny

禁止任何客戶端能和你的NFS伺服器進行NFS連接:

### NFS DAEMONS
portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL

(2)配置/etc/hosts.allow

允許那些你想要的客戶端和你的NFS伺服器建立連接。下列步驟將允許任何IP地址
以192.168.2開頭的主機(連接到NFS伺服器上),也可以指定特定的IP地址。

### NFS DAEMONS
portmap: 192.168.255.
lockd: 192.168.255.
rquotad: 192.168.255.
mountd: 192.168.255.
statd: 192.168.255.

(3)重啟portmap

運行 $ /etc/init.d/portmap restart 重啟portmap daemon。

(4)配置/etc/exports

NFS掛載目錄及許可權由/etc/exports文件定義。比如要將我的/tmp目錄讓
192.168.255.*的IP共享, 則在該文件末尾添加下列語句:

/tmp 192.168.255.*(rw,sync,no_root_squash)

192.168.255.* 網段內的NFS客戶端能夠共享NFS伺服器/tmp目錄內容,且有讀,寫
許可權,並且該用戶進入/home/zp/share目錄後的身份為root,最好加上sync,否則
$ sudo exportfs -r 時會給出警告, sync是NFS的默認選項。

(5)重啟NFS服務

運行 $ /etc/init.d/nfs-kernel-server restart 重啟nfs服務)

(6)NFS伺服器查看共享是否成功

$ Showmount –e 192.168.255.18

/tmp 192.168.255.*

(6)NFS客戶端啟動NFS服務

service nfs start

(7)NFS客戶端查看伺服器共享目錄

Showmount –e 192.168.255.18

(8)掛載NFS伺服器共享目錄

mount –t nfs -o tcp192.168.255.18:/tmp /tmp

4、錯誤排查

當/etc/exports設置的許可權,不符合client端的來源時,則會出現以下錯誤信息:

mount: hostname:/dir failed, reason given by server: Permission denied

6. LINUX怎樣安裝和使用NFS服務

舉例,有台機器叫AAA,想把自己機器根下的一個叫abc的目錄極其裡面的所有文件都共享給一台叫BBB的機器。

在這里AAA就可看成是伺服器,BBB為客戶端,方法如下:

(在AAA上先配置)

1.

vi /etc/exports
(用vi編輯器打開共享資源,在裡面填寫共享的屬性,linux下nfs的共享資源路徑為etc下的exports)

打開編輯器後,裡面可能什麼都沒有,需要自己填寫,然後保存即可,在這里填寫

2.

/abc BBB(ro)

之後按Esc停止文字錄入,然後按Shift+;鍵,在出來的冒號後輸入wq,表示保存退出!
(這個的格式是這樣的:先給出要共享的路徑,然後空格,後面寫共享給誰,可以是IP地址或主機名。再後面的括弧里表示以什麼方式來共享,ro是客戶端只能讀,如果想讓客戶端可以改,可設為rw,即可讀寫)

7. 如何使用NFS配置linux文件共享

1、使用的技術

NFS

2、測試環境

NFS伺服器:192.168.255.18

NFS客戶端:192.168.255.11

操作系統:REDHAT4

3、NFS伺服器配置

(1)配置 /etc/hosts.deny

禁止任何客戶端能和你的NFS伺服器進行NFS連接:

### NFS DAEMONS
portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL

(2)配置/etc/hosts.allow

允許那些你想要的客戶端和你的NFS伺服器建立連接。下列步驟將允許任何IP地址
以192.168.2開頭的主機(連接到NFS伺服器上),也可以指定特定的IP地址。

### NFS DAEMONS
portmap: 192.168.255.
lockd: 192.168.255.
rquotad: 192.168.255.
mountd: 192.168.255.
statd: 192.168.255.

(3)重啟portmap

運行 $ /etc/init.d/portmap restart 重啟portmap daemon。

(4)配置/etc/exports

NFS掛載目錄及許可權由/etc/exports文件定義。比如要將我的/tmp目錄讓
192.168.255.*的IP共享, 則在該文件末尾添加下列語句:

/tmp 192.168.255.*(rw,sync,no_root_squash)

192.168.255.* 網段內的NFS客戶端能夠共享NFS伺服器/tmp目錄內容,且有讀,寫
許可權,並且該用戶進入/home/zp/share目錄後的身份為root,最好加上sync,否則
$ sudo exportfs -r 時會給出警告, sync是NFS的默認選項。

(5)重啟NFS服務

運行 $ /etc/init.d/nfs-kernel-server restart 重啟nfs服務)

(6)NFS伺服器查看共享是否成功

$ Showmount –e 192.168.255.18

/tmp 192.168.255.*

(6)NFS客戶端啟動NFS服務

service nfs start

(7)NFS客戶端查看伺服器共享目錄

Showmount –e 192.168.255.18

(8)掛載NFS伺服器共享目錄

mount –t nfs -o tcp192.168.255.18:/tmp /tmp

4、錯誤排查

當/etc/exports設置的許可權,不符合client端的來源時,則會出現以下錯誤信息:

mount: hostname:/dir failed, reason given by server: Permission denied

5、NFS的一些參數

下面是一些NFS共享的常用參數(/etc/exports配置):

ro

只讀訪問

rw

讀寫訪問

sync

所有數據在請求時寫入共享

async

NFS在寫入數據前可以相應請求

secure

NFS通過1024以下的安全TCP/IP埠發送

insecure

NFS通過1024以上的埠發送

wdelay

如果多個用戶要寫入NFS目錄,則歸組寫入(默認)

no_wdelay

如果多個用戶要寫入NFS目錄,則立即寫入,當使用async時,無需此設置。

hide

在NFS共享目錄中不共享其子目錄

no_hide

共享NFS目錄的子目錄

subtree_check

如果共享/usr/bin之類的子目錄時,強制NFS檢查父目錄的許可權(默認)

no_subtree_check

和上面相對,不檢查父目錄許可權

all_squash

共享文件的UID和GID映射匿名用戶anonymous,適合公用目錄。

no_all_squash

保留共享文件的UID和GID(默認)

root_squash

root用戶的所有請求映射成如anonymous用戶一樣的許可權(默認)

no_root_squash

root用戶具有根目錄的完全管理訪問許可權

anonuid=xxx

指定NFS伺服器/etc/passwd文件中匿名用戶的UID

anongid=xxx

指定NFS伺服器/etc/passwd文件中匿名用戶的GID

注意:如果按照上面步驟不能成功,請查看兩台機器的防火牆設置。在條件允許的
情況下,建議將防火牆關閉!

8. vmware安裝linux時nfs如何配置

1、使用的技術
nfs
2、測試環境
nfs伺服器:192.168.255.18
nfs客戶端:192.168.255.11
操作系統:redhat4
3、nfs伺服器配置
(1)配置
/etc/hosts.deny
禁止任何客戶端能和你的nfs伺服器進行nfs連接:
###
nfs
daemons
portmap:all
lockd:all
mountd:all
rquotad:all
statd:all
(2)配置/etc/hosts.allow
允許那些你想要的客戶端和你的nfs伺服器建立連接。下列步驟將允許任何ip地址
以192.168.2開頭的主機(連接到nfs伺服器上),也可以指定特定的ip地址。
###
nfs
daemons
portmap:
192.168.255.
lockd:
192.168.255.
rquotad:
192.168.255.
mountd:
192.168.255.
statd:
192.168.255.
(3)重啟portmap

9. NFS筆記(二)NFS伺服器配置實例

一、NFS伺服器配置實例

實驗拓撲

二、實驗要求及環境

2.1實驗環境

NFS伺服器 IP:192.168.8.5

環境:

[root@server7 ~]# uname -a

Linux server7.ctos.zu 3.10.0-514.el7.centos.plus.i686 #1 SMP Wed Jan 25 12:55:04 UTC 2017 i686 i686 i386 GNU/Linux

[root@server7 ~]# cat /etc/redhat-release

CentOS release 7.3.1611 (AltArch)

客戶端IP:192.168.8.7

環境:

[root@client-A ~]# uname -a

Linux client-A.ctos.zu 2.6.32-696.el6.i686 #1 SMP Tue Mar 21 18:53:30 UTC 2017 i686 i686 i386 GNU/Linux

[root@client-A ~]# cat /etc/redhat-release

CentOS release 6.9 (Final)

2.2、實驗要求

NFS伺服器

1、/home/share 目錄可讀寫,並且不限制用戶身份,共享給192.168.8.0/24網段不的所有主機;

2、/home/data 這個目錄僅共享給192.168.8.7這台主機,以供該主機上面的這個用戶來使用,

也就是說在192.168.8.5和192.168.8.7上均有賬號,且賬號均為;

3、/home/upload 這個目錄做為192.168.8.0/24網段的數據上傳目錄,其中/home/upload

的用戶和所屬組為nfs-upload這個名字,它的UID和GID均為222;

4、/home/nfs  這個目錄的屬性為只讀,可提供除了網段內的工作站外,向Internet也提供數據內容。

三、伺服器端設置

1、 編輯/etc/exports內容

[root@server7 etc]# cat /etc/exports

/home/share  192.168.8.0/24(rw,no_root_squash)

/home/data  192.168.8.7(rw)

/home/upload   192.168.8.0/24(rw,all_squash,anonuid=222,anongid=222)

/home/nfs     192.168.8.0/24(ro)  *(ro,all_squash)

2、按要求建立每個對應目錄

    2.1、創建/home/share目錄 任何人都可以在 /home/share內新增、修改文件,但

    僅有該文件/目錄的建立者與root能夠刪除自己的目錄或文件。

    [root@server7 etc]# mkdir -p  /home/share

    [root@server7 etc]# ll -d /home/share/

    drwxr-xr-x. 2 root root 6 9月   5 15:50 /home/share/

    [root@server7 etc]# chmod 1777  /home/share/

    [root@server7 etc]# ll -d /home/share/

    drwxrwxrwt. 2 root root 6 9月   5 15:50 /home/share/

    2.2、創建/home/nfs

    [root@server7 etc]# ll -d /home/nfs/

    drwxr-xr-x. 2 root root 6 9月   5 16:52 /home/nfs/

    2.3、創建/home/data目錄

    [root@server7 etc]# mkdir -v /home/data

    mkdir: 已創建目錄 "/home/data"

    [root@server7 etc]# ll -d /home/data/

    drwxr-xr-x. 2 root root 6 9月   5 16:57 /home/data/

    [root@server7 etc]# useradd

    root@server7 etc]# passwd

    更改用戶 的密碼 。

    新的 密碼:

    無效的密碼: 密碼少於 8 個字元

    重新輸入新的 密碼:

    passwd:所有的身份驗證令牌已經成功更新。

    [root@server7 etc]# cat /etc/passwd | grep

    :x:1000:1000::/home/:/bin/bash

    [root@server7 etc]# chmod 700 /home/data/

    [root@server7 etc]# chown -R : /home/data/

    [root@server7 etc]# ll -d /home/data/

    drwx------. 2 6 9月   5 16:57 /home/data/

    2.4、創建/home/upload目錄

#先建立對應賬號與組名及UID

[root@server7 etc]# groupadd  -g 222 nfs-upload

[root@server7 etc]# useradd -g 222 -u 222 -M nfs-upload

[root@server7 etc]# cat /etc/passwd|grep nfs

rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin

nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin

nfs-upload:x:222:222::/home/nfs-upload:/bin/bash

#創建目錄,修改屬主

[root@server7 etc]# mkdir /home/upload

[root@server7 etc]# chown -R nfs-upload:nfs-upload  /home/upload/

[root@server7 etc]# ll -d /home/upload/

drwxr-xr-x. 2 nfs-upload nfs-upload 6 9月   6 08:38 /home/upload/

2.5、重啟NFS服務

[root@server7 etc]# systemctl restart  nfs

[root@server7 etc]# systemctl status  nfs

● nfs-server.service - NFS server and services

   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)

   Active: active (exited) since 三 2017-09-06 08:41:40 CST; 8s ago

  Process: 9171 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)

  Process: 9169 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)

  Process: 9168 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)

  Process: 9181 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)

  Process: 9180 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)

 Main PID: 9181 (code=exited, status=0/SUCCESS)

   CGroup: /system.slice/nfs-server.service

9月 06 08:41:40 server7.ctos.zu systemd[1]: Starting NFS server and services...

9月 06 08:41:40 server7.ctos.zu systemd[1]: Started NFS server and services.

[root@server7 etc]# tail /var/log/messages

Sep  6 08:41:40 server7 systemd: Started NFS Mount Daemon.

Sep  6 08:41:40 server7 rpc.mountd[9178]: Version 1.3.0 starting

Sep  6 08:41:40 server7 systemd: Started NFSv4 ID-name mapping service.

Sep  6 08:41:40 server7 systemd: Starting NFS server and services...

Sep  6 08:41:40 server7 kernel: NFSD: starting 90-second grace period (net c0c932c0)

Sep  6 08:41:40 server7 systemd: Started NFS server and services.

Sep  6 08:41:40 server7 systemd: Starting Notify NFS peers of a restart...

Sep  6 08:41:40 server7 sm-notify[9198]: Version 1.3.0 starting

Sep  6 08:41:40 server7 sm-notify[9198]: Already notifying clients; Exiting!

Sep  6 08:41:40 server7 systemd: Started Notify NFS peers of a restart.

2.6、查看NFS伺服器共享出來目錄

2.7、關閉防火牆、selinux

2.8查看配置

[root@server7 ~]# exportfs -v

/home/data     192.168.8.7(rw,wdelay,root_squash,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)

/home/share       192.168.8.0/24(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)

/home/upload      192.168.8.0/24(rw,wdelay,root_squash,all_squash,no_subtree_check,anonuid=222,anongid=222,sec=sys,rw,secure,root_squash,all_squash)

/home/nfs         192.168.8.0/24(ro,wdelay,root_squash,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)

/home/nfs         <world>(ro,wdelay,root_squash,all_squash,no_subtree_check,sec=sys,ro,secure,root_squash,all_squash)

四、客戶端配置

4.1、客戶端也要安裝nfs-utils和rcpbind軟體包

[root@client-A ~]# yum install nfs-utils rpcbind -y

4.2、啟動RPC

[root@client-A ~]# service rpcbind start  /systemctl start rpcbind

Starting rpcbind:                                          [  OK  ]

[root@client-A ~]# service rpcbind status

rpcbind (pid  1926) is running...

[root@client-A ~]# chkconfig --list |grep rpcbind

4.3、客戶端關閉防火牆、selinux

[root@client-A ~]# service iptables stop /systemctl stop firewalld

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading moles:                               [  OK  ]

4.4測試網路

[root@client-A ~]# ping 192.168.8.5

PING 192.168.8.5 (192.168.8.5) 56(84) bytes of data.

64 bytes from 192.168.8.5: icmp_seq=1 ttl=64 time=2.16 ms

64 bytes from 192.168.8.5: icmp_seq=2 ttl=64 time=0.697 ms

64 bytes from 192.168.8.5: icmp_seq=3 ttl=64 time=0.346 ms

64 bytes from 192.168.8.5: icmp_seq=4 ttl=64 time=0.336 ms

64 bytes from 192.168.8.5: icmp_seq=5 ttl=64 time=0.335 ms

64 bytes from 192.168.8.5: icmp_seq=6 ttl=64 time=0.317 ms

64 bytes from 192.168.8.5: icmp_seq=7 ttl=64 time=0.512 ms

64 bytes from 192.168.8.5: icmp_seq=8 ttl=64 time=0.320 ms

^C

--- 192.168.8.5 ping statistics ---

8 packets transmitted, 8 received, 0% packet loss, time 7555ms

rtt min/avg/max/mdev = 0.317/0.629/2.169/0.595 ms

4.5 在客戶端查看NFS伺服器共享出來目錄

[root@client-A ~]# showmount -e 192.168.8.5

Export list for 192.168.8.5:

/home/nfs     (everyone)

/home/upload  192.168.8.0/24

/home/share   192.168.8.0/24

/home/data 192.168.8.7

4.6、掛載NFS伺服器上/home/nfs目錄到本地/opt/data目錄下

#臨時掛載

#永久掛載

編輯、/etc/fstab文件,新增如下條目:

192.168.8.5:/home/nfs  /opt/data/ nfs4 defaults 0 0

更多信息參考 nfs參數詳解

#查看信息

[root@client-A data] # df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                      6.5G  644M  5.6G  11% /

tmpfs                 250M     0  250M   0% /dev/shm

/dev/sda1             477M   26M  426M   6% /boot

192.168.8.5:/home/nfs

                      8.0G  1.6G  6.5G  20% /opt/data

[root@client-A data]# mount

/dev/mapper/VolGroup-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

nfsd on /proc/fs/nfsd type nfsd (rw)

192.168.8.5:/home/nfs on /opt/data type nfs (rw,vers=4,addr=192.168.8.5,clientaddr=192.168.8.7)

#創建文件測試

[root@client-A data]# touch testabc

touch: cannot touch `testabc': Read-only file system

4.7掛載/home/upload 目錄到客戶端/opt/upload目錄下

#掛載

[root@client-A data]# mkdir /opt/upload

[root@client-A data]# mount -t nfs  192.168.8.5:/home/upload   /opt/upload/

#查看掛載是否成功

[root@client-A data]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                      6.5G  644M  5.6G  11% /

tmpfs                 250M     0  250M   0% /dev/shm

/dev/sda1             477M   26M  426M   6% /boot

192.168.8.5:/home/nfs

                      8.0G  1.6G  6.5G  20% /opt/data

192.168.8.5:/home/upload

                      8.0G  1.6G  6.5G  20% /opt/upload

#客戶端創建nfs-upload用戶

[root@client-A ~]# groupadd  -g 222 nfs-upload

[root@client-A ~]# useradd -g 222 -u 222 -m nfs-upload

#測試,可以看到創建的文件及目錄默認屬主為nfs-upload屬組為nfs-upload

[@client-A upload]$ pwd

/opt/upload

[@client-A upload]$ ll

total 0

#測試創建文件

[@client-A upload]$ touch test123

測試創建目錄

[@client-A upload]$ mkdir  testdir

[@client-A upload]$ ll -a

total 4

drwxr-xr-x  3 nfs-upload nfs-upload   36 Sep  6 10:28 .

drwxr-xr-x. 4 root       root       4096 Sep  6 18:22 ..

-rw-rw-r--  1 nfs-upload nfs-upload    0 Sep  6 10:28 test123

drwxrwxr-x  2 nfs-upload nfs-upload    6 Sep  6 10:28 testdir

# 在客戶端用root用戶創建文件測試

root@client-A upload]# touch testabc

[root@client-A upload]# ll

total 0

-rw-r--r-- 1 root       root       0 Sep  6 10:31 nfstest123

-rw-r--r-- 1 nfs-upload nfs-upload 0 Sep  6 10:32 testabc

drwxrwxr-x 2 nfs-upload nfs-upload 6 Sep  6 10:28 testdir

可以看到用root用戶創建的文件屬主仍是nfs-upload

#測試刪除文件

[@client-A upload]$ rm test123

[@client-A upload]$ ll

total 0

drwxrwxr-x 2 nfs-upload nfs-upload 6 Sep  6 10:28 testdir

10. Linux搭建NFS伺服器

作者:SpookZanG
linux搭建NFS伺服器
一、什麼是NFS服務
NFS是Network
File
System的簡寫,即網路文件系統.
網路文件系統是FreeBSD支持的文件系統中的一種,也被稱為NFS.
NFS允許一個系統在網路上與它人共享目錄和文件。通過使用NFS,用戶和程序可以象訪問本地文件一樣訪問遠端系統上的文件。
二、NFS的優勢
1.本地工作站使用更少的磁碟空間,因為通常的數據可以存放在一台機器上而且可以通過網路訪問到。
2.用戶不必在每個網路上機器里頭都有一個home目錄。Home目錄
可以被放在NFS伺服器上並且在網路上處處可用。
3.諸如軟碟機,CDROM,和
Zip®
之類的存儲設備可以在網路上面被別的機器使用。這可以減少整個網路上的可移動介質設備的數量。
NFS至少有兩個主要部分:一台伺服器和一台(或者更多)客戶機。客戶機遠程訪問存放在伺服器上的數據。為了正常工作,一些進程需要被配置並運行。
三、NFS的搭建
1、伺服器端
安裝NFS的服務程序
yum
install
-y
nfs-utils
寫配置文件
寫入
/music
192.168.0.0/255.255.255.0(rw,sync)
格式是:
要共享的目錄
共享的IP及掩碼或者域名(許可權,同步更新)
啟動服務
/etc/init.d/portmap
restart
/etc/init.d/nfs
restart
chkconfig
nfs
on
chkconfig
portmap
on
然後關閉防火牆以及更改Selinux關於NIS的選項
/etc/init.d/iptables
stop
(防護牆服務關閉)
chkconfig
iptables
off
system-config-selinux
(設置selinux)
2、客戶端
編輯fstab文件,實現開機自動掛載
mount
-t
nfs
IP:/目錄
掛載到的目錄
(此為臨時掛載)
如:mount
-t
nfs
192.168.0.9:/doce
/doc
編輯FSTAB文件
vim
/etc/init.d/fstab
IP:/目錄
掛載到的目錄
nfs
defaults
0
0
然後關閉防火牆以及更改Selinux關於NIS的選項
/etc/init.d/iptables
stop
(防護牆服務關閉)
chkconfig
iptables
off
system-config-selinux
(設置selinux)
至此,搭建完畢。

熱點內容
隨機啟動腳本 發布:2025-07-05 16:10:30 瀏覽:532
微博資料庫設計 發布:2025-07-05 15:30:55 瀏覽:30
linux485 發布:2025-07-05 14:38:28 瀏覽:310
php用的軟體 發布:2025-07-05 14:06:22 瀏覽:760
沒有許可權訪問計算機 發布:2025-07-05 13:29:11 瀏覽:436
javaweb開發教程視頻教程 發布:2025-07-05 13:24:41 瀏覽:718
康師傅控流腳本破解 發布:2025-07-05 13:17:27 瀏覽:246
java的開發流程 發布:2025-07-05 12:45:11 瀏覽:692
怎麼看內存卡配置 發布:2025-07-05 12:29:19 瀏覽:288
訪問學者英文個人簡歷 發布:2025-07-05 12:29:17 瀏覽:837