Linux之间NFS方式共享文件

Linux服务器间共享文件的方式有很多种(ftp、smba、nfs)这里给介绍以下,Linux下nfs文件共享方式和实现的方法。

1、首先要开启portmap和nfs服务。

   service portmap start

   service nfs start

2、查看服务是否开启。

   netstat -ntpl

3、修改 /etc/exports

   vi /etc/exports

#/home/temp *(rw,sync,no_root_squash,all_squash)
/home/temp *(ro,sync,no_root_squash,all_squash)  (/home/temp 表示要被共享的目录)
/mnt/inst *(ro,sync)                             (* 表示任意地址)
4、exportfs -a                                   (到处所以共享的目录)

5、showmount -e 127.0.0.1                        (查被共享的目录)
  Export list for 127.0.0.1:
/mnt/inst  *
/home/temp *
6、在客户端输入所需要的共享文件。

mount -t nfs 192.168.111.1:/mnt/inst /mnt        (mount服务器上的共享目录)

7、在客户端使用mount命令,就可以看到刚才被mount的文件了。

这样简单的就是实现了文件共享。


实例:
192.168.10.1 操作:
vi /etc/exports ×添加下面这一行
     /home/temp *(ro,sync)   (/home/temp 表示要被共享的目录)
service portmap start
service nfs start
netstat -ntpl

192.168.10.2 操作:
mount -t nfs 192.168.111.1:/mnt/inst /mnt




猜你喜欢

转载自zpopopo.iteye.com/blog/1759436