Linux上搭建Samba,实现windows与Linux文件数据同步
一 環(huán)境介紹
1. 本地win10
2. Linux (centos7.4)
注:因?yàn)檫\(yùn)營(yíng)商方面禁止smb協(xié)議,導(dǎo)致無法在云服務(wù)器上使用smb,如果不是在虛擬機(jī)上操作,而是在云服務(wù)器上操作,建議還是使用 filezilla+xshell組合 或者 使用finalshell等工具來進(jìn)行Linux和Windows文件同步。
二 安裝Samba
1. 安裝samba相關(guān)的服務(wù)
yum install -y samba*
2. 查看Samba是否安裝成功
systemctl status smb
注:如果出現(xiàn)如下顯示,說明Samba安裝成功
三 配置Samba
1.? 配置Samba配置文件
1.1 備份samba配置文件
cp /etc/samba/smb.conf? /etc/samba/smb.conf.bak
1.2 編輯smb.conf , 對(duì)samba進(jìn)行配置,改為如下
[global] workgroup = WORKGROUP server string = Ted Samba Server %v netbios name = TedSamba security = user map to guest = Bad User passdb backend = tdbsam [Faraway] comment = project development directory path = /data valid users = ted write list = ted printable = no create mask = 0644 directory mask = 07552. 配置系統(tǒng)文件打開數(shù)目上限(因?yàn)楹罄m(xù)會(huì)通過samba文件打開大量文件,所以需要修改此參數(shù))
vim /etc/security/limits.conf
//文件末尾需要添加如下內(nèi)容
* soft nofile 65535
* hard nofile 65535
四? 創(chuàng)建用戶
groupadd co3 #創(chuàng)建co3組
useradd ted -g co3 -s /sbin/nologin? #添加用戶ted,并放到co3組
smbpasswd -a ted? #將ted用戶添加到smb服務(wù)中
五 賦予共享文件夾屬性
chown ted:co3 /data/
六 關(guān)閉 Selinux 和 防火墻
1.關(guān)閉Selinux
vim /etc/selinux/config? ? ? #永久關(guān)閉selinux , 將SELINUX=enforcing改為SELINUX=disabled
2.關(guān)閉firewall
systemctl stop firewalld
systemctl disable firewalld
3. 重啟系統(tǒng)
reboot
七 啟動(dòng)Samba?
systemctl stop iptables? #關(guān)閉防火墻 (雖然之前有關(guān)閉防火墻的操作,但是根據(jù)實(shí)踐表明,可能防火墻關(guān)閉的并不徹底,所以添加了這一步)
systemctl restart smb #重啟
systemctl enable smb #修改為開機(jī)啟動(dòng)
systemctl status smb #查看狀態(tài)
八 windows訪問Linux下data文件夾
1 訪問
2. 效果
3. 將Linux上的文件映射到磁盤中
鼠標(biāo)右鍵Faraway文件夾, 選擇"映射網(wǎng)絡(luò)驅(qū)動(dòng)器,選擇一個(gè)磁盤名",確定之后,我們打開我的電腦,可以看到多了一個(gè)磁盤,就是Linux映射過來的文件夾
像這樣
九 可能出現(xiàn)的問題
一 無法訪問遠(yuǎn)程samba共享文件夾
1. 重新關(guān)閉firewalld,并重啟smb
2. 進(jìn)行windows的smb配置
//管理員權(quán)限進(jìn)入cmd
//開啟SMBv1
sc.exe config lanmanworkstation depend= bowser/mrxsmb10/mrxsmb20/nsi?
sc.exe config mrxsmb10 start= auto
//關(guān)閉SMBv2 and SMBv3
sc.exe config lanmanworkstation depend= bowser/mrxsmb10/nsi?
sc.exe config mrxsmb20 start= disabled
3. 設(shè)置windows訪問來賓權(quán)限?
3.1 win+R
3.2
3.3 雙擊調(diào)整來賓登錄
https://jingyan.baidu.com/article/7c6fb428d62a6e80642c90cc.html
4. 如果到現(xiàn)在還是不行,檢查本地win10計(jì)算機(jī)登錄賬戶, 確認(rèn)切換到本地賬戶登錄
二 寫入文件用sublime可以, 用phpstorm就打不開
這時(shí),我們需要對(duì)phpstorm進(jìn)行一定的設(shè)置,如下
應(yīng)用確定之后,我們發(fā)現(xiàn),現(xiàn)在可以用phpstorm打開剛才在phpstorm中顯示不出來的遠(yuǎn)程Linux文件了
參考:
http://www.mamicode.com/info-detail-2255973.html
https://blog.csdn.net/qice675563721/article/details/74853222
總結(jié)
以上是生活随笔為你收集整理的Linux上搭建Samba,实现windows与Linux文件数据同步的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用Filezilla 与 linux远
- 下一篇: Linux中写脚本,同时去开启我们自己设