---
title: "openLDAP相关维护"
author: "zp820705"
date: "2013-10-12T17:28:42Z"
tags: []
categories: ["企业架构"]
slug: "openldap"
draft: false
lastmod: "2013-10-12T17:28:42Z"
id: 1955902
url: "https://acooly.iteye.com/blog/1955902"
---

**1、ACL 控制**

\# 设置访问基础访问权限：对，密码的访问控制

access to **attrs**=userPassword

      by anonymous auth # 匿名访问，用于认证

      by dn= “cn=Manager,dc=boy,dc=com” write  # 管理员可修改

      by self write # 自己可以修改

 

\# 对其他全局所有数据，除管理员可写外，其他人只读。

access to *

      by dn=”cn=Manager,dc=boy,dc=com” write

      by self write

      by * read

      

**2、日志错误处理**

Oct 12 03:12:09 localhost slapd\[17954]: /usr/local/openldap/etc/openldap/slapd.conf: line 59: "attr" is deprecated (and undocumented); use "attrs" instead.

解决：

access to **attr**=userPassword    修改为：access to **attrs**=userPassword

 

Oct 12 03:12:09 localhost slapd\[17955]: bdb\_db\_open: warning - no DB\_CONFIG file found in directory /data/openldap/data: (2).#012Expect poor performance for suffix "dc=feinno,dc=com".

解决： cp /usr/local/openldap/etc/openldap/DB\_CONFIG.example /data/openldap/data/DB\_CONFIG

 

 

**3、loglevel**

默认就是256,即：256 (0x100 stats) stats log connections/operations/results

可以在日志中看到连接情况，客户端的请求操作，查询条件和结果等信息

 slapd.conf 中加入指令: loglevel 256

 

openLDAP是通过操作系统的syslog或rsyslog等写日志，我们主要使用rsyslog, 需要在其配置文件中加入

LOCAL4.*    /var/log/ldap.log

 

**4、ldap备份/还原**

/usr/local/openldap/sbin/slapadd -v -l ./ldapdata.ldif.20131012

stop slapd 

/usr/local/openldap/sbin/slapadd -v -l ./ldapdata.ldif.20131012

start slapd

 

 

 

**5、ldap-rsyslog 日志滚动**

logrostat

/var/log/ldap.log {

    compress 

    missingok 

    notifempty

    size 1024m 

    weekly

    rotate 8

    create 0600 root root

    postrotate

/bin/kill -HUP \`cat /var/run/syslogd.pid 2&gt; /dev/null\` 2&gt; /dev/null || true

    endscript

}

logrotate 的配置文件是 /etc/logrotate.conf。

命令参考：[http://5iqiong.blog.51cto.com/2999926/790908](http://5iqiong.blog.51cto.com/2999926/790908)

 

 

6、SVN整合LDAP的缓存和连接池

默认情况下，APACHE的module\_ldap模块为其他组件提供了连接池和缓存，默认1024个实体缓存每10分钟刷新一次。

```
LDAPSharedCacheSize 500000
LDAPCacheEntries 1024
LDAPCacheTTL 600
LDAPOpCacheEntries 1024
LDAPOpCacheTTL 600
```

 

官方参考：http://httpd.apache.org/docs/2.2/mod/mod\_ldap.html