这里记录一次Samba排错,启动服务是报标题错误,查看Samba服务状态如下(防火墙和SELinux已关闭):
● smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 一 2018-11-12 09:53:47 CST; 59min ago
Process: 1341 ExecStart=/usr/sbin/smbd --foreground --no-process-group $SMBDOPTIONS (code=exited, status=1/FAILURE)
Main PID: 1341 (code=exited, status=1/FAILURE)
11月 12 09:53:47 localhost.localdomain systemd[1]: Starting Samba SMB Daemon…
11月 12 09:53:47 localhost.localdomain systemd[1]: smb.service: main process exited, code=exited, status=1/FAILURE
11月 12 09:53:47 localhost.localdomain systemd[1]: Failed to start Samba SMB Daemon.
11月 12 09:53:47 localhost.localdomain systemd[1]: Unit smb.service entered failed state.
11月 12 09:53:47 localhost.localdomain systemd[1]: smb.service failed.
在网上找了很多文章都说是配置文件的问题,将配置文件的security项的share改为user,笔者改了也没用(笔者Samba服务之前都是正常的,崩于一次网络问题),附上配置文件
vim /etc/samba/smb.conf
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775
[lee]
comment = lee
path = /home/lee/samba
browseable = yes
guest ok = yes
writeable = yes
一、首先我们可以用testparm命令来测试smb.conf配置档的合法性
[root@localhost /etc/samba] # testparm
Load smb config files from /etc/samba/smb.conf
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[lee]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions 回车
# Global parameters
[global]
printcap name = cups
security = USER
workgroup = SAMBA
idmap config * : backend = tdb
cups options = raw
[homes]
browseable = No
comment = Home Directories
inherit acls = Yes
read only = No
valid users = %S %D%w%S
[printers]
browseable = No
comment = All Printers
create mask = 0600
path = /var/tmp
printable = Yes
[print$]
comment = Printer Drivers
create mask = 0664
directory mask = 0775
force group = @printadmin
path = /var/lib/samba/drivers
write list = @printadmin root
[lee]
comment = lee
guest ok = Yes
path = /home/lee/samba
read only = No
显示配置文件没有问题
二、然后使用samba命令输出日志信息
[root@localhost ~] # smbd -F -S
smbd version 4.7.1 started.
Copyright Andrew Tridgell and the Samba Team 1992-2017
invalid permissions on directory '/var/lib/samba/lock/msg.lock': has 0777 should be 0755
显示目录权限问题应该设置成755,
[root@localhost /var/lib/samba/lock/msg.lock] # chmod -R 0755 /var/lib/samba/lock/msg.lock
照做之后继续:
[root@localhost /var/lib/samba/lock/msg.lock] # smbd -F -S
smbd version 4.7.1 started.
Copyright Andrew Tridgell and the Samba Team 1992-2017
invalid permissions on directory '/var/lib/samba/private/msg.sock': has 0777 should be 0700
还是权限问题,继续改:
[root@localhost /var/lib/samba/lock/msg.lock] # chmod -R 0700 /var/lib/samba/private/msg.sock
[root@localhost /var/lib/samba/lock/msg.lock] # smbd -F -S
smbd version 4.7.1 started.
Copyright Andrew Tridgell and the Samba Team 1992-2017
STATUS=daemon 'smbd' finished starting up and ready to serve connections
显示Samba正在启动,准备服务连接,这时候systemctl start smb发现成功了。
[root@localhost /home/lee/samba] # systemctl start smb
[root@localhost /home/lee/samba] # systemctl status smb
● smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
Active: active (running) since 一 2018-11-12 11:04:22 CST; 17s ago
Main PID: 2077 (smbd)
Status: "smbd: ready to serve connections..."
Memory: 4.3M
CGroup: /system.slice/smb.service
├─2077 /usr/sbin/smbd --foreground --no-process-group
├─2079 /usr/sbin/smbd --foreground --no-process-group
├─2080 /usr/sbin/smbd --foreground --no-process-group
└─2081 /usr/sbin/smbd --foreground --no-process-group
11月 12 11:04:22 localhost.localdomain systemd[1]: Starting Samba SMB Daemon...
11月 12 11:04:22 localhost.localdomain smbd[2077]: [2018/11/12 11:04:22.632400, 0] ../lib/util/become_daemon.c:124(daemon_ready)
11月 12 11:04:22 localhost.localdomain smbd[2077]: STATUS=daemon 'smbd' finished starting up and ready to serve connections
11月 12 11:04:22 localhost.localdomain systemd[1]: Started Samba SMB Daemon.
然后从windows访问samba共享目录,无论使用自己创建的samba用户还是root用户都提示用户名密码错误使用:smbpasswd命令:
#smbpasswd -a samba
#passwd samba,然后从新登陆成功。
#smbpasswd -a 增加用户(要增加的用户必须以是系统用户)
#smbpasswd -d 冻结用户,就是这个用户不能在登录了
#smbpasswd -e 恢复用户,解冻用户,让冻结的用户可以在使用
#smbpasswd -n 把用户的密码设置成空.