日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
CentOS下NFS服務(wù)搭建與配置

啟動(dòng)NFS server之前,首先要啟動(dòng)RPC服務(wù)(CentOS5.8下為portmap服務(wù),CentOS6.6下為rpcbind服務(wù),下同),否則NFS SERVER就無(wú)法向RPC服務(wù)注冊(cè)了。另外,如果RPC服務(wù)重新啟動(dòng),原來(lái)已經(jīng)注冊(cè)好的NFS端口數(shù)據(jù)就會(huì)丟失,因此,此時(shí)RPC服務(wù)管理的NFS程序也需要重新啟動(dòng)以重新向RPC注冊(cè)。要特別注意的是,一般修改NFS配置文件后,是不需要重啟NFS的,直接在命令行執(zhí)行 /etc/init.d/nfs reload 或 exportfs -rv 即可使修改的 /etc/exports 生效。

成都創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供沿灘網(wǎng)站建設(shè)、沿灘做網(wǎng)站、沿灘網(wǎng)站設(shè)計(jì)、沿灘網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、沿灘企業(yè)網(wǎng)站模板建站服務(wù),十載沿灘做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

1. NFS服務(wù)端搭建

1.1. 安裝NFS和rpc 【服務(wù)端、客戶端都安裝】

[root@backup ~]# rpm -qa nfs-utils rpcbind
[root@backup ~]# yum install nfs-utils rpcbind -y    #nfs需要的安裝包
[root@backup ~]# rpm -qa nfs-utils rpcbind
nfs-utils-1.2.3-64.el6.x86_64
rpcbind-0.2.0-11.el6_7.x86_64

1.2. 查看用戶信息

[root@nfs01 ~]# tail /etc/passwd
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
saslauth:x:499:76:Saslauthd user:/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
oldboy:x:500:500::/home/oldboy:/bin/bash
rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin        #yum安裝rpc服務(wù)時(shí)創(chuàng)建的
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin        #yum安裝rpc服務(wù)時(shí)創(chuàng)建的
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin    #yum安裝nfs服務(wù)時(shí)創(chuàng)建的

1.3. 配置exports

[root@nfs01 ~]# mkdir /data
[root@nfs01 ~]# ll -d /data/
drwxr-xr-x. 3 root root 4096 Apr 11 09:49 /data/
[root@nfs01 ~]# chown -R nfsnobody.nfsnobody /data/   
[root@nfs01 ~]# ll -d /data/                     
drwxr-xr-x. 3 nfsnobody nfsnobody 4096 Apr 11 09:49 /data/
[root@nfs01 ~]# cat /etc/exports   
# share /data for web created by zhangliang at 2016-05-21
/data  172.16.1.0/24(rw,sync)
#172.16.1.0/24(rw,sync) 沒(méi)有空格

1.4. 啟動(dòng)rpcbind服務(wù)

[root@nfs01 ~]# /etc/init.d/rpcbind start   
[root@nfs01 ~]# netstat -anp | grep 'rpc'   
tcp        0      0 0.0.0.0:111                0.0.0.0:*                  LISTEN      1346/rpcbind       
tcp        0      0 0.0.0.0:38420              0.0.0.0:*                  LISTEN      1368/rpc.statd     
tcp        0      0 :::13894                    :::*                        LISTEN      1368/rpc.statd     
tcp        0      0 :::111                      :::*                        LISTEN      1346/rpcbind       
udp        0      0 0.0.0.0:673                0.0.0.0:*                              1346/rpcbind       
udp        0      0 127.0.0.1:703              0.0.0.0:*                              1368/rpc.statd     
udp        0      0 0.0.0.0:15306              0.0.0.0:*                              1368/rpc.statd     
udp        0      0 0.0.0.0:111                0.0.0.0:*                              1346/rpcbind       
udp        0      0 :::673                      :::*                                    1346/rpcbind       
udp        0      0 :::50537                    :::*                                    1368/rpc.statd     
udp        0      0 :::111                      :::*                                    1346/rpcbind       
unix  2      [ ACC ]    STREAM    LISTENING    10120  1346/rpcbind        /var/run/rpcbind.sock
unix  2      [ ]        DGRAM                    10207  1368/rpc.statd     
[root@nfs01 ~]# rpcinfo -p localhost   
  program vers proto  port  service
    100000    4  tcp    111  portmapper
    100000    3  tcp    111  portmapper
    100000    2  tcp    111  portmapper
    100000    4  udp    111  portmapper
    100000    3  udp    111  portmapper
    100000    2  udp    111  portmapper
    100024    1  udp  15306  status
    100024    1  tcp  38420  status
#### 由上可知,暫時(shí)只有自己的端口服務(wù),沒(méi)有其他的

1.5. 啟動(dòng)NFS

[root@nfs01 ~]# /etc/init.d/nfs start   
Starting NFS services:                                    [  OK  ]
Starting NFS quotas:                                      [  OK  ]
Starting NFS mountd:                                      [  OK  ]
Starting NFS daemon:                                      [  OK  ]
正在啟動(dòng) RPC idmapd:                                      [確定]
[root@nfs01 ~]# rpcinfo -p localhost   
  program vers proto  port  service
    100000    4  tcp    111  portmapper
    100000    3  tcp    111  portmapper
    100000    2  tcp    111  portmapper
    100000    4  udp    111  portmapper
    100000    3  udp    111  portmapper
    100000    2  udp    111  portmapper
    100024    1  udp  15306  status
    100024    1  tcp  38420  status
    100011    1  udp    875  rquotad
    100011    2  udp    875  rquotad
    100011    1  tcp    875  rquotad
    100011    2  tcp    875  rquotad
    100005    1  udp  11473  mountd
    100005    1  tcp  62369  mountd
    100005    2  udp  17528  mountd
    100005    2  tcp  47308  mountd
    100005    3  udp  11312  mountd
    100005    3  tcp  51724  mountd
    100003    2  tcp  2049  nfs
    100003    3  tcp  2049  nfs
    100003    4  tcp  2049  nfs
    100227    2  tcp  2049  nfs_acl
    100227    3  tcp  2049  nfs_acl
    100003    2  udp  2049  nfs
    100003    3  udp  2049  nfs
    100003    4  udp  2049  nfs
    100227    2  udp  2049  nfs_acl
    100227    3  udp  2049  nfs_acl
    100021    1  udp  25181  nlockmgr
    100021    3  udp  25181  nlockmgr
    100021    4  udp  25181  nlockmgr
    100021    1  tcp  20093  nlockmgr
    100021    3  tcp  20093  nlockmgr
    100021    4  tcp  20093  nlockmgr

1.6. 加入開始自啟動(dòng)

1.6.1. 使用 /etc/rc.local

[root@nfs01 ~]# tail /etc/rc.local   
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

# start rpc and nfs server
/etc/init.d/rpcbind start
/etc/init.d/nfs start

1.6.2. 使用chkconfig

[root@nfs01 ~]# chkconfig rpcbind on   
[root@nfs01 ~]# chkconfig nfs on   
[root@nfs01 ~]# ls /etc/rc.d/rc3.d/* | grep -E 'rpc|nfs' 
/etc/rc.d/rc3.d/K61nfs-rdma
/etc/rc.d/rc3.d/K69rpcsvcgssd
/etc/rc.d/rc3.d/S13rpcbind
/etc/rc.d/rc3.d/S14nfslock
/etc/rc.d/rc3.d/S19rpcgssd
/etc/rc.d/rc3.d/S30nfs

查看rpc服務(wù)和NFS服務(wù)的開機(jī)啟動(dòng)順序

[root@nfs01 ~]# head /etc/init.d/rpcbind
#! /bin/sh
#
# rpcbind      Start/Stop RPCbind
#
# chkconfig: 2345 13 87                    #運(yùn)行級(jí)別  開機(jī)順序  關(guān)機(jī)順序【其中 2345 指的是 運(yùn)行級(jí)別】
# description: The rpcbind utility is a server that converts RPC program \
#              numbers into universal addresses. It must be running on the \
#              host to be able to make RPC calls on a server on that machine.
#
# processname: rpcbind
[root@nfs01 ~]# head /etc/init.d/nfs   
#!/bin/sh
#
# nfs          This shell script takes care of starting and stopping
#              the NFS services.
#
# chkconfig: - 30 60
# description: NFS is a popular protocol for file sharing across networks.
#              This service provides NFS server functionality, which is \
#              configured via the /etc/exports file.
# probe: true

1.7. 查看有哪些參數(shù)生效

[root@nfs01 ~]# cat /var/lib/nfs/etab
/data  172.16.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,root_squash,no_all_squash)

1.8. 檢查是否成功

[root@nfs01 ~]# showmount -e 172.16.1.31   
Export list for 172.16.1.31:
/data 172.16.1.0/24

2. NFS客戶端配置

2.1. 開始rpcbind服務(wù)

[root@web01 ~]# /etc/init.d/rpcbind start       
Starting rpcbind:                                          [  OK  ]

2.2. 檢查共享信息

[root@web01 ~]# showmount -e 172.16.1.31   
Export list for 172.16.1.31:
/data 172.16.1.0/24

2.3. NFS掛載

[root@web01 ~]# mount -t nfs 172.16.1.31:/data /mnt   

2.4. 查看掛載信息

[root@web01 ~]# df -h        #有時(shí)可能會(huì)被卡主
Filesystem        Size  Used Avail Use% Mounted on
/dev/sda3          8.8G  1.5G  6.9G  18% /
tmpfs              495M    0  495M  0% /dev/shm
/dev/sda1          190M  40M  141M  23% /boot
172.16.1.31:/data  8.8G  1.5G  6.9G  18% /mnt

或者

[root@web01 ~]# cat /proc/mounts                    # 優(yōu)先使用,監(jiān)控時(shí)使用該命令
rootfs / rootfs rw 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
devtmpfs /dev devtmpfs rw,relatime,size=490920k,nr_inodes=122730,mode=755 0 0
devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /dev/shm tmpfs rw,relatime 0 0
/dev/sda3 / ext4 rw,relatime,barrier=1,data=ordered 0 0
/proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0
/dev/sda1 /boot ext4 rw,relatime,barrier=1,data=ordered 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
172.16.1.31:/data/ /mnt nfs4 rw,relatime,vers=4,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.1.8,minorversion=0,local_lock=none,addr=172.16.1.31 0 0

2.5. 測(cè)試

在客戶端和服務(wù)端之間測(cè)試

  1、客戶端創(chuàng)建文件并且輸入數(shù)據(jù),在服務(wù)端是否可以查看

  2、服務(wù)端創(chuàng)建文件并且輸入數(shù)據(jù),在客戶端是否可以查看

  3、在服務(wù)端刪除客戶端創(chuàng)建的文件

  4、在客戶端刪除服務(wù)端創(chuàng)建的文件

2.6. 加入開機(jī)自啟動(dòng)

[root@web01 mnt]# tail -3 /etc/rc.local   
# mount nfs
mount -t nfs 172.16.1.31:/data /mnt


當(dāng)前文章:CentOS下NFS服務(wù)搭建與配置
分享路徑:http://www.dlmjj.cn/article/coscjhp.html