linux服务器nfs配置实验报告(linux的nfs配置)

linux配置nfs步骤

NFS的配置过程很简单。在服务器端中编辑 /etc/exports 文件,添加如下内容: /home/nfs-share 192.168.1.122 (rw,sync)

第一项是要共享的目录,后者为共享的配置参数一般为: (rw,sync,no_root_squash,no_all_squash,no_subtree_check)

然后开启NFS和portmap服务:

/etc/init.d/nfs start //用service nfs start也可以 /etc/init.d/portmap start //用service portmap stasrt也可以

在centos6.5中portmap已经改为rpcbind 在客户端,用mount –t nfs 192.168.123:/home/nfs-share /home/remote_file挂载服务器端的共享目录到本地的/home/remote-file挂载点,然后我们就可以在客户端上应用到远程主机上的/home/nfs-share目录了。想要系统在开机时自动挂载,修改/etc/fstab文件,把NFS服务器的共享目录添加进去就可以了,这个不用多说。

如何知道远程主机上的共享目录情况呢?使用showmount命令,这个命令需要root权限。它有三个选项(记住这三个选项代表的含义: showmount –a IP 显示指定NFS服务器的客户端以及服务器端在客户端的挂载点 showmount –d IP 显示指定NFS服务器在客户端的挂载点 showmount –e IP 显示指定NFS服务器上的共享目录列表(或者叫输出列表) 我们输入命令showmount –a 192.168.1.123:

图片客户端中出现的mount clntudp_create: RPC: Program not registered错误是怎么回事?噢,我刚才重启了一下服务器端,重启后NFS服务没有开启。 我们开启服务器端的NFS服务,再从客户端上查看一下NFS服务器的情况:

Showmount –a显示出NFS服务器192.168.1.123的共享目录被客户端192.168.122挂载到/home中;

在showmount -e IP,出现clnt_create: RPC: Port mapper failure - Timed out报错

解决方案:

被访问的NFS服务器上的防火墙没有添加规则,向iptables里面添加以下查看的所有端口即可(目前解决的方法,当然你也可以关闭防火墙,不过这样是比较不安全的,如果你的nfs作用不大,建议你另选别的应用来替代吧!毕竟开那么多的端口,比较不安全呀!)

通过#rpcinfo -p 10.10.209.148

[root@rh01 /]# rpcinfo -p 10.10.209.148program vers proto port service100000 4 tcp 111 portmapper100000 3 tcp 111 portmapper100000 2 tcp 111 portmapper100000 4 udp 111 portmapper100000 3 udp 111 portmapper100000 2 udp 111 portmapper100024 1 udp 52943 status100024 1 tcp 37706 status100011 1 udp 875 rquotad100011 2 udp 875 rquotad100011 1 tcp 875 rquotad100011 2 tcp 875 rquotad100003 2 tcp 2049 nfs100003 3 tcp 2049 nfs100003 4 tcp 2049 nfs100227 2 tcp 2049 nfs_acl100227 3 tcp 2049 nfs_acl100003 2 udp 2049 nfs100003 3 udp 2049 nfs100003 4 udp 2049 nfs100227 2 udp 2049 nfs_acl100227 3 udp 2049 nfs_acl100021 1 udp 37438 nlockmgr100021 3 udp 37438 nlockmgr100021 4 udp 37438 nlockmgr100021 1 tcp 46331 nlockmgr100021 3 tcp 46331 nlockmgr100021 4 tcp 46331 nlockmgr100005 1 udp 57177 mountd100005 1 tcp 43147 mountd100005 2 udp 49154 mountd100005 2 tcp 54810 mountd100005 3 udp 55707 mountd100005 3 tcp 58309 mountd

[root@rh01 /]#

刚才在重启NFS服务的时候,细心的话可以注意到,我们在输入命令/etc/init.d/nfs start开启nfs服务时,系统还自作主张地开启了NFS quotas等其它3个服务。

怎么回事?我们只输入了一条启动NFS服务的命令,它怎么额外的启动了3个服务?后面的启动portmap服务又是怎么回事? 我们首先要了解一点:NFS文件系统要提供服务单靠本身的NFS服务是不够的,还需要调用其它服务,这个其它服务就是RPC(remote procedure call,远程过程调用)服务和portmap服务。由于NFS服务本身不提供文件传输功能,我们要远程使用NFS文件系统就需要RPC服务的支持;而portmap服务用来为RPC服务进行动态端口分配和映射,所以portmap服务也是NFS服务所必须的。

我们查看一下服务的启动情况:

所遇错误:

/etc/init.d/nfs-kernel-server: 没有那个文件或目录

解决方案:

没有配置、安装NFS

Linux 下配置NFS服务

1、安装

2、配置

3、客户端

所遇问题:centos6.5

portmap: 未被识别的服务

解决方案:

由于在6系列里面,portmap已经改名了 ,6系列需要使用 service rpcbind start启动[root@unix-big-bang ~]# service portmap start

portmap: 未被识别的服务

[root@unix-big-bang ~]# service rpcbind status

rpcbind (pid 1312) is running...

[root@unix-big-bang ~]#

好文共赏:

linux nfs文件共享

◆一、概念

NFS是网络文件系统(Network File System)的简称,是分布式计算机系统的一个组成部分,可实现在异构网络上共享和装配远程文件系统。

NFS由SUN公司开发,目前已成为文件服务的一种标准(RFC1904,RFC1813)。其最大的功能就是可以通过网络,让不同 操作系统 的计算机可以共享数据,所以也可以看作是一个文件服务器。NFS是除了SAMBA之外Windows与Linux及Unix与Linux之间通信的方法。

理想条件下的NFS 网络拓扑结构

1、设置Linux系统之间的文件共享(Linux与Windows中间文件共享采用SAMBA服务);

2、NFS只是一种文件系统,本身没有传输功能,是基于RPC协议实现的,才能达到两个Linux系统之间的文件目录共享;

3、NFS为C/S 架构 ;

◆二、服务器配置

1、配置文件

主要配置文件为:/etc/exports

格式为: 共享目录 可mount主机IP(参数1,参数2,……)

如:/var/nfs 172.20. . (rw,sync,no_rootl_squash)

说明:必须注意nfs/目录的访问权限,必须设置成777权限;父目录/var权限无要求,普通的755即可;

2、启动相关服务

然后依次启动相关服务:portmap,nfslock,nfs

service portmap start

service nfslock start

service nfs start

关闭顺序相反。

3、检查共享目录

随后可以采用showmount –e查看一下,看看共享的目录情况:

[root@ns var]# showmount -e

Export list for ns.osserver:

/var/nfs 172.20. .

OK,到此为止,NFS服务器搭建完毕;

◆三、客户端配置

1、确保portmap运行

客户端必须确保RPC协议相应的portmap正常运行,否则mount将失败;

2、挂载/var/nfs目录(本地挂载点为/mnt/nfs)

mount -t nfs 172.20.65.16:/var/nfs /mnt/nfs

成功mount以后,即可同本地目录一样随意操作;

◆四、其它相关命令

1、当修改了/etc/exports文件后,可以不用重新启动nfs服务,直接采用exports –rv 即可重新导出共享目录;

该命令格式如下:

exportfs [-aruv]

-a :全部mount或者unmount /etc/exports中的内容

-r :重新mount /etc/exports中分享出来的目录

-u :umount 目录

-v :在 export 的时候,将详细的信息输出到屏幕上。

具体例子:

[root@ns var]# showmount -e

Export list for ns.osserver:

/var/nfs 172.20. .

[root@ns var]# exportfs –au #全部卸载

[root@ns var]# showmount -e

Export list for ns.osserver:

[root@ns var]# exportfs –rv #全部重新 export 一次

exporting 172.20. . :/var/nfs

[root@ns var]#

2、showmout命令对于NFS的操作和查错有很大的帮助,所以我们先来看一下showmount的用法

showmout

-a :这个参数是一般在NFS SERVER上使用,是用来显示已经mount上本机nfs目录的cline机器。

-e :显示指定的NFS SERVER上export出来的目录。

例如:

[root@localhost ~]# showmount -e 172.20.16.139

Export list for 172.20.16.139 :/root/share 172.20.16.137

[root@ns var]# showmount -a

All mount points on localhost.localdomain: :/root/share,172.20. . :/root/share,172.20.16. :/root/share,172.20.16.139:/nfsshare,172.20.16.139:/root/share172.20.16.137: 172.20.16.137:,172.20. . 172.20.16.137:,172.20.16. 172.20.16.137:/root/share172.20.16.139: 172.20.16.139:,172.20. . 172.20.16.139:,172.20.16. 172.20.16.139:,172.20.16.139172.20.16.139:DEFAULT

◆五、常见问题解答

1、提示:mount to NFS server \'172.20.67.203\' failed: server is down.

解决方案:可能是NFS服务器的防火墙有问题;

2、提示:mount: RPC: Timed out

解决方案:由于RPC协议没运行;启动portmap服务;

也有可能是防火墙问题;Server/Client均有可能。

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/zhidata 这个目录仅共享给192.168.8.7这台主机,以供该主机上面的zhi这个用户来使用,

也就是说zhi在192.168.8.5和192.168.8.7上均有账号,且账号均为zhi;

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/zhidata  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/zhidata目录

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

    mkdir: 已创建目录 \"/home/zhidata\"

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

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

    [root@server7 etc]# useradd zhi

    root@server7 etc]# passwd zhi

    更改用户 zhi 的密码 。

    新的 密码:

    无效的密码: 密码少于 8 个字符

    重新输入新的 密码:

    passwd:所有的身份验证令牌已经成功更新。

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

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

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

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

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

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

    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/zhidata     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 modules:                               [  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/zhidata 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

[zhi@client-A upload]$ pwd

/opt/upload

[zhi@client-A upload]$ ll

total 0

#测试创建文件

[zhi@client-A upload]$ touch test123

测试创建目录

[zhi@client-A upload]$ mkdir  testdir

[zhi@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

#测试删除文件

[zhi@client-A upload]$ rm test123

[zhi@client-A upload]$ ll

total 0

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

如何在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

NFS服务器的安装与配置

由于实验室的项目需要实现在CephFS之上建立NFS之上,所以记录一下NFS服务器的安装与配置流程。

NFS 服务器可以让客户端将网络远程的 NFS 服务器分享的目录,直接挂载到本地端的机器当中。本地端的机器通过直接读写挂载的目录,就可以同步到NFS服务器之上。

系统平台:Ubuntu 14.04

NFS Server IP:192.168.1.2

iptables关闭: Firewall is disable.(NFS端口使用在默认情况下是不固定,所以若配置NFS服务器需要搭配防火墙使用的话,请配置固定端口)

SELINUX=disabled

NFS的安装只需要安装rpcbind与nfs-server就可以对外提供服务了。

NFS服务器的主要配置文件就是:/etc/exports。不过这个配置文件不一定会存在,可能需要使用 vim 主动新建这个文件。

/etc/exports文件由以下选项构成:

每一行最前面是要分享出来的目录,目录可以依照不同的权限分享给不同的主机。若权限参数不止一个时,则以逗号 (,) 分开。且主机名与小括号是连在一起的喔!其中参数是可选的,当不指定参数时,nfs将使用默认选项。默认的共享选项是 sync,ro,root_squash,no_delay 当主机名或IP地址为空时,则代表共享给任意客户机提供服务。

下面是一些NFS共享的常用参数:

这里我们使用了NFS v3的配置,如下图所示:

配置完/etc/exports之后,接下来就可以启动NFS服务器了。

为了使NFS服务器能正常工作,需要启动rpcbind和nfs-kernel-server两个服务,并且rpcbind一定要先于nfs-kernel-server启动。

若要开机自启动nfs服务,可以通过sysv-rc-conf配置自启动服务。

客户端的挂载很简单,先建立一个挂载目录

之后客户端对应的文件目录便挂载上对应的文件系统了。

客户端可以通过命令配置开机自启动挂载NFS的文件系统。

将对应的命令 mount -t nfs 192.168.12:/tmp /mnt/nfs

添加至/etc/rc.d/local,不要尝试在直接在/etc/fstab/里挂载

小结 :梳理了一下在ubuntu之下NFS服务器的安装与配置。当然RedHat系列的发行版也是大同小异。若有疏漏,望指点斧正。

Linux NFS配置

body{

line-height:200%;

}

Linux

NFS配置

文件传输服务的种类:

1.NFS(Network

File

System),将远程主机的目录挂载到本地,实现文件共享与远程访问。

UNIX和UNIX之间的文件传输

UNIX和LINUX之间的文件传输

LINUX和LINUX之间的文件传输

2.Samba

WINDOWS和LINUX之间的文件传输

3.TFTP

常用于LINUX和开发板之间的文件传输

一、NFS服务器的搭建

1.在NFS服务器主机中进行设置

安装NFS服务器软件包

设置NFS共享目录输出

启动NFS服务器程序

2.在NFS客户机中进行设置

使用mount命令挂载NFS服务器中的NFS共享目录到文件系统中

通过NFS文件系统的挂载点目录访问NFS服务器中的共享内容

(1)NFS服务器的配置文件

\"/etc/exports\"文件用于配置NFS服务器中输出的共享目录

例如:

/home/share

*(sync,ro)

NFS服务器配置

以root

身份登陆Linux

服务器,编辑/etc

目录下的共享目录配置文件exports,指定共享目录及权限等。

执行如下命令编辑文件/etc/exports:

#

vi

/etc/exports

在该文件里添加如下内容:

/home/work

192.168.0.*(rw,sync,no_root_squash)

然后保存退出。

添加的内容表示:允许ip

地址范围在192.168.0.*的计算机以读写的权限来访问/home/work

目录。

/home/work

也称为服务器输出共享目录。

括号内的参数意义描述如下:

rw:读/写权限,只读权限的参数为ro;

sync:数据同步写入内存和硬盘,也可以使用async,此时数据会先暂存于内存中,而不立即写入硬盘。

no_root_squash:NFS

服务器共享目录用户的属性,如果用户是

root,那么对于这个共享目录来说就具有

root

的权限。

接着执行如下命令,启动端口映射:

#

/etc/rc.d/init.d/portmap

start

sync:设置NFS服务器同步写磁盘,这样不会轻易丢失数据,建议所有的NFS共享目录都是用该选项

ro:设置输出的共享目录只读,与rw不能共同使用

rw:设置输出的共享目录可读写,与ro不能共同使用

二、NFS服务器的架势

防火墙修改

SELinux的修改

未经允许不得转载:便宜VPS网 » linux服务器nfs配置实验报告(linux的nfs配置)