天天看点

Linux,windows下nfs服务器的挂载

web:192.168.1.10   nfs:192.168.1.11

1 配置nfs服务器

安装软件

    yum install rpcbind

    yum install nfs

创建共享目录

    mkdir /tmp/rw

    mkdir /tmp/ro

更改属猪属组

chmod -R nfsnobody.nfsnobody rw

chmod -R nfsnobody.nfsnobody ro

vim /etc/exports

/tmp/rw 192.168.1.10/24(rw)

/tmp/ro 192.168.1.10/24(ro)

关闭 selinux iptables

setenforce 0

/etc/init.d/iptables stop

service rpcbind restart  (需先重启)

service nfs restart

showmount -e localhost  查看

2 web客户端

    安装软件 重启服务

mkdir /tmp/rw

mkdir /tmp/ro

showmount -e 192.168.1.11  查看nfs服务器

挂载

mount -t nfs 192.168.1.11:/tmp/rw /tmp/rw

mount -t nfs 192.168.1.11:/tmp/ro /tmp/ro

df -hT  查看本机挂载情况

查看写入情况

cd /tmp/ro

touch q

cd /tmp/rw

3 配置开机自动挂载  nfs 和客户端都要配置

配置开机启动服务

chkconfig --level 35 rpcbind on

chkconfig --level 35 nfs on

chkconfig --list rpcbind

chkconfig --list nfs

      等级0表示:表示关机

      等级1表示:单用户模式

      等级2表示:无网络连接的多用户命令行模式

      等级3表示:有网络连接的多用户命令行模式

      等级4表示:不可用

      等级5表示:带图形界面的多用户模式

      等级6表示:重新启动

开机关闭selinux 和iptables

vim /etc/selinux/config

SELINUX=Permissive

chkconfig iptables off (2 3 4 5 等级关闭)

在web客户端配置自动挂载

echo "mount -t nfs 192.168.1.11:/tmp/ro /tmp/ro" >> /etc/rc.local

echo "mount -t nfs 192.168.1.11:/tmp/rw /tmp/rw" >> /etc/rc.local

完成  开机时先打开NFS 再打开web

若客户端不能找到nfs会 开机卡在 nfs挂载项 解决

开机 几秒内 倒计时

回车

按e

按向下箭头 指到kernel 按e

在quiet后加 空格 再加1 回车

按b

启动后 删除 rc.local 里的 挂载NFS命令  重启

继续阅读