Cloud Computing Learning Route course syllabus Courseware: about NFS
Cloud Computing Learning Route Tutorial Outline Coursera: About NFS
Importance index 4 stars
Project name: Configuring backend storage for Web Server in cluster
NFS: Network File System, a protocol for sharing files between Unix systems
NFS clients are primarily Linux
Supports simultaneous mounting and concurrent writing of multiple nodes
========================================================
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/configsetenforce 0
centos6
iptables -Fservice iptables save
centos7
systemctl stop firewalldsystemctl disable firewalldvim /etc/hosts [optional]
192.168.122.59 nas
192.168.122.85 web1
192.168.122.166 web2
192.168.122.111 web3
NFS
1. install software
yum -y install nfs-utils (main package provides file system)
yum -y install rpcbind (provides rpc protocol)
2. Start Services-----> Both services must be enabled at the same time
systemctl start nfs
systemctl start rpcbind
NAS (Storage)
[root@nas ~]# yum -y install nfs-utils
[root@nas ~]# mkdir /webdata //Store website code!
[root@nas ~]# echo "nfs test... " > /webdata/index.html
[root@nas ~]# vim /etc/exports
/webdata 192.168.122.0/24(rw,sync,no_root_squash) //do not suppress root(when the client uses root mount, it also has root privileges) mount root, and also maintain root privileges
[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 Web 2 Web3 Client
Take web1 for example:
[root@web1 ~]# yum -y install nfs-utils httpd
[root@web1 ~]# systemctl start httpd
[root@web1 ~]# systemctl enable httpd
httpd
View storage-side shares [optional]
[root@web1 ~]# showmount -e nas
Export list for nas:
/webdata 192.168.122.0/24
ps -ef | grep nfs
Manual mount [optional]
[root@web1 ~]# mount -t nfs nas:/webdata /var/www/html/
[root@web1 ~]# umount /var/www/html/
Automatically mount to website home directory
[root@web1 ~]# vim /etc/fstab
nas:/webdata /var/www/html nfs defaults 0 0
[root@web1 ~]# mount -a
View mount
[root@web1 ~]# df
nas:/webdata 7923136 692416 6821568 10% /var/www/html
[root@web1 ~]# ls /var/www/html/
index.html
web2 web3 as above
Third, test website visit
firefox 192.168.122.85firefox 192.168.122.111firefox 192.168.122.166