linux中nfs

在服务器端中编辑 /etc/exports 文件,添加如下内容:
/usr/local/tomcat/apache-tomcat_city/webapps/upload/ 10.26.42.209(rw,no_root_squash)
/usr/local/tomcat/apache-tomcat_city/webapps/upload/ 10.27.193.22(rw,no_root_squash)
/usr/local/tomcat/apache-tomcat_city/webapps/upload/ 10.27.192.141(rw,no_root_squash)
第一项是要共享的目录,后者为共享的配置参数一般为:*(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也可以

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

Linux下配置NFS服务

1、安装

  #centos
yum install nfs-utils portmap nfs4-acl-tools


#Debian下,kernel-server相当于server,common是client
sudo apt-get install nfs-kernel-server nfs-common portmap

2、配置

#创建共用目录
sudo mkdir /home/nfs
sudo chmod 777 /home/nfs

#配置目录、权限等
vim /etc/exports
/home/nfs *(rw,sync)

#启动,Debian
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-kernel-server restart


#启动,CentOS
service portmap restart
service nfs restart

#更新了/etc/exports后,使用如下命令刷新:
sudo exportfs -r

3、客户端

#显示NFS服务器上exports出来的目录
showmount -e 10.61.1.31
Export list for 10.61.1.31:
/home/nfs *

#挂载到本地/mnt/nfs
mkdir /mnt/nfs
chmod 777 /mnt/nfs
sudo mount -t nfs 10.61.1.31:/home/nfs /mnt/nfs

#卸载,必须mount的shell进程退出后才能执行
sudo umount -f /mnt/nfs


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值