mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
Enable compilation of the load balancer as a module
To compile the balancer as a slapd module, pass --enable-balancer=mod to ./configure Use --enable-balancer(=yes) to compile as standalone server.
This commit is contained in:
parent
8bc7650a7c
commit
37cd5f21d5
8 changed files with 310 additions and 37 deletions
27
configure.ac
27
configure.ac
|
|
@ -414,7 +414,8 @@ dnl ----------------------------------------------------------------
|
|||
dnl BALANCER OPTIONS
|
||||
AC_ARG_ENABLE(balanceroptions,[
|
||||
LLOADD (Load Balancer Daemon) Options:])
|
||||
OL_ARG_ENABLE(balancer,[ --enable-balancer enable building load balancer], auto)dnl
|
||||
OL_ARG_ENABLE(balancer, [AS_HELP_STRING([--enable-balancer], [enable load balancer])],
|
||||
no, [no yes mod])
|
||||
|
||||
dnl ----------------------------------------------------------------
|
||||
AC_ARG_ENABLE(xxliboptions,[
|
||||
|
|
@ -445,13 +446,18 @@ if test $ol_enable_slapd = no ; then
|
|||
eval "ol_enable_$i=no"
|
||||
fi
|
||||
done
|
||||
|
||||
if test $ol_enable_balancer = mod ; then
|
||||
AC_MSG_WARN([slapd disabled, ignoring --enable-balancer=mod argument])
|
||||
ol_enable_balancer=no
|
||||
fi
|
||||
else
|
||||
dnl If slapd enabled and loadable module support disabled
|
||||
dnl then require at least one built-in backend
|
||||
|
||||
if test $ol_enable_modules = no; then
|
||||
|
||||
for i in backends overlays $Backends $Overlays; do
|
||||
for i in backends overlays balancer $Backends $Overlays; do
|
||||
eval "ol_tmp=\$ol_enable_$i"
|
||||
if test -n "$ol_tmp" && test "$ol_tmp" = mod ; then
|
||||
AC_MSG_ERROR([--enable-$i=mod requires --enable-modules])
|
||||
|
|
@ -487,7 +493,7 @@ if test $ol_enable_modules = yes ; then
|
|||
ol_enable_dynamic=yes
|
||||
fi
|
||||
|
||||
if test $ol_enable_balancer = yes ; then
|
||||
if test $ol_enable_balancer != no ; then
|
||||
dnl Load Balancer was specifically enabled
|
||||
if test $ol_with_threads = no ; then
|
||||
AC_MSG_ERROR([Load balancer requires threads])
|
||||
|
|
@ -524,6 +530,7 @@ CLIENT_LIBS=
|
|||
|
||||
SLAPD_LIBS=
|
||||
BALANCER_LIBS=
|
||||
BALANCER_INCLUDE=
|
||||
|
||||
BUILD_SLAPD=no
|
||||
BUILD_BALANCER=no
|
||||
|
|
@ -2967,7 +2974,13 @@ fi
|
|||
if test "$ol_enable_balancer" != no \
|
||||
-a "$ol_with_threads" != no \
|
||||
-a "$have_libevent" = yes ; then
|
||||
BUILD_BALANCER=yes
|
||||
if test "$ol_enable_balancer" = mod; then
|
||||
BALANCER_INCLUDE=Makefile.module
|
||||
BUILD_BALANCER=mod
|
||||
else
|
||||
BALANCER_INCLUDE=Makefile.server
|
||||
BUILD_BALANCER=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ol_enable_slapi" != no ; then
|
||||
|
|
@ -3088,6 +3101,8 @@ AC_SUBST(SLAPD_SQL_INCLUDES)
|
|||
AC_SUBST(WT_INCS)
|
||||
AC_SUBST(WT_LIBS)
|
||||
|
||||
AC_SUBST(BALANCER_INCLUDE)
|
||||
|
||||
dnl ----------------------------------------------------------------
|
||||
dnl final help output
|
||||
AC_ARG_WITH(xxinstall,[
|
||||
|
|
@ -3134,7 +3149,9 @@ AC_CONFIG_FILES([Makefile:build/top.mk:Makefile.in:build/dir.mk]
|
|||
[servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk]
|
||||
[servers/slapd/slapi/Makefile:build/top.mk:servers/slapd/slapi/Makefile.in:build/lib.mk:build/lib-shared.mk]
|
||||
[servers/slapd/overlays/Makefile:build/top.mk:servers/slapd/overlays/Makefile.in:build/lib.mk]
|
||||
[servers/lloadd/Makefile:build/top.mk:servers/lloadd/Makefile.in:build/srv.mk]
|
||||
[servers/lloadd/Makefile:build/top.mk:servers/lloadd/Makefile.in]
|
||||
[servers/lloadd/Makefile.server:servers/lloadd/Makefile_server.in:build/srv.mk]
|
||||
[servers/lloadd/Makefile.module:servers/lloadd/Makefile_module.in:build/mod.mk]
|
||||
[tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk]
|
||||
[tests/run]
|
||||
[tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk])
|
||||
|
|
|
|||
|
|
@ -215,6 +215,41 @@ This allows one to specifically query the SLP DAs for LDAP servers holding the
|
|||
.I production
|
||||
tree in case multiple trees are available.
|
||||
.RE
|
||||
|
||||
.SH RELATION TO SLAPD(8)
|
||||
.B Lloadd
|
||||
can be compiled as a
|
||||
.B slapd
|
||||
loadable module. In that case, it can be loaded as such:
|
||||
.LP
|
||||
.nf
|
||||
.ft tt
|
||||
moduleload path/to/lloadd.la lloadd.conf "listening URLs"
|
||||
.ft
|
||||
.fi
|
||||
|
||||
This enables
|
||||
.B lloadd
|
||||
to provide additional features through the host slapd process like access to
|
||||
run-time statistics in
|
||||
.B cn=monitor
|
||||
and dynamic configuration from
|
||||
.BR cn=config .
|
||||
|
||||
The listening sockets specified will be under direct control of
|
||||
.B lloadd
|
||||
and need to be different from the sockets slapd is configured to listen on.
|
||||
Clients connecting to these are completely separate from regular LDAP clients
|
||||
connecting to the usual
|
||||
.B slapd
|
||||
sockets -
|
||||
.B lloadd
|
||||
clients have no access to slapd databases, similarly,
|
||||
.B slapd
|
||||
client traffic does not propagate to the
|
||||
.B lloadd
|
||||
backend servers in any way.
|
||||
|
||||
.SH EXAMPLES
|
||||
To start
|
||||
.I lloadd
|
||||
|
|
@ -237,9 +272,22 @@ on voluminous debugging which will be printed on standard error, type:
|
|||
LIBEXECDIR/lloadd \-f /var/tmp/lloadd.conf \-d 255
|
||||
.ft
|
||||
.fi
|
||||
.LP
|
||||
To start
|
||||
.B lloadd
|
||||
as a module inside a slapd process listening on ldap://:1389 and ldaps://,
|
||||
put the following in your slapd.conf (or its equivalent in cn=config):
|
||||
.LP
|
||||
.nf
|
||||
.ft tt
|
||||
moduleload lloadd.la /var/tmp/lloadd.conf "ldap://:1389 ldaps://"
|
||||
.ft
|
||||
.fi
|
||||
.SH "SEE ALSO"
|
||||
.BR ldap (3),
|
||||
.BR lloadd.conf (5),
|
||||
.BR slapd-config (5),
|
||||
.BR slapd-monitor (5),
|
||||
.BR slapd (8).
|
||||
.LP
|
||||
"OpenLDAP Administrator's Guide" (http://www.OpenLDAP.org/doc/admin/)
|
||||
|
|
|
|||
|
|
@ -13,28 +13,21 @@
|
|||
## top-level directory of the distribution or, alternatively, at
|
||||
## <http://www.OpenLDAP.org/license.html>.
|
||||
|
||||
PROGRAMS = lloadd
|
||||
XPROGRAMS = slloadd
|
||||
|
||||
XSRCS = version.c
|
||||
|
||||
NT_SRCS = nt_svc.c
|
||||
NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
|
||||
|
||||
SRCS = main.c globals.c backend.c bind.c config.c connection.c client.c \
|
||||
daemon.c ch_malloc.c init.c operation.c user.c sl_malloc.c \
|
||||
upstream.c value.c libevent_support.c extended.c \
|
||||
SRCS = backend.c bind.c config.c connection.c client.c \
|
||||
daemon.c extended.c operation.c \
|
||||
upstream.c libevent_support.c \
|
||||
$(@PLAT@_SRCS)
|
||||
|
||||
OBJS = $(patsubst %.c,%.o,$(SRCS)) $(@PLAT@_OBJS)
|
||||
|
||||
LDAP_INCDIR= ../../include -I$(srcdir)
|
||||
LDAP_INCDIR= ../../include -I$(srcdir) -I$(srcdir)/../slapd
|
||||
LDAP_LIBDIR= ../../libraries
|
||||
|
||||
BUILD_OPT = "--enable-balancer"
|
||||
BUILD_SRV = @BUILD_BALANCER@
|
||||
|
||||
all-local-srv: $(PROGRAMS)
|
||||
|
||||
# $(LTHREAD_LIBS) must be last!
|
||||
XLIBS = $(LLOADD_L)
|
||||
|
|
@ -50,25 +43,6 @@ UNIX_OBJECTS = $(OBJS) version.o
|
|||
LLOADD_DEPENDS = $(@PLAT@_DEPENDS)
|
||||
LLOADD_OBJECTS = $(@PLAT@_OBJECTS)
|
||||
|
||||
lloadd: $(LLOADD_DEPENDS) version.o
|
||||
$(LTLINK) -o $@ $(OBJS) version.o $(LIBS)
|
||||
include @BALANCER_INCLUDE@
|
||||
|
||||
slloadd: version.o
|
||||
$(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS)
|
||||
|
||||
version.c: Makefile
|
||||
@-$(RM) $@
|
||||
$(MKVERSION) -s -n Versionstr lloadd > $@
|
||||
|
||||
version.o: version.c $(OBJS) $(LLOADD_L)
|
||||
|
||||
install-local-srv: FORCE
|
||||
-$(MKDIR) $(DESTDIR)$(libexecdir)
|
||||
@-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-lloadd
|
||||
@( \
|
||||
for prg in $(PROGRAMS); do \
|
||||
$(LTINSTALL) $(INSTALLFLAGS) $(STRIP) -m 755 $$prg$(EXEEXT) \
|
||||
$(DESTDIR)$(libexecdir); \
|
||||
done \
|
||||
)
|
||||
|
||||
|
|
|
|||
45
servers/lloadd/Makefile_module.in
Normal file
45
servers/lloadd/Makefile_module.in
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Makefile.in for Load Balancer
|
||||
# $OpenLDAP$
|
||||
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
||||
##
|
||||
## Copyright 1998-2020 The OpenLDAP Foundation.
|
||||
## All rights reserved.
|
||||
##
|
||||
## Redistribution and use in source and binary forms, with or without
|
||||
## modification, are permitted only as authorized by the OpenLDAP
|
||||
## Public License.
|
||||
##
|
||||
## A copy of this license is available in the file LICENSE in the
|
||||
## top-level directory of the distribution or, alternatively, at
|
||||
## <http://www.OpenLDAP.org/license.html>.
|
||||
|
||||
|
||||
XSRCS = version.c
|
||||
|
||||
NT_SRCS = nt_svc.c
|
||||
NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
|
||||
|
||||
SRCS += module_init.c
|
||||
|
||||
OBJS = $(patsubst %.c,%.lo,$(SRCS)) $(@PLAT@_OBJS)
|
||||
|
||||
BUILD_OPT = "--enable-balancer=mod"
|
||||
BUILD_MOD = @BUILD_BALANCER@
|
||||
|
||||
LIBBASE=lloadd
|
||||
|
||||
# $(LTHREAD_LIBS) must be last!
|
||||
XLIBS = $(LLOADD_L)
|
||||
XXLIBS = $(LLOADD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
|
||||
XXXLIBS = $(LTHREAD_LIBS)
|
||||
|
||||
NT_DEPENDS = slapd.exp
|
||||
NT_OBJECTS = slapd.exp symdummy.o $(LLOADD_OBJS) version.o
|
||||
|
||||
UNIX_DEPENDS = version.o $(LLOADD_L)
|
||||
UNIX_OBJECTS = $(OBJS) version.o
|
||||
|
||||
LLOADD_DEPENDS = $(@PLAT@_DEPENDS)
|
||||
LLOADD_OBJECTS = $(@PLAT@_OBJECTS)
|
||||
LINK_LIBS=$(LLOADD_LIBS)
|
||||
MOD_DEFS = -DSLAPD_IMPORT -DBALANCER_MODULE
|
||||
69
servers/lloadd/Makefile_server.in
Normal file
69
servers/lloadd/Makefile_server.in
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# Makefile.in for Load Balancer
|
||||
# $OpenLDAP$
|
||||
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
||||
##
|
||||
## Copyright 1998-2020 The OpenLDAP Foundation.
|
||||
## All rights reserved.
|
||||
##
|
||||
## Redistribution and use in source and binary forms, with or without
|
||||
## modification, are permitted only as authorized by the OpenLDAP
|
||||
## Public License.
|
||||
##
|
||||
## A copy of this license is available in the file LICENSE in the
|
||||
## top-level directory of the distribution or, alternatively, at
|
||||
## <http://www.OpenLDAP.org/license.html>.
|
||||
|
||||
PROGRAMS = lloadd
|
||||
XPROGRAMS = slloadd
|
||||
|
||||
XSRCS = version.c
|
||||
|
||||
NT_SRCS = nt_svc.c
|
||||
NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
|
||||
|
||||
SRCS += main.c init.c value.c \
|
||||
ch_malloc.c sl_malloc.c user.c
|
||||
|
||||
OBJS = $(patsubst %.c,%.o,$(SRCS)) $(@PLAT@_OBJS)
|
||||
|
||||
BUILD_OPT = "--enable-balancer"
|
||||
BUILD_SRV = @BUILD_BALANCER@
|
||||
|
||||
all-local-srv: $(PROGRAMS)
|
||||
|
||||
# $(LTHREAD_LIBS) must be last!
|
||||
XLIBS = $(LLOADD_L)
|
||||
XXLIBS = $(LLOADD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
|
||||
XXXLIBS = $(LTHREAD_LIBS)
|
||||
|
||||
NT_DEPENDS = slapd.exp
|
||||
NT_OBJECTS = slapd.exp symdummy.o $(LLOADD_OBJS) version.o
|
||||
|
||||
UNIX_DEPENDS = version.o $(LLOADD_L)
|
||||
UNIX_OBJECTS = $(OBJS) version.o
|
||||
|
||||
LLOADD_DEPENDS = $(@PLAT@_DEPENDS)
|
||||
LLOADD_OBJECTS = $(@PLAT@_OBJECTS)
|
||||
|
||||
|
||||
lloadd: $(LLOADD_DEPENDS) version.o
|
||||
$(LTLINK) -o $@ $(OBJS) version.o $(LIBS)
|
||||
|
||||
slloadd: version.o
|
||||
$(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS)
|
||||
|
||||
version.c: Makefile
|
||||
@-$(RM) $@
|
||||
$(MKVERSION) -s -n Versionstr lloadd > $@
|
||||
|
||||
version.o: version.c $(OBJS) $(LLOADD_L)
|
||||
|
||||
install-local-srv: FORCE
|
||||
-$(MKDIR) $(DESTDIR)$(libexecdir)
|
||||
@-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-lloadd
|
||||
@( \
|
||||
for prg in $(PROGRAMS); do \
|
||||
$(LTINSTALL) $(INSTALLFLAGS) $(STRIP) -m 755 $$prg$(EXEEXT) \
|
||||
$(DESTDIR)$(libexecdir); \
|
||||
done \
|
||||
)
|
||||
|
|
@ -150,9 +150,13 @@ lload_libevent_init( void )
|
|||
lload_libevent_cond_timedwait
|
||||
};
|
||||
|
||||
#ifndef BALANCER_MODULE
|
||||
/* only necessary if lload is a server, slapd already calls
|
||||
* ldap_pvt_thread_initialize() */
|
||||
if ( ldap_pvt_thread_initialize() ) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
evthread_set_lock_callbacks( &cbs );
|
||||
evthread_set_condition_callbacks( &cond_cbs );
|
||||
|
|
|
|||
110
servers/lloadd/module_init.c
Normal file
110
servers/lloadd/module_init.c
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/* module_init.c - module initialization functions */
|
||||
/* $OpenLDAP$ */
|
||||
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
||||
*
|
||||
* Copyright 1998-2020 The OpenLDAP Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted only as authorized by the OpenLDAP
|
||||
* Public License.
|
||||
*
|
||||
* A copy of this license is available in the file LICENSE in the
|
||||
* top-level directory of the distribution or, alternatively, at
|
||||
* <http://www.OpenLDAP.org/license.html>.
|
||||
*/
|
||||
/* Portions Copyright (c) 1995 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
|
||||
#include "../servers/slapd/slap.h"
|
||||
|
||||
#include "lload.h"
|
||||
#include "lber_pvt.h"
|
||||
|
||||
#include "ldap_rq.h"
|
||||
|
||||
int
|
||||
lload_start_daemon()
|
||||
{
|
||||
struct event_base *daemon_base = event_base_new();
|
||||
int rc = 0, i;
|
||||
if ( !daemon_base ) {
|
||||
Debug( LDAP_DEBUG_ANY, "lload_start_daemon: "
|
||||
"main event base allocation failed\n" );
|
||||
rc = 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = lloadd_daemon( daemon_base );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* from init.c */
|
||||
int
|
||||
lload_conn_pool_init()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
ldap_pvt_thread_mutex_init( &backend_mutex );
|
||||
ldap_pvt_thread_mutex_init( &clients_mutex );
|
||||
|
||||
lload_exop_init();
|
||||
Debug( LDAP_DEBUG_TRACE, "lload_conn_pool_init: "
|
||||
"mutexes initialized.\n" );
|
||||
return rc;
|
||||
}
|
||||
|
||||
void *
|
||||
lload_module_start_daemon( void *ctx, void *arg )
|
||||
{
|
||||
lload_start_daemon();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
init_module( int argc, char *argv[] )
|
||||
{
|
||||
if ( slapMode & SLAP_TOOL_MODE ) {
|
||||
return 0;
|
||||
}
|
||||
if ( lload_libevent_init() ) {
|
||||
return -1;
|
||||
}
|
||||
global_host = ldap_pvt_get_fqdn( NULL );
|
||||
#ifdef HAVE_TLS
|
||||
if ( ldap_create( &lload_tls_backend_ld ) ) {
|
||||
return -1;
|
||||
}
|
||||
#endif /* HAVE_TLS */
|
||||
|
||||
if ( lloadd_daemon_init( argv[1] ) != 0 ) {
|
||||
return -1;
|
||||
}
|
||||
lload_conn_pool_init();
|
||||
|
||||
if ( lload_read_config( argv[0], NULL ) != 0 ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
|
||||
ldap_pvt_runqueue_insert( &slapd_rq, 0, lload_module_start_daemon, NULL,
|
||||
"lload_module_start_daemon", "lloadd" );
|
||||
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ SUBDIRS= progs
|
|||
|
||||
BUILD_MDB=@BUILD_MDB@
|
||||
BUILD_SQL=@BUILD_SQL@
|
||||
BUILD_SLAPD=@BUILD_SLAPD@
|
||||
BUILD_BALANCER=@BUILD_BALANCER@
|
||||
|
||||
# test primary backends (default)
|
||||
|
|
@ -54,7 +55,12 @@ lloadd test-lloadd: lloadd-$(BUILD_BALANCER)
|
|||
lloadd-no:
|
||||
@echo "run configure with --enable-balancer to run the Load Balancer tests"
|
||||
|
||||
lloadd-yes: FORCE
|
||||
lloadd-yes: lloadd-slapd-$(BUILD_SLAPD)
|
||||
|
||||
lloadd-slapd-no:
|
||||
@echo "run configure with --enable-slapd to run the Load Balancer tests"
|
||||
|
||||
lloadd-slapd-yes: FORCE
|
||||
@echo "Initiating LDAP tests for the Load Balancer..."
|
||||
@$(RUN) lloadd-all
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue