搭建NFS服务器和Samba服务器

一、搭建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即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值