二个文件储存服务 nfs|samba

NFS

文件传输服务
nfs 实现文件之间的共享 只需要在nfs服务端创建文件 client自动会接受到该文件
nfs network files system 网络文件传输系统
/share ---- nfs类型
nfs – rpc-bind 传输文件 两个服务同时存在 才能共享文件
安装nfs服务
本身自带

[root@localhost httpd]# rpm -qa nfs-utils
nfs-utils-1.3.0-0.68.el7.x86_64
[root@localhost httpd]# rpm -qa rpcbind
rpcbind-0.2.0-49.el7.x86_64

如果不存在 yum -y install nfs-utils rpcbind 安装即可
第一台 1.11 服务端
第二台 1.100 客户端

服务端:

创建共享目录

[root@localhost ~]# mkdir /share

更改nfs的主配置文件

[root@localhost ~]# vim /etc/exports 
/share *(rw)       #写一个就可以   所有主机
/share 192.168.1.0/24(rw)    1网段的主机
/share 192.168.1.100(rw)     1.100这个ip的主机 
[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# systemctl restart nfs
[root@localhost ~]# showmount -e localhost  查看共享目录
Export list for localhost:
/share *

客户端

查看共享目录

[root@localhost ~]# showmount -e 192.168.1.11  
Export list for 192.168.1.11:
/share *
[root@localhost ~]# mkdir /client    #创建客户端目录
[root@localhost ~]# mount -t nfs 192.168.1.11:/share  /client    挂载目录 

验证

服务端创建数据
[root@localhost ~]# cd /share
[root@localhost share]# touch aa
[root@localhost share]# ls
aa
客户端:
[root@localhost ~]# cd /client/
[root@localhost client]# ls
aa
自动挂载
[root@localhost client]# vim /etc/fstab 
192.168.1.11:/share     /client    nfs         defaults 0 0
[root@localhost client]# mount -a  刷新mount

SAMBA

第一台 192.168.1.11
第二台 192.168.1.100
samba: 使用smb协议的应用程序 主要用于文件共享 nfs实现同系统之间的共享 linux – linux samba服务实现的是不同系统 linux—windows 使用tcp或者udp来传输的 采用c/s架构
samba 挂载 自动挂载 文件系统类型 cifs
samba里面包含两个程序: smbd为client提供共享资源 ————nmbd负责主机之间的主机名解析
samba作用:
1.可以做存储
2.可以进行文件共享(不同系统之间的共享)

1.匿名用户共享

server 192.168.1.11
client 192.168.1.100

server 安装samba

[root@localhost ~]# yum -y install samba  samba-client
[root@localhost ~]# mkdir /samba
[root@localhost ~]# vim /etc/samba/smb.conf
 6 [global]  #对于全局配置
 7         workgroup = SAMBA    #工作组
 8         security = user    #用户级别    用户名和密码共享
  9         map to guest = Bad user    #支持匿名用户共享
38 [pub]    #共享目录在配置文件中名称    用户挂载
 39         comment = pub   #详细说明
 40         path = /samba     #实际的目录
 41         public = yes   #公开的
 42         writable = yes   #可写的权限
 43         browseable = yes   #可读的权限
[root@localhost ~]# systemctl restart smb
[root@localhost ~]# smbclient -L localhost
Enter SAMBA\root's password: 
	pub             Disk      pub

客户端

[root@localhost ~]# rpm -q samba-client
samba-client-4.7.1-6.el7.x86_64
[root@localhost ~]# rpm -q cifs-utils
cifs-utils-6.2-10.el7.x86_64
[root@localhost ~]# smbclient -L 192.168.1.11
	pub             Disk      pub
[root@localhost ~]# mkdir /client
[root@localhost ~]# mount -t cifs //192.168.1.11/pub /client -o guest

验证

验证:
服务端创建数据
[root@localhost ~]# cd /samba/
[root@localhost samba]# touch haha
[root@localhost samba]# ls
haha
[root@localhost samba]# setenforce 0
client查看
[root@localhost ~]# ls /client/
haha

本地用户共享

服务端:

[root@localhost ~]# mkdir /samba-share
[root@localhost ~]# vim /etc/samba/smb.conf
 9         #map to guest = Bad user
44 [public]
 45         comment = public
 46         path = /samba-share
 47         public = no
 48         writable = yes
 49         browseable = yes
创建一个本地用户   本地用户添加samba服务
[root@localhost ~]# useradd test
[root@localhost ~]# smbpasswd -a test
New SMB password:
Retype new SMB password:
[root@localhost ~]# systemctl restart smb
[root@localhost ~]# smbclient -L localhost -U test
	public          Disk      public

客户端

[root@localhost ~]# smbclient -L 192.168.1.11 -U test
[root@localhost ~]# mount -t cifs //192.168.1.11/public /samba-client -o user=test,password=123.com

验证

服务端创建数据
[root@localhost ~]# cd /samba-share/
[root@localhost samba-share]# touch haha
[root@localhost samba-share]# ls
haha
客户端查看
[root@localhost ~]# cd /samba-client/
[root@localhost samba-client]# ls
haha
[root@localhost samba-client]# vim /etc/fstab
//192.168.1.11/public  /samba-client   cifs  defaults,user=test,password=123.com  0 0
//192.168.1.11/pub    /client          cifs  defaults,guest 0 0
[root@localhost samba-client]# mount -a

windows+linux系统之间的共享

服务端:

[root@localhost ~]# mkdir /data
[root@localhost ~]# vim /etc/samba/smb.conf
[aa]
        comment = aa
        path = /data
        valid users = aa
        write list = aa
        public = no
        create mask = 0644
        directory mask = 0755
[root@localhost ~]# useradd aa
[root@localhost ~]# smbpasswd -a aa
New SMB password:
Retype new SMB password:
Added user aa.
[root@localhost ~]# chown aa:aa /data/
[root@localhost ~]# systemctl restart smb

windows物理机
客户端
网络 ----搜索 ----\192.168.1.11 samba的ip------aa----123.com—确定

验证:
[root@localhost ~]# cd /data/
[root@localhost data]# touch 1

验证
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值