糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > rpcbind结合nfs实现文件共享

rpcbind结合nfs实现文件共享

时间:2019-04-12 17:56:31

相关推荐

rpcbind结合nfs实现文件共享

NFS介绍

NFS 就是 Network FileSystem 的缩写,最早之前是由 Sun 这家公司所发展出来的 (注1)。 它最大的功能就是可以透过网络,让不同的机器、不同的操作系统、可以彼此分享个别的档案 (share files)。所以,你也可以简单的将他看做是一个文件服务器 (file server) 呢!这个 NFS 服务器可以让你的 PC 来将网络远程的 NFS 服务器分享的目录,挂载到本地端的机器当中, 在本地端的机器看起来,那个远程主机的目录就好像是自己的一个磁盘分区槽一样 (partition)!使用上相当的便利!

RPC介绍

RPC 最主要的功能就是在指定每个 NFS 功能所对应的 port number ,并且回报给客户端,让客户端可以连结到正确的埠口上去。 那 RPC 又是如何知道每个 NFS 的埠口呢?这是因为当服务器在启动 NFS 时会随机取用数个埠口,并主动的向 RPC 注册,因此 RPC 可以知道每个埠口对应的 NFS 功能,然后 RPC 又是固定使用 port 111 来监听客户端的需求并回报客户端正确的埠口, 所以当然可以让 NFS 的启动更为轻松愉快了!

注意

要启动 NFS 之前,RPC 就要先启动了,否则 NFS 会无法向 RPC 注册。 另外,RPC 若重新启动时,原本注册的数据会不见,因此 RPC 重新启动后,它管理的所有服务都需要重新启动来重新向 RPC 注册。

nfs server配置

os:centos6

IP:192.168.153.167

安装

安装rpc服务和nfs服务

[root@localhost ~]# yum -y install rpcbind nfs-utils

启动服务

先开启rpc服务

[root@localhost ~]# service rpcbind start

在开启nfs服务

[root@localhost ~]# service nfs start

配置nfs服务

创建共享目录

[root@localhost ~]# mkdir /opt/data

修改nfs的配置文件

[root@localhost ~]# vim /etc/exports

配置内容如下

[root@localhost ~]# cat /etc/exports /opt/data 192.168.153.0/24(rw,no_root_squash)

/etc/exports 配置文件的语法与参数

重新读取配置文件

[root@localhost ~]# exportfs -rvexporting 192.168.153.0/24:/opt/data

nfs client配置

os:centos6

IP:192.168.153.166

安装

[root@localhost ~]# yum -y install nfs-utils

查看

查看 NFS server 上所有的共享目录

[root@localhost ~]# showmount -e 192.168.153.167Export list for 192.168.153.167:/opt/data 192.168.153.0/24

挂载

将nfs server的共享目录挂载到本地的/var/www/html 下

临时挂载

[root@localhost ~]# mount -t nfs 192.168.153.167:/opt/data /var/www/html/

永久挂载

修改/etc/fstab 配置文件

[root@localhost ~]# vim /etc/fstab

在最后添加一行

[root@localhost ~]# tail -1 /etc/fstab 192.168.153.167:/opt/data /var/www/html nfsdefaults 0 0

如图:

查看挂载结果:

[root@localhost ~]# df -hFilesystemSize Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 18G 982M 16G 6% /tmpfs491M0 491M 0% /dev/shm/dev/sda1 485M 33M 427M 8% /boot192.168.153.167:/opt/data18G 1.3G 16G 8% /var/www/html

测试:

nfs server端

在 /opt/data 目录下创建文件hello.txt

[root@localhost ~]# cd /opt/data/[root@localhost data]# echo "hello world" > hello.txt

nfs client端

可以看到server端文件

[root@localhost ~]# cd /var/www/html/[root@localhost html]# lshello.txt[root@localhost html]# cat hello.txt hello world

链接

详细内容见鸟哥链接:

http://cn./linux_server/0330nfs.php#What_NFS_RPC

如果觉得《rpcbind结合nfs实现文件共享》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。