一、搭建NFS服务器
1.配置服务并启动
[root@LY ~]# systemctl stop firewalld
[root@LY ~]# setenforce 0
[root@LY ~]# yum install -y nfs
[root@LY ~]# yum install -y rpcbind
[root@LY ~]# systemctl start rpcbind.service
[root@LY ~]# systemctl start rpcbind
[root@LY ~]# systemctl start nfs
验证是否启动
[root@LY ~]# netstat -nltp|grep rpcbind
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 4269/rpcbind
tcp6 0 0 :::111 :::* LISTEN 4269/rpcbind
2.服务端创建好文件,做好相关的配置
[root@LY ~]# mkdir -p /share/nfs
[root@LY ~]# touch /share/nfs/file{1..5}
[root@LY ~]# vim /etc/exports
[root@LY ~]# cat /etc/exports
/share/nfs *
3.客户端挂载文件目录
[root@client ~]# systemctl stop firewalld.service
[root@client ~]# setenforce 0
[root@client ~]# mkdir /u01 //创建一个空目录
[root@client ~]# mount.nfs 192.168.93.129:/share/nfs /u01/
服务端的ip 共享的目录 挂载至本地的目录
[root@client ~]# cd /u01
[root@client u01]# ls
file1 file2 file3 file4 file5
需求1:以读写的方式将/share/nfs下的文件共分享给所有人
[root@LY ~]# chmod o+w /share/nfs/
[root@LY ~]# cat /etc/exports
/share/nfs *(rw)
/share/nfs 192.168.93.0/24(rw)
[root@LY ~]# systemctl restart nfs.service
需求2:访问web中的内容
服务端配置
创建共享目录
[root@LY ~]# mkdir -p /share/web
写入页面的内容
[root@LY ~]# echo "hello world" > /share/web/index.html
在配置中写入共享的目录及用户
[root@LY ~]# cat /etc/exports
/share/nfs *(rw)
/share/web *(ro)
[root@LY ~]# systemctl restart nfs
客户端配置
[root@client ~]# mount.nfs 192.168.93.129:/share/web /var/www/h
tml/
[root@client ~]# systemctl start httpd
结果验证
二、搭建Samba服务器
1.安装Samba
[root@Server ~]# yum install -y samba
2.创建一个本地用户,并将其加入到smb数据库中
[root@Server ~]# useradd haha
[root@Server ~]# smbpasswd -a haha
New SMB password:
Retype new SMB password:
Added user haha.
3.在”此电脑“中输入服务器的Ip即可