亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Ubuntu配置NFS的具體流程(推薦)

 更新時間:2017年02月09日 09:19:43   投稿:jingxian  
下面小編就為大家?guī)硪黄猆buntu配置NFS的具體流程(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

NFS 是Network File System的縮寫,即網(wǎng)絡(luò)文件系統(tǒng),一種使用于分散式文件系統(tǒng)的協(xié)定

NFS通過網(wǎng)絡(luò)讓不同的機(jī)器、不同的操作系統(tǒng)能夠彼此分享個別的數(shù)據(jù),例如將/home設(shè)置為共享目錄,然后共享給網(wǎng)絡(luò)中的其它服務(wù)器,這樣每臺機(jī)器就不必單獨建立自己的/home路徑了,NFS獨立于操作系統(tǒng),容許不同硬件及操作系統(tǒng)的系統(tǒng)共同進(jìn)行文件的分享,是在類Unix系統(tǒng)間實現(xiàn)磁盤文件共享的一種方法

NFS本身沒有提供信息傳輸?shù)膮f(xié)議和功能,而是使用RPC服務(wù)完成這部分功能??梢哉fNFS本身就是使用RPC服務(wù)的一個程序,或者說NFS也是一個RPC SERVER。所以只要用到NFS的地方都要啟動RPC服務(wù),不論是NFS server還是NFS client,可以這么理解RPC和NFS之間的關(guān)系:NFS是一個文件系統(tǒng),而RPC負(fù)責(zé)信息的傳輸

一,系統(tǒng)環(huán)境

Linux Distribution:Ubuntu 14

二,安裝Linux NFS

sean@sean:~$ sudo apt-get install nfs-kernel-server
[sudo] password for sean: 
Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following extra packages will be installed:
 keyutils libgssglue1 libnfsidmap2 libtirpc1 nfs-common rpcbind
Suggested packages:
 open-iscsi watchdog
The following NEW packages will be installed:
 keyutils libgssglue1 libnfsidmap2 libtirpc1 nfs-common nfs-kernel-server
 rpcbind
0 upgraded, 7 newly installed, 0 to remove and 159 not upgraded.
Need to get 460 kB of archives.
After this operation, 2,049 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libgssglue1 amd64 0.4-2ubuntu1 [19.7 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libnfsidmap2 amd64 0.25-5 [32.2 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libtirpc1 amd64 0.2.2-5ubuntu2 [71.3 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu/ trusty/main keyutils amd64 1.5.6-1 [33.6 kB]
Get:5 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main rpcbind amd64 0.2.1-2ubuntu2.2 [37.1 kB]
Get:6 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main nfs-common amd64 1:1.2.8-6ubuntu1.2 [181 kB]
Get:7 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main nfs-kernel-server amd64 1:1.2.8-6ubuntu1.2 [85.8 kB]
Fetched 460 kB in 16s (27.2 kB/s)                       
Selecting previously unselected package libgssglue1:amd64.
(Reading database ... 168701 files and directories currently installed.)
Preparing to unpack .../libgssglue1_0.4-2ubuntu1_amd64.deb ...
Unpacking libgssglue1:amd64 (0.4-2ubuntu1) ...
Selecting previously unselected package libnfsidmap2:amd64.
Preparing to unpack .../libnfsidmap2_0.25-5_amd64.deb ...
Unpacking libnfsidmap2:amd64 (0.25-5) ...
Selecting previously unselected package libtirpc1:amd64.
Preparing to unpack .../libtirpc1_0.2.2-5ubuntu2_amd64.deb ...
Unpacking libtirpc1:amd64 (0.2.2-5ubuntu2) ...
Selecting previously unselected package keyutils.
Preparing to unpack .../keyutils_1.5.6-1_amd64.deb ...
Unpacking keyutils (1.5.6-1) ...
Selecting previously unselected package rpcbind.
Preparing to unpack .../rpcbind_0.2.1-2ubuntu2.2_amd64.deb ...
Unpacking rpcbind (0.2.1-2ubuntu2.2) ...
Selecting previously unselected package nfs-common.
Preparing to unpack .../nfs-common_1%3a1.2.8-6ubuntu1.2_amd64.deb ...
Unpacking nfs-common (1:1.2.8-6ubuntu1.2) ...
Selecting previously unselected package nfs-kernel-server.
Preparing to unpack .../nfs-kernel-server_1%3a1.2.8-6ubuntu1.2_amd64.deb ...
Unpacking nfs-kernel-server (1:1.2.8-6ubuntu1.2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Setting up libgssglue1:amd64 (0.4-2ubuntu1) ...
Setting up libnfsidmap2:amd64 (0.25-5) ...
Setting up libtirpc1:amd64 (0.2.2-5ubuntu2) ...
Setting up keyutils (1.5.6-1) ...
Setting up rpcbind (0.2.1-2ubuntu2.2) ...
 Removing any system startup links for /etc/init.d/rpcbind ...
rpcbind start/running, process 12074
Processing triggers for ureadahead (0.100.0-16) ...
Setting up nfs-common (1:1.2.8-6ubuntu1.2) ...

Creating config file /etc/idmapd.conf with new version

Creating config file /etc/default/nfs-common with new version
Adding system user `statd' (UID 118) ...
Adding new user `statd' (UID 118) with group `nogroup' ...
Not creating home directory `/var/lib/nfs'.
statd start/running, process 12307
gssd stop/pre-start, process 12341
idmapd start/running, process 12399
Processing triggers for ureadahead (0.100.0-16) ...
Setting up nfs-kernel-server (1:1.2.8-6ubuntu1.2) ...

Creating config file /etc/exports with new version

Creating config file /etc/default/nfs-kernel-server with new version
 * Not starting NFS kernel daemon: no exports.
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Processing triggers for ureadahead (0.100.0-16) ...

通過安裝日志可以發(fā)現(xiàn)總共會安裝keyutils,libgssglue1,libnfsidmap2,libtirpc1,nfs-common,nfs-kernel-server,rpcbind這7個包

很多文檔中安裝的包為portmap,但是這個包已經(jīng)被rpcbind替代

sean@sean:~$ sudo apt-get install portmap
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'rpcbind' instead of 'portmap'
rpcbind is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded.
rpcbind包安裝完成后會自動啟動rpcbind服務(wù)

sean@sean:~$ ps -ef|grep rpcbind
root 807 1 0 22:27 ? 00:00:00 rpcbind
sean 10215 9528 0 22:48 pts/6 00:00:00 grep --color=auto rpcbind
但是由于目前NFS的配置文件為空,NFS服務(wù)并沒有啟動

三,配置NFS服務(wù)

從安裝日志中我們可以發(fā)現(xiàn)NFS服務(wù)的配置文件為/etc/exports,并且這個文件在安裝過程中已經(jīng)生成好了,我們所要做的就是將NFS配置信息添加到這個文件中

sean@sean:~$ sudo vi /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
#        to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes    hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4    gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
/home/sean/shareDir 192.168.137.129(rw,no_root_squash,async)

其中中的最后一行為新添加的NFS配置,NFS配置信息格式如下:

<共享目錄> [客戶端1 選項(訪問權(quán)限,用戶映射,其他)] [客戶端2 選項(訪問權(quán)限,用戶映射,其他)]

1,共享目錄:

共享目錄是指NFS系統(tǒng)中需要共享給客戶機(jī)使用的目錄

2,客戶端:

客戶端是指網(wǎng)絡(luò)中可以訪問NFS共享目錄的計算機(jī)

客戶端常用的指定方式:

(1)指定ip地址的主機(jī):192.168.0.1
(2)指定子網(wǎng)中的所有主機(jī):192.168.0.0/255.255.255.0
(3)指定域名的主機(jī):www.sean.com
(4)指定域中的所有主機(jī):*.sean.com
(5)所有主機(jī):*

3,選項:

選項用來設(shè)置輸出目錄的訪問權(quán)限、用戶映射等,NFS主要有3類選項:

訪問權(quán)限選項:

(1)設(shè)置輸出目錄只讀:ro
(2)設(shè)置輸出目錄讀寫:rw

用戶映射選項:

(1)all_squash:將遠(yuǎn)程訪問的所有普通用戶及所屬組都映射為匿名用戶或用戶組(nfsnobody)
(2)no_all_squash:與all_squash取反(默認(rèn)設(shè)置)
(3)root_squash:將root用戶及所屬組都映射為匿名用戶或用戶組(默認(rèn)設(shè)置)
(4)no_root_squash:與rootsquash取反
(5)anonuid=xxx:將遠(yuǎn)程訪問的所有用戶都映射為匿名用戶,并指定該用戶為本地用戶(UID=xxx)
(6)anongid=xxx:將遠(yuǎn)程訪問的所有用戶組都映射為匿名用戶組賬戶,并指定該匿名用戶組賬戶為本地用戶組賬戶(GID=xxx)

其它選項:

(1)secure:限制客戶端只能從小于1024的tcp/ip端口連接nfs服務(wù)器(默認(rèn)設(shè)置)
(2)insecure:允許客戶端從大于1024的tcp/ip端口連接服務(wù)器
(3)sync:將數(shù)據(jù)同步寫入內(nèi)存緩沖區(qū)與磁盤中,效率低,但可以保證數(shù)據(jù)的一致性
(4)async:將數(shù)據(jù)先保存在內(nèi)存緩沖區(qū)中,必要時才寫入磁盤
(5)wdelay:檢查是否有相關(guān)的寫操作,如果有則將這些寫操作一起執(zhí)行,這樣可以提高效率(默認(rèn)設(shè)置)
(6)no_wdelay:若有寫操作則立即執(zhí)行,應(yīng)與sync配合使用
(7)subtree:若輸出目錄是一個子目錄,則nfs服務(wù)器將檢查其父目錄的權(quán)限(默認(rèn)設(shè)置)
(8)no_subtree:即使輸出目錄是一個子目錄,nfs服務(wù)器也不檢查其父目錄的權(quán)限,這樣可以提高效率

四,啟動NFS服務(wù)

sean@sean:~$ sudo service nfs-kernel-server start
 * Exporting directories for NFS kernel daemon...                                                                exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.137.129:/home/sean/shareDir".
 Assuming default behaviour ('no_subtree_check').
 NOTE: this default has changed since nfs-utils version 1.0.x

 * Starting NFS kernel daemon  
sean@sean:~$ sudo service nfs-kernel-server status
nfsd running
sean@sean:~$ ps -ef|grep nfsd
root   10536   2 0 23:40 ?    00:00:00 [nfsd4]
root   10537   2 0 23:40 ?    00:00:00 [nfsd4_callbacks]
root   10539   2 0 23:40 ?    00:00:00 [nfsd]
root   10540   2 0 23:40 ?    00:00:00 [nfsd]
root   10541   2 0 23:40 ?    00:00:00 [nfsd]
root   10542   2 0 23:40 ?    00:00:00 [nfsd]
root   10543   2 0 23:40 ?    00:00:00 [nfsd]
root   10544   2 0 23:40 ?    00:00:00 [nfsd]
root   10545   2 0 23:40 ?    00:00:00 [nfsd]
root   10546   2 0 23:40 ?    00:00:00 [nfsd]
sean   10566  9528 0 23:41 pts/6  00:00:00 grep --color=auto nfsd

通過命令可以看到文件夾已經(jīng)被共享

sean@sean:~$ showmount -e
Export list for sean:
/home/sean/shareDir 192.168.137.129

五,客戶端掛載NFS共享目錄

sean@ubuntu:~$ sudo mount 192.168.137.128:/home/sean/shareDir /home/sean/shared
mount: wrong fs type, bad option, bad superblock on 192.168.137.128:/home/sean/shareDir,
    missing codepage or helper program, or other error
    (for several filesystems (e.g. nfs, cifs) you might
    need a /sbin/mount.<type> helper program)
    In some cases useful info is found in syslog - try
    dmesg | tail or so

上網(wǎng)查看了一下錯誤原因,是因為客戶端沒有安裝nfs-common包

sean@ubuntu:~$ sudo apt-get install nfs-common
之后再次使用掛載命令即可,此時如果我們再次查看客戶端掛載的磁盤,就可以看到NFS共享目錄已經(jīng)被掛載上了

sean@ubuntu:~$ df
Filesystem             1K-blocks  Used Available Use% Mounted on
udev                  488800    4  488796  1% /dev
tmpfs                  99904  1456   98448  2% /run
/dev/sda1              19478204 3745568 14720156 21% /
none                    4    0     4  0% /sys/fs/cgroup
none                   5120    0   5120  0% /run/lock
none                  499512   152  499360  1% /run/shm
none                  102400   40  102360  1% /run/user
/dev/sr0               1044480 1044480     0 100% /media/sean/Ubuntu 14.04.4 LTS amd64
192.168.137.128:/home/sean/shareDir 19478272 4288896 14176896 24% /home/sean/shared

此時如果我們在128的/home/sean/shareDir目錄下創(chuàng)建一個文件,在129的/home/sean/shared目錄下可以看到一個名稱相同的文件,并且文件的內(nèi)容也相同

六,開機(jī)啟動NFS服務(wù)

安裝完成之后查看系統(tǒng)服務(wù)

sean@sean:~$ runlevel
N 2
sean@sean:~$ ll /etc/rc2.d
total 20
drwxr-xr-x 2 root root 4096 6月 20 23:25 ./
drwxr-xr-x 132 root root 12288 6月 26 20:16 ../
-rw-r--r-- 1 root root 677 2月 17 12:59 README
lrwxrwxrwx 1 root root 20 2月 22 06:33 S20kerneloops -> ../init.d/kerneloops*
lrwxrwxrwx 1 root root 27 6月 20 23:25 S20nfs-kernel-server -> ../init.d/nfs-kernel-server*
lrwxrwxrwx 1 root root 15 2月 22 06:33 S20rsync -> ../init.d/rsync*
lrwxrwxrwx 1 root root 27 2月 22 06:33 S20speech-dispatcher -> ../init.d/speech-dispatcher*
lrwxrwxrwx 1 root root 15 2月 22 06:33 S50saned -> ../init.d/saned*
lrwxrwxrwx 1 root root 19 2月 22 06:33 S70dns-clean -> ../init.d/dns-clean*
lrwxrwxrwx 1 root root 18 2月 22 06:33 S70pppd-dns -> ../init.d/pppd-dns*
lrwxrwxrwx 1 root root 21 2月 22 06:33 S99grub-common -> ../init.d/grub-common*
lrwxrwxrwx 1 root root 18 2月 22 06:33 S99ondemand -> ../init.d/ondemand*
lrwxrwxrwx 1 root root 18 2月 22 06:33 S99rc.local -> ../init.d/rc.local*
nfs-kernel-server是自動啟動,就不需要再進(jìn)行修改了,而rpcbind就比較麻煩了,找了半天才找到vi /etc/init/rpcbind-boot.conf

# portmap-boot

description "Upstart job to start rpcbind on boot only"
author "Clint Byrum"

emits start-rpcbind

start on virtual-filesystems and net-device-up IFACE=lo

task

exec initctl emit --no-wait start-rpcbind ON_BOOT=y
可以見到這個服務(wù)設(shè)為開機(jī)啟動了

七,開機(jī)自動掛載共享盤

這時候我們需要修改的文件是/etc/fstab,命令格式如下:

<NFS服務(wù)端>:<共享目錄> <本地目錄> <文件系統(tǒng)類型> <選項> <dump> <pass>每個字段的具體含義這里就不詳細(xì)解釋了,vi /etc/fstab,在文件中添加下面這行配置

192.168.137.128:/home/sean/shareDir /home/sean/shared nfs defaults 0 0系統(tǒng)每次啟動時即會自動掛載共享盤

以上這篇Ubuntu配置NFS的具體流程(推薦)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 淺談Linux中的mkdir -p及基礎(chǔ)用法

    淺談Linux中的mkdir -p及基礎(chǔ)用法

    mkdir是一個用于創(chuàng)建目錄(目錄樹)的 Unix 和 Linux 命令, -p 選項允許創(chuàng)建一個目錄和它不存在的父目錄,這篇文章主要介紹了Linux中的mkdir -p,需要的朋友可以參考下
    2023-09-09
  • Linux Shell腳本系列教程(一):Shell入門

    Linux Shell腳本系列教程(一):Shell入門

    這篇文章主要介紹了Linux Shell腳本系列教程(一):Shell入門,本文講解了Shell簡介、Shell基本操作、如何打開Shell終端、Shell腳本的概念、如何運行Shell腳本、Shell腳本的注釋等基礎(chǔ)知識,需要的朋友可以參考下
    2015-06-06
  • ubuntu與centos中更換ip的shell代碼

    ubuntu與centos中更換ip的shell代碼

    ubuntu與centos中更換ip的shell代碼,需要的朋友可以參考下
    2013-02-02
  • Shell(())實現(xiàn)對整數(shù)進(jìn)行數(shù)學(xué)運算

    Shell(())實現(xiàn)對整數(shù)進(jìn)行數(shù)學(xué)運算

    這篇文章主要介紹了Shell(())實現(xiàn)對整數(shù)進(jìn)行數(shù)學(xué)運算,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • shell腳本配置hostname的方法步驟

    shell腳本配置hostname的方法步驟

    本文主要介紹了shell腳本配置hostname的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-03-03
  • shell腳本引用外部變量的兩種方法

    shell腳本引用外部變量的兩種方法

    本文主要介紹了shell腳本引用外部變量的兩種方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-05-05
  • Linux上安裝和卸載rpm軟件包的方法

    Linux上安裝和卸載rpm軟件包的方法

    這篇文章主要介紹了Linux上安裝和卸載rpm軟件包的方法的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-11-11
  • 解決centos7 開機(jī)/etc/rc.local 不執(zhí)行的問題

    解決centos7 開機(jī)/etc/rc.local 不執(zhí)行的問題

    下面小編就為大家?guī)硪黄鉀Qcentos7 開機(jī)/etc/rc.local 不執(zhí)行的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-03-03
  • shell腳本 自動創(chuàng)建用戶詳解及實例代碼

    shell腳本 自動創(chuàng)建用戶詳解及實例代碼

    這篇文章主要介紹了shell腳本 自動創(chuàng)建用戶詳解及實例代碼的相關(guān)資料,需要的朋友可以參考下
    2017-03-03
  • linux用戶與文件基礎(chǔ)命令介紹(1)

    linux用戶與文件基礎(chǔ)命令介紹(1)

    這篇文章主要為大家詳細(xì)介紹了linux用戶與文件基礎(chǔ)命令,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-12-12

最新評論