ITPub博客

首页 > 云计算 > 虚拟化 > 好程序员云计算学习路线分享:关于NFS

好程序员云计算学习路线分享:关于NFS

原创 虚拟化 作者:好程序员IT 时间:2019-11-18 17:59:21 0 删除 编辑

好程序员云计算学习路线分享 :关于NFS

项目名称:  为集群中的  Web Server  配置后端存储

NFS : Network File System  网络文件系统, Unix 系统之间共享文件的一种协议

NFS  的客户端主要为 Linux

支持多节点同时挂载以及并发写入

========================================================

nas 192.168.122.59

web1 192.168.122.85

web2 192.168.122.166

web3 192.168.122.111

nas web1 web2 web3

# sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config

# setenforce 0

centos6

# iptables -F

# service iptables save

centos7

# systemctl stop firewalld

# systemctl disable firewalld

# vim /etc/hosts [ 可选 ]

192.168.122.59 nas

192.168.122.85 web1

192.168.122.166 web2

192.168.122.111 web3

NFS

1. 安装软件

yum -y install nfs-utils (主包提供文件系统)

yum -y install rpcbind (提供 rpc 协议)

2. 启动服务 ------> 这两个服务必须同时启用

systemctl start nfs

systemctl start rpcbind

一、nas (存储端)

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

[root@nas ~]# mkdir /webdata // 存储网站代码 !

[root@nas ~]# echo "nfs test..." > /webdata/index.html

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

/webdata 192.168.122.0/24(rw,sync,no_root_squash) // 不压制 root( 当 client 端使用 root 挂载时,也有 root 权限 )  挂载是 root  ,同样保持 root 权限

[root@nas ~]# systemctl start nfs-server

[root@nas ~]# systemctl enable nfs-server

[root@nas ~]# exportfs -v

/webdata 192.168.122.0/24(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)

his

二、web1 web2 web3  客户端

以web1 为例:

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

[root@web1 ~]# systemctl start httpd

[root@web1 ~]# systemctl enable httpd

httpd

1.  查看存储端共享  [ 可选 ]

[root@web1 ~]# showmount -e nas

Export list for nas:

/webdata 192.168.122.0/24

ps -ef | grep nfs

2.  手动挂载  [ 可选 ]

[root@web1 ~]# mount -t nfs nas:/webdata /var/www/html/

[root@web1 ~]# umount /var/www/html/

3.  自动挂载到网站主目录

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

nas:/webdata /var/www/html nfs defaults 0 0

[root@web1 ~]# mount -a

4.  查看挂载

[root@web1 ~]# df

nas:/webdata 7923136 692416 6821568 10% /var/www/html

[root@web1 ~]# ls /var/www/html/

index.html

5. web2 web3 同上

三、测试网站访问

# firefox 192.168.122.85

# firefox 192.168.122.111

# firefox 192.168.122.166


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69913892/viewspace-2664683/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
欢迎关注公众号:好程序员特训营 web前端教程分享 723729549 大数据教程分享 703503210

注册时间:2019-03-20

  • 博文量
    539
  • 访问量
    410742