[Samba] Managing samba ad dc with systemd

L.P.H. van Belle belle at bazuin.nl
Fri Apr 26 07:19:47 UTC 2019


Hai Igor,

No, that not normal, and this is and old bug in the start/stop. 
Entered after samba started to use preforking i believe. 

See the Unit setup below. 
Note, i added bind9.service here, because i use bind and i want bind to start before samba-ad.
Just keep it there, if you change you samba to samba+bind_dlz, then you services are starting in the correct order. 

This part: 
# systemctl mask smbd nmbd winbind 
# systemctl disable smbd nmbd winbind 

That should be fine, but if there are left overs from a packages install, you might notice that. 
Then check also if samba.service exist, if so, remove it, not used anymore. 

smbd nmbd winbind samba-ad

As you see i've added bind9.service also to After, that is, if you want/are useing bind9_dlz with samba
Than bind needs to start before samba, just keep it there it wont hurt anything.

So for you i suggest this systemd setup.
If you can verify it, i'll make some changes in the wiki. 


#/etc/systemd/system/samba-ad-dc.service
[Unit]
Description=Samba AD Daemon
Wants=network-online.target
After=network.target network-online.target bind9.service

[Service]
Type=notify
NotifyAccess=all
ExecStart=/usr/local/samba/sbin/samba -D
PIDFile=/usr/local/samba/var/run/samba.pid
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

After the change

systemctl daemon-reload
systemctl stop samba-ad-dc
systemctl start samba-ad-dc


Greetz, 

Louis

> -----Oorspronkelijk bericht-----
> Van: samba [mailto:samba-bounces at lists.samba.org] Namens Igor 
> Sousa via samba
> Verzonden: donderdag 25 april 2019 23:32
> Aan: samba at lists.samba.org
> Onderwerp: [Samba] Managing samba ad dc with systemd
> 
> Hi,
> 
> I have a question about samba 4 with systemd. I've followed 
> the "Managing
> the Samba AD DC Service Using Systemd" and I've created
> /etc/systemd/system/samba-ad-dc.service file with the 
> following content:
> 
> [Unit]
> Description=Samba Active Directory Domain Controller
> After=network.target remote-fs.target nss-lookup.target
> 
> [Service]
> Type=forking
> ExecStart=/usr/local/samba/sbin/samba -D
> PIDFile=/usr/local/samba/var/run/samba.pid
> ExecReload=/bin/kill -HUP $MAINPID
> 
> [Install]
> WantedBy=multi-user.target
> 
> 
> I've created a mask to smbd, nmbd and winbind and I've disabled them
> following this command: # systemctl mask smbd nmbd winbind # systemctl
> disable smbd nmbd winbind. But, when I've use systemctl stop 
> samba-ad-dc to
> stop samba, the status shown is "failed" with code=exited and 
> status=127.
> 
> Is it normal behavior?
> 
> [root at king ~]# systemctl stop samba-ad-dc
> [root at king ~]# systemctl status samba-ad-dc
> ??? samba-ad-dc.service - Samba Active Directory Domain Controller
>    Loaded: loaded (/etc/systemd/system/samba-ad-dc.service; disabled;
> vendor preset: disabled)
>    Active: failed (Result: exit-code) since Thu 2019-04-25 
> 17:05:26 -03;
> 10min ago
>   Process: 4937 ExecStart=/usr/local/samba/sbin/samba -D (code=exited,
> status=0/SUCCESS)
>  Main PID: 4938 (code=exited, status=127)
> 
> Apr 25 17:05:19 king smbd[4944]:   daemon_ready: daemon 
> 'smbd' finished
> starting up and ready to serve connections
> Apr 25 17:05:19 king winbindd[4954]: [2019/04/25 17:05:19.918759,  0]
> ../../source3/winbindd/winbindd_cache.c:3165(initialize_win...d_cache)
> Apr 25 17:05:19 king winbindd[4954]:   
> initialize_winbindd_cache: clearing
> cache and re-creating with version number 2
> Apr 25 17:05:19 king winbindd[4954]: [2019/04/25 17:05:19.939054,  0]
> ../../lib/util/become_daemon.c:136(daemon_ready)
> Apr 25 17:05:19 king winbindd[4954]:   daemon_ready: daemon 'winbindd'
> finished starting up and ready to serve connections
> Apr 25 17:05:25 king systemd[1]: Stopping Samba Active 
> Directory Domain
> Controller...
> Apr 25 17:05:25 king systemd[1]: samba-ad-dc.service: main 
> process exited,
> code=exited, status=127/n/a
> Apr 25 17:05:26 king systemd[1]: Stopped Samba Active Directory Domain
> Controller.
> Apr 25 17:05:26 king systemd[1]: Unit samba-ad-dc.service 
> entered failed
> state.
> Apr 25 17:05:26 king systemd[1]: samba-ad-dc.service failed.
> Hint: Some lines were ellipsized, use -l to show in full.
> 
> 
> (
> https://wiki.samba.org/index.php/Managing_the_Samba_AD_DC_Serv
> ice_Using_Systemd
> )
> 
> --
> Igor Sousa
> -- 
> To unsubscribe from this list go to the following URL and read the
> instructions:  https://lists.samba.org/mailman/options/samba
> 
> 




More information about the samba mailing list