我已经samba 4.8
在 Ubuntu xenial 上从源代码进行了编译,但无法启动它。
按照 samba.org 的说明,我找到/usr/local/samba/sbin
了/usr/local/samba/bin
可执行文件,在卸载4.3
电脑上的旧版本之前,我保存了/etc/init.d/smbd
文件以使其正常工作。但即使在更改 init.d 文件中二进制文件的位置后,它仍然不起作用。
如果我运行 /etc/init.d/smbd start 我会得到以下结果
[....] Starting smbd (via systemctl): smbd.serviceJob for smbd.service failed because the control process exited with error code. See "systemctl status smbd.service" and "journalctl -xe" for details.
failed!
这是 journalctl -xe 的输出
-- i servizi attivati sono in fase di completamento.
--
-- L'avvio del kernel ha richiesto KERNEL_USEC microsecondi.
--
-- L'avvio del disco RAM ha richiesto INITRD_USEC microsecondi.
--
-- L'avvio dello userspace ha richiesto 24776 microsecondi.
mar 26 23:18:12 apollo systemd[1]: Started User Manager for UID 1001.
-- Subject: L'unità [email protected] termina la fase di avvio
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- L'unità [email protected] ha terminato la fase di avvio.
--
-- La fase di avvio è done.
mar 26 23:18:30 apollo sudo[11809]: pam_unix(sudo:session): session closed for user root
mar 26 23:18:46 apollo sudo[11913]: francesco : TTY=pts/1 ; PWD=/home/francesco ; USER=root ; COMMAND=/bin/nano /lib/systemd/system/smbd.service
mar 26 23:18:46 apollo sudo[11913]: pam_unix(sudo:session): session opened for user root by francesco(uid=0)
mar 26 23:19:03 apollo sudo[11913]: pam_unix(sudo:session): session closed for user root
mar 26 23:19:06 apollo sudo[11929]: francesco : TTY=pts/1 ; PWD=/home/francesco ; USER=root ; COMMAND=/etc/init.d/smbd start
mar 26 23:19:06 apollo sudo[11929]: pam_unix(sudo:session): session opened for user root by francesco(uid=0)
mar 26 23:19:06 apollo systemd[1]: Starting Samba SMB/CIFS server...
-- Subject: L'unità smbd.service inizia la fase di avvio
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- L'unità smbd.service ha iniziato la fase di avvio.
mar 26 23:19:06 apollo systemd[1]: smbd.service: Control process exited, code=exited status=1
mar 26 23:19:06 apollo systemd[1]: Failed to start Samba SMB/CIFS server.
-- Subject: L'unità smbd.service è fallita
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- L'unità smbd.service è fallita.
--
-- Il risultato è failed.
mar 26 23:19:06 apollo systemd[1]: smbd.service: Unit entered failed state.
mar 26 23:19:06 apollo systemd[1]: smbd.service: Failed with result 'exit-code'.
mar 26 23:19:06 apollo sudo[11929]: pam_unix(sudo:session): session closed for user root
抱歉,信息是意大利语,但重要的是英语。
这是 init.d 脚本
#!/bin/sh
### BEGIN INIT INFO
# Provides: smbd
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: slapd cups
# Should-Stop: slapd cups
# Short-Description: start Samba SMB/CIFS daemon (smbd)
### END INIT INFO
PIDDIR=/var/run/samba
SMBDPID=$PIDDIR/smbd.pid
# clear conflicting settings from the environment
unset TMPDIR
# See if the daemons are there
test -x /usr/local/samba/sbin/smbd || exit 0
. /lib/lsb/init-functions
case $1 in
start)
if init_is_upstart; then
exit 1
fi
SERVER_ROLE=`samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1`
if [ "$SERVER_ROLE" = "active directory domain controller" ]; then
exit 0
fi
log_daemon_msg "Starting SMB/CIFS daemon" smbd
# Make sure we have our PIDDIR, even if it's on a tmpfs
install -o root -g root -m 755 -d $PIDDIR
if ! start-stop-daemon --start --quiet --oknodo --exec /usr/local/samba/sbin/smbd -- -D; then
log_end_msg 1
exit 1
fi
log_end_msg 0
;;
stop)
if init_is_upstart; then
exit 0
fi
log_daemon_msg "Stopping SMB/CIFS daemon" smbd
start-stop-daemon --stop --quiet --pidfile $SMBDPID
# Wait a little and remove stale PID file
sleep 1
if [ -f $SMBDPID ] && ! ps h `cat $SMBDPID` > /dev/null
then
# Stale PID file, remove it (should be removed by
# smbd itself IMHO).
rm -f $SMBDPID
fi
log_end_msg 0
;;
reload)
log_daemon_msg "Reloading /etc/samba/smb.conf" smbd
start-stop-daemon --stop --quiet --signal HUP --pidfile $SMBDPID
log_end_msg 0
;;
restart|force-reload)
if init_is_upstart; then
exit 1
fi
$0 stop
sleep 1
$0 start
;;
status)
status_of_proc -p $SMBDPID /usr/local/samba/sbin/smbd smbd
exit $?
;;
*)
echo "Usage: /etc/init.d/smbd {start|stop|reload|restart|force-reload|status}"
exit 1
;;
esac
exit 0
这是 smbd.service
[Unit]
Description=Samba SMB/CIFS server
After=network.target nmbd.service winbindd.service
[Service]
Type=forking
ExecStart=/usr/local/samba/sbin/smbd -D
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
PIDDIR 和 SMBPID 重要吗?
即使我运行,sudo /usr/local/samba/sbin/smbd -D
我仍然什么也没有得到,没有错误,也没有 smb 出现在ps aux | grep smb
答案1
经过一些测试,主要是运行sudo smbd -FS
以将输出显示为 stdout,我发现位于的可执行文件/usr/local/samba/sbin
没有加载/etc/samba/smb.conf
文件,而是/usr/local/samba/etc/smb.conf
。在预期位置复制默认文件后,一切都开始正常工作。
可能是我漏掉了一个配置标志。希望它能帮助遇到同样问题的人。
此外,由于从源安装过程无法执行此操作,因此我必须添加文件smb.service
夹/etc/avahi/services/
才能正确进行宣传。
我仍在研究如何让它出现在 Windows 的网络中,但通过 \ip.add.re.ss 连接它可以工作,并且在 Mac 上它可以正确显示。