[Samba] CTDB: Failed to connect client socket to daemon.

steve steve at steve-ss.com
Sun Aug 17 03:25:31 MDT 2014


On Sat, 2014-08-16 at 19:57 +0200, Achim Gottinger wrote:
> Am 16.08.2014 19:39, schrieb steve:
> > On Sat, 2014-08-16 at 18:09 +0200, Achim Gottinger wrote:
> >> Am 16.08.2014 15:52, schrieb steve:
> >>> Ubuntu 14.04, ctdb 2.5.3, samba 4.1.11. CTDB is working with IP takeover
> >>> between the 2 nodes. The machine is joined to the domain.
> >>>
> >>> Any help with the following errors would be most gratefully received.
> >>>
> >>> 1. connect to socket error:
> >>> ctdb status
> >>> 2014/08/16 15:32:03.248034 [23255]: client/ctdb_client.c:267 Failed to
> >>> connect client socket to daemon. Errno:Connection refused(111)
> >>> common/cmdline.c:156 Failed to connect to daemon
> >> What's the output of ls -l /usr/local/var/run/ctdb/ ?
> >   ls -l /usr/local/var/run/ctdb
> > total 0
> > srwx------ 1 root root 0 ago 16 19:32 ctdbd.socket
> >
> > The socket is there and is renewed upon each ctdb (re) start. smb.conf
> > refers to the same socket.
> Guess that's ok. Maybe the log is more helpfull with CTDB_DEBUGLEVEL=4 
> (an recommendation i found on an other therad about ctdb issues).

Hi
This solves the socket problem:
/etc/default/ctdb

#CTDB_SOCKET=/usr/local/var/run/ctdb/ctdbd.socket
export CTDB_SOCKET

and indeed:
 sudo ctdb status
Number of nodes:2
pnn:0 192.168.0.10     OK (THIS NODE)
pnn:1 192.168.0.11     DISCONNECTED|UNHEALTHY|INACTIVE
Generation:635915504
Size:1
hash:0 lmaster:0
Recovery mode:NORMAL (0)
Recovery master:0

The socket appears at exactly the same place:
 ls -l /usr/local/var/run/ctdb
total 0
srwx------ 1 root root 0 ago 17 10:37 ctdbd.socket

so we've left in smb.conf:
ctdbd socket = /usr/local/var/run/ctdb/ctdbd.socket

We've enabled the event:
sudo ctdb enablescript 50.samba

and then tested it:
 sudo ctdb eventscript 50.samba
2014/08/17 11:17:17.026342 [15756]: Running eventscripts with arguments
"50.samba" on node 0
2014/08/17 11:17:17.033602 [15756]: Failed to run eventscripts - (null)

 sudo ctdb eventscript 50.samba start
2014/08/17 11:18:39.250642 [16159]: Invalid arguments

The log gives:
Aug 17 11:12:01 uc1 ctdbd: server/eventscript.c:765 Starting eventscript
monitor 
Aug 17 11:12:01 uc1 ctdbd: server/eventscript.c:388 Eventscript monitor
finished with state 0


What are the valid arguments to 50.samba?

*************
As you suggested we restored the original 50.samba script and added:
CTDB_SERVICE_SMB=smbd
to /etc/defaults/ctdb

Here is /etc/ctdb/events.d/50.samba:
#!/bin/sh
# ctdb event script for Samba

[ -n "$CTDB_BASE" ] || \
    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")

. $CTDB_BASE/functions

detect_init_style

case $CTDB_INIT_STYLE in
        suse)
                CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
                CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
                ;;
        debian)
               CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smbd}
               CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
                ;;
        *)
                # Use redhat style as default:
               CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
               CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
                ;;
esac

service_name="samba"

loadconfig

ctdb_setup_service_state_dir

service_start ()
{
    # make sure samba is not already started
echo $CTDB_SERVICE_SMB
exit 1
    service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1
    if [ -n "$CTDB_SERVICE_NMB" ] ; then
        service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
    fi
    killall -0 -q smbd && {
        sleep 1
        # make absolutely sure samba is dead
        killall -q -9 smbd
    }
    killall -0 -q nmbd && {
        sleep 1
        # make absolutely sure samba is dead
        killall -q -9 nmbd
    }

    # start Samba service. Start it reniced, as under very heavy load
    # the number of smbd processes will mean that it leaves few cycles
    # for anything else
    net serverid wipe

    if [ -n "$CTDB_SERVICE_NMB" ] ; then
        nice_service "$CTDB_SERVICE_NMB" start || die "Failed to start
nmbd"
    fi

    nice_service "$CTDB_SERVICE_SMB" start || die "Failed to start
samba"
}

service_stop ()
{
    service "$CTDB_SERVICE_SMB" stop
    if [ -n "$CTDB_SERVICE_NMB" ] ; then
        service "$CTDB_SERVICE_NMB" stop
    fi
}

######################################################################
# Show the testparm output using a cached smb.conf to avoid delays due
# to registry access.

smbconf_cache="$service_state_dir/smb.conf.cache"

testparm_foreground_update ()
{
    _timeout="$1"

    if ! _out=$(timeout $_timeout testparm -v -s 2>/dev/null) ; then
        if [ -f "$smbconf_cache" ] ; then
            echo "WARNING: smb.conf cache update failed - using old
cache file"
            return 1
        else
            die "ERROR: smb.conf cache create failed"
        fi
    fi

    _tmpfile="${smbconf_cache}.$$"
    # Patterns to exclude...
    pat='^[[:space:]]+(registry[[:space:]]+shares|include|copy|
winbind[[:space:]]+separator)[[:space:]]+='    
    echo "$_out" | grep -Ev "$pat" >"$_tmpfile"
    mv "$_tmpfile" "$smbconf_cache" # atomic

    return 0
}

testparm_background_update ()
{
    _timeout="$1"

    testparm_foreground_update $_timeout >/dev/null 2>&1 </dev/null &
}

testparm_cat ()
{
    testparm -s "$smbconf_cache" "$@" 2>/dev/null
}

list_samba_shares ()
{
    testparm_cat |
    sed -n -e 's@^[[:space:]]*path[[:space:]]*=[[:space:]]@@p' |
    sed -e 's/"//g'
}

list_samba_ports ()
{
    testparm_cat --parameter-name="smb ports" |
    sed -e 's@,@ @g'
}

###########################

ctdb_start_stop_service

is_ctdb_managed_service || exit 0

###########################

case "$1" in
     startup)
        ctdb_service_start
        ;;

     shutdown)
        ctdb_service_stop
        ;;

     monitor)
        testparm_foreground_update 10
        ret=$?

        smb_ports="$CTDB_SAMBA_CHECK_PORTS"
        if [ -z "$smb_ports" ] ; then
            smb_ports=$(list_samba_ports)
            [ -n "$smb_ports" ] || die "Failed to set smb ports"
        fi
        ctdb_check_tcp_ports $smb_ports || exit $?

        if [ "$CTDB_SAMBA_SKIP_SHARE_CHECK" != "yes" ] ; then
            list_samba_shares | ctdb_check_directories || exit $?
        fi

        if [ $ret -ne 0 ] ; then
            testparm_background_update 10
        fi
        ;;

    *)
        ctdb_standard_event_handler "$@"
        ;;
esac
exit 0




More information about the samba mailing list