Cloud Computing Learning Route sharing for good programmers: about NFS
Cloud Computing Learning Route sharing for good programmers: about NFS
Project name: configure back-end storage for Web Server in the cluster
NFS:Network File System network file system, a protocol for sharing files between Unix systems
The client of NFS is mainly Linux.
Support simultaneous mounting of multiple nodes and concurrent writing
=
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 [optional]
192.168.122.59 nas
192.168.122.85 web1
192.168.122.166 web2
192.168.122.111 web3
NFS
1. Install softwar
Yum-y install nfs-utils (file system provided by the main package)
Yum-y install rpcbind (provides rpc protocol)
two。 Start services-> both services must be enabled at the same time
Systemctl start nfs
Systemctl start rpcbind
1. Nas (storage side)
[root@nas ~] # yum-y install nfs-utils
[root@nas ~] # mkdir / webdata / / Storage website code!
[root@nas ~] # echo "nfs test..." > / webdata/index.html
[root@nas ~] # vim / etc/exports
/ webdata 192.168.122.0 root 24 (rw,sync,no_root_squash) / / do not suppress root (when the client uses root to mount, it also has root permission) Mount root, and also maintain root permission
[root@nas ~] # systemctl start nfs-server
[root@nas ~] # systemctl enable nfs-server
[root@nas] # exportfs-v
/ webdata 192.168.122.0 take 24 (rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
His
II. Web1 web2 web3 client
Take web1 as an example:
[root@web1 ~] # yum-y install nfs-utils httpd
[root@web1 ~] # systemctl start httpd
[root@web1 ~] # systemctl enable httpd
Httpd
1. View storage side shares [optional]
[root@web1] # showmount-e nas
Export list for nas:
/ webdata 192.168.122.0/24
Ps-ef | grep nfs
two。 Manual mount [optional]
[root@web1] # mount-t nfs nas:/webdata / var/www/html/
[root@web1 ~] # umount / var/www/html/
3. Automatically mount to the home directory of the website
[root@web1 ~] # vim / etc/fstab
Nas:/webdata / var/www/html nfs defaults 0 0
[root@web1] # mount-a
4. View mount
[root@web1 ~] # df
Nas:/webdata 7923136 692416 6821568 10% / var/www/html
[root@web1 ~] # ls / var/www/html/
Index.html
5. Web2 web3 ditto
Third, test website access
# firefox 192.168.122.85
# firefox 192.168.122.111
# firefox 192.168.122.166