共享存储nfs=network file system

安装:RPC协议

yum install rpcbind nfs-utils –y

[root@bogon ~]# rpm -qa | grep rpcbind

rpcbind-0.2.0-42.el7.x86_64

[root@bogon ~]# rpm -qa | grep nfs-utils

nfs-utils-1.3.0-0.48.el7_4.x86_64

[root@bogon /]# mkdir /share

[root@bogon /]# touch /share/share.txt

[root@bogon /]# echo gongxiang > /share/share.txt

[root@bogon /]#

修改配置文件

[root@bogon /]# vim /etc/exports

输入(要求192.168.88.0-24端的都可以访问)

/share 192.168.88.0/24(rw,sync,fsid=0)

配置生效

[root@bogon share]# exportfs -r

开权限:别同组和别人都有读写执行权限

[root@bogon /]# ll -d /share

drwxr-xr-x. 2 root root 23 11月 19 09:34 /share

[root@bogon /]# chmod -R o+rw /share

[root@bogon /]# ll -d /share

drwxr-xrwx. 2 root root 23 11月 19 09:34 /share

[root@bogon /]# chmod -R g+w /share

[root@bogon /]# ll -d /share

drwxrwxrwx. 2 root root 23 11月 19 09:34 /share

[root@bogon /]#

启动服务:

先设置开机启动

[root@bogon /]# systemctl start rpcbind.service

[root@bogon /]# systemctl start nfs-server.service

启动服务:

[root@bogon /]# systemctl enable rpcbind.service

[root@bogon /]# systemctl enable nfs-server.service

看看是否启动成功:

[root@bogon /]# systemctl status rpcbind.service

[root@bogon /]# systemctl status nfs-server.service

看看是否共享成功

[root@bogon share]# exportfs

/share              192.168.88.0/24

[root@bogon share]# showmount -e

Export list for bogon:

/share 192.168.88.0/24

[root@bogon share]#

去别的客户端(虚拟机)查看共享情况

[root@bogon ~]# showmount -e 192.168.88.128

Export list for 192.168.88.128:

/share 192.168.88.0/24

把别人共享的目录挂载到自己的文件夹中:

[root@bogon ~]# mount -t nfs 192.168.88.128:/share /var/www/html

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

share.txt

[root@bogon ~]# df

文件系统                 1K-块    已用     可用 已用% 挂载点

/dev/sda3             18351104 4764024 13587080   26% /

devtmpfs                227104       0   227104    0% /dev

tmpfs                   241808       0   241808    0% /dev/shm

tmpfs                   241808   13336   228472    6% /run

tmpfs                   241808       0   241808    0% /sys/fs/cgroup

/dev/sda1               508580  154404   354176   31% /boot

tmpfs                    48364       4    48360    1% /run/user/42

tmpfs                    48364      28    48336    1% /run/user/0

/dev/sr0               8490330 8490330        0  100% /run/media/root/CentOS 7 x86_64

192.168.88.128:/share  4183040   32896  4150144    1% /var/www/html

[root@bogon ~]#

职员A输入系统后,系统要同步更新,所以下面的命令需要sync表示,当职员B打开系统时,可以看到最新的信息。

 

跨存储:把自己的文件夹共享出去

对象存储:把本地的文件放到网上,自己无法在网上修改文件,要先下载,修改后,覆盖原来的

文件存储:一切皆文件,文件就是读和写

配IP地址:

先输入ifconfig,知道网卡名是:ens33

[root@bogon ~]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.88.128  netmask 255.255.255.0  broadcast 192.168.88.255

得到临时配IP地址命令:

ifconfig ens33 192.168.88.128

在另外两台也分别配IP:

ifconfig ens33 192.168.88.131

ifconfig ens33 192.168.88.132

原文地址:https://www.cnblogs.com/jensenxie/p/7860834.html