samba 使用

在系统开发过程中,因为做了负载均衡,文件无法保存在程序的单节点中,需要使用使用独立的文件服务进行管理,调研了几个软件,samba比较适合我们的需求。

一、安装

全安装

sudo dnf install samba samba-common samba-client

客户端安装

yum install -y samba-client

查看版本号

smbd -V

编辑配置文件

vim /etc/samba/smb.conf

[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos-8
security = user
map to guest = bad user
dns proxy = no

[public]
path = /share
browsable =yes
writable = yes
guest ok = yes
read only = no

运行测试命令

testparm

启动samba

sudo systemctl start smb
sudo systemctl enable smb
systemctl restart smb
systemctl status smb

二、客户端连接

从客户端连接到 samba

smbclient //192.168.0.120/public -U root
ls //查看文件
get xxx.xxx //下载文件
put xxx.xxx //上传文件

挂载目录,在指定服务器上执行

mount -t cifs //192.168.0.120/public /share -o username=root,password=xxxxxx

umount /share

posted @ 2021-05-27 09:14  littlewrong  阅读(143)  评论(0编辑  收藏  举报