Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成。SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务。SMB协议是客户机/服务器型协议,客户机通过该协议可以访问服务器上的共享文件系统、打印机及其他资源。通过设置“NetBIOS over TCP/IP”使得Samba不但能与局域网络主机分享资源,还能与全世界的电脑分享资源。
samba属于网络附加存储NAS
例一:
server端:
[root@server0 ~]# yum install samba samba-client -y
[root@server0 ~]# mkdir /common
[root@server0 ~]# semanage fcontext -a -t samba_share_t
'/common(/.*)?'
[root@server0 ~]# restorecon -Rv /common/
[root@server0 ~]# vim /etc/samba/smb.conf
workgroup = STAFF
[common]
path = /common
browseable = yes
hosts allow = 172.25.0.0/24
[root@server0 ~]# systemctl start smb
[root@server0 ~]# systemctl start nmb
[root@server0 ~]# systemctl enable smb
[root@server0 ~]# systemctl enable nmb
[root@server0 ~]# smbpasswd -a andy
[root@server0 ~]# firewall-cmd --add-rich-rule "rule family="ipv4"
source address="172.25.0.0/24" service name="samba" accept"
[root@server0 ~]# firewall-cmd --add-rich-rule "rule family="ipv4"
source address="172.25.0.0/24" service name="samba" accept" --per
例二:
server端
[root@server0 ~]# mkdir /devops
[root@server0 ~]# semanage fcontext -a -t samba_share_t
'/devops(/.*)?'
[root@server0 ~]# restorecon -Rv /devops/
[root@server0 ~]# useradd silene
[root@server0 ~]# useradd akira
[root@server0 ~]# smbpasswd -a akira
[root@server0 ~]# smbpasswd -a silene
[root@server0 ~]# setfacl -m u:akira:rwx /devops
[root@server0 ~]# setfacl -m u:akira:rwx /devops
[root@server0 ~]# vim /etc/samba/smb.conf
[devops]
path = /devops
browseable = yes
hosts allow = 172.25.0.0/24
writable = no
write list = akira
[root@server0 ~]# systemctl restart smb
[root@server0 ~]# systemctl restart nmb
client端:
[root@desktop0 ~]# mkdir /mnt/dev
[root@desktop0 ~]# vim /etc/fstab
//server0/devops /mnt/dev cifs
defaults,multiuser,sec=ntlmssp,user=silene,pass=redhat0 0
[root@desktop0 ~]# mount -a
[root@desktop0 ~]# logout
[kiosk@foundation0 ~]$ ssh student@desktop0
[student@desktop0 ~]$ cd /mnt/dev
[student@desktop0 dev]$ cifscreds add -u akira server0
Password:
[student@desktop0 dev]$ ls
注意:启动的服务,以及启动顺序