Linux之间实现目录共享

来源:互联网 发布:linux禁ping设置 编辑:程序博客网 时间:2024/05/19 18:11

最近项目中需要将一台服务器上的文件共享到其他服务器上(作为笔记记录一下)

在服务器0.0.0.1中(文件所在的服务器ip地址)

首先检查nfs及portmap两个软件包是否安装

ll /etc/rc.d/init.d/nfs

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

如果没有找到,可以用以下命令安装

rpm –q nfs-utils portmap

配置共享目录

vim /etc/exports    (修改后记得重启 nfs 与 portmap  ;   service nfs restart)

在/etc/exports中输入

/home/file -ro -network 0.0.0.2

其中/home/file表示要共享的目录,-ro表示只读,-network表示网络共享,0.0.0.2为运行读取共享的服务器

查看nfs及portmap的状态

service nfs starus

service portmap starus

根据状态,启动,或者重启服务

service nfs start

service portmap start


在服务器0.0.0.2上

挂载0.0.0.1共享的目录

mount -t nfs 0.0.0.1:/home/file /tmp/share

这样在0.0.0.2服上就可以通过访问/home/share目录来访问到192.168.0.1上的/home/file目录了

ll /tmp/def

如果失败请查看防火墙是否关闭

service iptables status

如果没有请关闭

service iptables stop


0 0