学习记录012-NFS


1.Network file System 主要是通过网络让不同的主机进行通信,构建于ip协议之上的现代文件系统,用来存储共享视频,图片,文件等

2.并发大的时候会有点问题(维护不好会丢数据)

3.NFS挂载
mount 源 目标
mount 192.168.1.111:/data /data
NFS传输的两个端口是不确定的,所以才会用Rpc服务,RPC(Remote Procddure Call)服务(中间人的角色) rpcbind
它的配置文件在/etc/exports
ssh的配置文件在/etc/ssh/sshd_config

4. 安装步骤
a. 以下是执行环境
 

[root@NFSserver ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@NFSserver ~]# uname -r
2.6.32-358.el6.x86_64
[root@NFSserver ~]# uname -m
x86_64

  

b. portmap 的作用端口与对应的功能对应工作
nfs-utils 这个是NFS的主程序,包括rpc.nfsd rpc.mountd两个守护进程(daemons)
rpm -qa nfs-utils portmap rpcbind //查看机主有没有该文件

c. 安装包有两种方式:
yum install -y nfs-utils rpcbind
yum groupinstall "NFS fileserver" -y //双引号内的内容在yum grouplist 中找到

d.开启服务,并检查
 

[root@NFSserver ~]# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
[root@NFSserver ~]# ps -ef|grep rpc
rpc 9584 1 0 08:19 ? 00:00:00 rpcbind
root 9589 9092 0 08:19 pts/0 00:00:00 grep rpc
[root@NFSserver ~]# /etc/init.d/rpcbind status
rpcbind (pid 9584) is running...
rpcinfo -p localhost //查看rpc目前有什么服务
[root@NFSserver ~]# /etc/init.d/rpcbind stop Stopping rpcbind: [ OK ] [root@NFSserver ~]# rpcinfo -p localhost rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused //代表服务没有启动

  


e. 开机启动nfs,rpcbind 并检查设置是否成功
 

[root@NFSserver ~]# chkconfig nfs on
[root@NFSserver ~]# chkconfig rpcbind on
[root@NFSserver ~]# chkconfig --list nfs
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@NFSserver ~]# chkconfig --list rpcbind
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off

  

f. vim /etc/exports 写入
/data 192.168.1.0/24 (rw,sync) //读写, ro 就是只读only,sync则同步到磁盘里,async则同步到缓存里

g. /etc/init.d/nfs reload //reload 平滑重启 等同于exportfs -r

h. 在本机做检查showmount -e localhost

i. telent 192.168.1.111 111

j.挂载并测试
mount -t nfs 192.168.1.111:/data /mnt
cd /mnt
ls-l
touch
ls -l

Try! Try! Try!
原文地址:https://www.cnblogs.com/carltonx/p/5645556.html