Good programmers cloud computing learning route Share: About NFS

Good programmers cloud computing learning route Share : About NFS

Project namethe cluster of  Web Server  configuration back-end storage

NFS : Network File System  Network File System, Unix a protocol to share files between systems

NFS  clients are mainly Linux

Support for multiple nodes simultaneously mount and concurrent writes

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

on 192.168.122.59

web1 192.168.122.85

web2 192.168.122.166

web3 192.168.122.111

We 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 [ Optional ]

192.168.122.59 in

192.168.122.85 web1

192.168.122.166 web2

192.168.122.111 web3

NFS

1. Install the software

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


Guess you like

Origin blog.51cto.com/14573321/2451304