Revision ccb849ec
Added by Benoît PECCATTE about 7 years ago
rudder-inventory-ldap/SOURCES/rudder-inventory-ldap.init | ||
---|---|---|
fi
|
||
|
||
# configuration
|
||
if [ "${RUDDER_CACHESIZE}" != "noauto" ]
|
||
if [ "${RUDDER_MDBSIZE}" != "noauto" ]
|
||
then
|
||
if [ "${RUDDER_CACHESIZE}" = "auto" ] || [ "${RUDDER_CACHESIZE}" = "" ]
|
||
if [ "${RUDDER_MDBSIZE}" = "auto" ] || [ "${RUDDER_MDBSIZE}" = "" ]
|
||
then
|
||
# calculate the value to use about 10% of RAM
|
||
# calculate the value to match about 50% of RAM (this is only virtual memory)
|
||
MEMSIZE=$(sed -n '/^MemTotal/s/[^0-9]//gp' /proc/meminfo)
|
||
# Round down using integer division (800 bytes is the size of an entry)
|
||
CACHESIZE=$((${MEMSIZE} * 1024 / 800 / 10 / 10000 * 10000))
|
||
# Maximum cache size of 40M entries. Above about 40G of RAM (about 53.6M entries) OpenLDAP dumps core, so we force an upper limit.
|
||
if [ ${CACHESIZE} -gt 40000000 ]; then
|
||
CACHESIZE=40000000
|
||
MDBSIZE=$((${MEMSIZE} * 1024 / 2 ))
|
||
# on 32 bits architectures max it to 500M (PAE allows more ram but not more virtual memory)
|
||
if [ "$(getconf LONG_BIT)" -ne "64" ] && [ "${MDBSIZE}" -gt 524288000 ]
|
||
then
|
||
MDBSIZE=524288000
|
||
fi
|
||
else
|
||
# set cache size to the value provided
|
||
CACHESIZE=${RUDDER_CACHESIZE}
|
||
MDBSIZE=${RUDDER_MDBSIZE}
|
||
fi
|
||
sed -i '/^[ \t]*\(cachesize\|idlcachesize\)/d' /opt/rudder/etc/openldap/slapd.conf
|
||
sed -i 's/^\([ \t]*suffix[ \t]\+"cn=rudder-configuration".*\)/\1\ncachesize '${CACHESIZE}'/' /opt/rudder/etc/openldap/slapd.conf
|
||
sed -i 's/^\([ \t]*suffix[ \t]\+"cn=rudder-configuration".*\)/\1\nidlcachesize '$((${CACHESIZE}*3))'/' /opt/rudder/etc/openldap/slapd.conf
|
||
sed -i '/^[ \t]*\(maxsize\|maxsize\)/d' /opt/rudder/etc/openldap/slapd.conf
|
||
sed -i 's/^\([ \t]*suffix[ \t]\+"cn=rudder-configuration".*\)/\1\nmaxsize '${MDBSIZE}'/' /opt/rudder/etc/openldap/slapd.conf
|
||
fi
|
||
|
||
# Parameters
|
rudder-inventory-ldap/SOURCES/rudder-slapd.conf | ||
---|---|---|
######################### WARNING ############################
|
||
|
||
# Rudder automatic caching size setup
|
||
RUDDER_CACHESIZE="auto"
|
||
RUDDER_MDBSIZE="auto"
|
||
|
||
# OpenLDAP settings
|
||
IP="localhost"
|
rudder-inventory-ldap/SOURCES/slapd.conf | ||
---|---|---|
# Database definitions
|
||
#######################################################################
|
||
|
||
# 1 - Rudder database ( BerkeleyDB HDB )
|
||
# 1 - Rudder database
|
||
|
||
database hdb
|
||
database mdb
|
||
|
||
suffix "cn=rudder-configuration"
|
||
|
||
... | ... | |
# Checkpoint database every 128k written or every minute
|
||
checkpoint 128 1
|
||
|
||
# Performance optimizations
|
||
cachesize 100000
|
||
idlcachesize 300000
|
||
# Maximum database size in bytes (memory mapping size)
|
||
# Default 100M to work on 32 bits arch
|
||
maxsize 104857600
|
||
|
||
# Indices to maintain
|
||
index objectClass eq
|
rudder-inventory-ldap/SPECS/rudder-inventory-ldap.spec | ||
---|---|---|
export CPPFLAGS="-I/opt/rudder/include"
|
||
export LDFLAGS="-L/opt/rudder/lib"
|
||
|
||
./configure --build=%{_target} --prefix=%{rudderdir} --libdir=%{rudderdir}/lib/ldap --enable-dynamic --enable-debug --enable-modules --enable-hdb=mod --enable-monitor=mod --enable-dynlist=mod
|
||
./configure --build=%{_target} --prefix=%{rudderdir} --libdir=%{rudderdir}/lib/ldap --enable-dynamic --enable-debug --enable-modules --enable-hdb=mod --enable-monitor=mod --enable-dynlist=mod --enable-mdb=yes
|
||
|
||
make %{?_smp_mflags} depend
|
||
make %{?_smp_mflags}
|
||
... | ... | |
RUDDER_UPGRADE_TOOLS=${RUDDER_SHARE}/upgrade-tools
|
||
BACKUP_LDIF_PATH=/var/rudder/ldap/backup/
|
||
BACKUP_LDIF_REGEX="^/var/rudder/ldap/backup/openldap-data-pre-upgrade-\([0-9]\{14\}\)\.ldif$"
|
||
SLAPD_CONF="/opt/rudder/etc/openldap/slapd.conf"
|
||
|
||
# Do we have a backup file from a previous upgrade?
|
||
# Do we have a backup file from preinst
|
||
BACKUP_LDIF=$(find ${BACKUP_LDIF_PATH} -regextype sed -regex "${BACKUP_LDIF_REGEX}" 2>&1 | sort -nr | head -n1)
|
||
if [ -n "${BACKUP_LDIF}" ]; then
|
||
TIMESTAMP=$(echo ${BACKUP_LDIF} | sed "s%${BACKUP_LDIF_REGEX}%\1%")
|
||
... | ... | |
service rudder-slapd forcestop >/dev/null 2>&1
|
||
echo " Done"
|
||
|
||
# Backup the old database
|
||
# Backup the current database
|
||
LDAP_BACKUP_DIR="/var/rudder/ldap/openldap-data-backup-upgrade-on-${TIMESTAMP}/"
|
||
mkdir -p "${LDAP_BACKUP_DIR}"
|
||
find /var/rudder/ldap/openldap-data -maxdepth 1 -mindepth 1 -not -name "DB_CONFIG" -exec mv {} ${LDAP_BACKUP_DIR} \;
|
||
|
||
# Import the backed up database
|
||
# Upgrade backend to lmdb
|
||
sed -i 's/^database.*hdb/database mdb/' "${SLAPD_CONF}"
|
||
sed -i '/^idlcachesize.*/d' "${SLAPD_CONF}"
|
||
sed -i '/^cachesize.*/d' "${SLAPD_CONF}"
|
||
|
||
# Import the backed up database
|
||
/opt/rudder/sbin/slapadd -q -l ${BACKUP_LDIF}
|
||
|
||
# Start OpenLDAP
|
rudder-inventory-ldap/debian/postinst | ||
---|---|---|
RUDDER_UPGRADE_TOOLS=${RUDDER_SHARE}/upgrade-tools
|
||
BACKUP_LDIF_PATH=/var/rudder/ldap/backup/
|
||
BACKUP_LDIF_REGEX="^/var/rudder/ldap/backup/openldap-data-pre-upgrade-\([0-9]\{14\}\)\.ldif$"
|
||
SLAPD_CONF="/opt/rudder/etc/openldap/slapd.conf"
|
||
|
||
# Do we have a backup file from a previous upgrade?
|
||
# Do we have a backup file from preinst
|
||
BACKUP_LDIF=$(find ${BACKUP_LDIF_PATH} -regextype sed -regex "${BACKUP_LDIF_REGEX}" 2>&1 | sort -nr | head -n1)
|
||
if [ -n "${BACKUP_LDIF}" ]; then
|
||
TIMESTAMP=$(echo ${BACKUP_LDIF} | sed "s%${BACKUP_LDIF_REGEX}%\1%")
|
||
... | ... | |
invoke-rc.d rudder-slapd forcestop >/dev/null 2>&1
|
||
echo " Done"
|
||
|
||
# Backup the old database
|
||
# Backup the current database
|
||
LDAP_BACKUP_DIR="/var/rudder/ldap/openldap-data-backup-upgrade-on-${TIMESTAMP}/"
|
||
mkdir -p "${LDAP_BACKUP_DIR}"
|
||
find /var/rudder/ldap/openldap-data -maxdepth 1 -mindepth 1 -not -name "DB_CONFIG" -exec mv {} ${LDAP_BACKUP_DIR} \;
|
||
|
||
# Upgrade backend to lmdb
|
||
sed -i 's/^database.*hdb/database mdb/' "${SLAPD_CONF}"
|
||
sed -i '/^idlcachesize.*/d' "${SLAPD_CONF}"
|
||
sed -i '/^cachesize.*/d' "${SLAPD_CONF}"
|
||
|
||
# Import the backed up database
|
||
/opt/rudder/sbin/slapadd -q -l ${BACKUP_LDIF}
|
||
|
rudder-inventory-ldap/debian/rules | ||
---|---|---|
CPPFLAGS="-I$(CURDIR)/debian/tmp/opt/rudder/include" \
|
||
CFLAGS="-I$(CURDIR)/debian/tmp/opt/rudder/include" \
|
||
LDFLAGS="-L$(CURDIR)/debian/tmp/opt/rudder/lib" \
|
||
./configure --prefix=/opt/rudder --libdir=/opt/rudder/lib/ldap --enable-dynamic --enable-debug --enable-modules --enable-hdb=mod --enable-monitor=mod --enable-dynlist=mod
|
||
./configure --prefix=/opt/rudder --libdir=/opt/rudder/lib/ldap --enable-dynamic --enable-debug --enable-modules --enable-hdb=mod --enable-monitor=mod --enable-dynlist=mod --enable-mdb=yes
|
||
|
||
touch configure-stamp
|
||
|
Also available in: Unified diff
Fixes #9839: Build slapd with lmdb