
1 基础知识
1.1 缓存代理的概念
缓存代理服务器缓存单个或多个主服务器LDAP条目副本,该副本直接为LDAP客户端提供服务,副本缓存的是搜索过滤器而不是子树相对应的LDAP条目。
1.2 缓存代理的实现
使用LDAP同步复制将LDAP条目从主服务器传递到缓存服务器
1.3 缓存的的作用
减轻后端ldap服务器的负载
1.4 代理缓存的配置
1.4.1 获取帮助信息
man slapd.conf
注:请参阅“database meta”或“database ldap”章节的overlay pcache指令
1.4.2 设置缓存的参数
pcache <DB> <maxentries> <nattrsets> <entrylimit> <period>
– 指令启用代理缓存并设置常规缓存参数
– DB参数指定用于baocun缓存条目的基础数据库,可设置为“bdb”或“hdb”
– maxentries参数指定可在缓存中保留的条目数
– nattrsets参数指定可定义的属性集的总数(由pcacheAttrset指令指定)
– entrylimit参数指定可缓存查询中的最大条目数
– period参数指定一致性检查周期(单位秒)
1.4.3 定义属性集
pcacheAttrset <index> <attrs …>
– 指令用于将一组属性与索引相关联
– 每个属性集从0到<numattrsets>-1
– pcacheTemplate指令使用这些索引来定义缓存模板
1.4.4 定义可缓存的模板
pcacheTemplate <prototype_string> <attrset_index> <TTL>
– 指令为属于模板的查询指定可缓存模板和TTL(生存时间)
– 属于模板的查询由原型过滤器字符串和<attrset_index>标识的必须属性集描述
1.5 配置范例
1.5.1 slapd.conf的范例
database ldap suffix "dc=example,dc=com" rootdn "dc=example,dc=com" uri ldap://ldap.example.com/ overlay pcache pcache hdb 100000 1 1000 100 pcacheAttrset 0 mail postaladdress telephonenumber pcacheTemplate (sn=) 0 3600 pcacheTemplate (&(sn=)(givenName=)) 0 3600 pcacheTemplate (&(departmentNumber=)(secretary=*)) 0 3600 cachesize 20 directory ./testrun/db.2.a index objectClass eq index cn,sn,uid,mail pres,eq,sub
注:以上范例代理缓存ldap.example.com服务器的”dc=example,dc=com”子树
1.5.2 slapd-config的范例
dn: olcDatabase={2}ldap,cn=config objectClass: olcDatabaseConfig objectClass: olcLDAPConfig olcDatabase: {2}ldap olcSuffix: dc=example,dc=com olcRootDN: dc=example,dc=com olcDbURI: "ldap://ldap.example.com" dn: olcOverlay={0}pcache,olcDatabase={2}ldap,cn=config objectClass: olcOverlayConfig objectClass: olcPcacheConfig olcOverlay: {0}pcache olcPcache: hdb 100000 1 1000 100 olcPcacheAttrset: 0 mail postalAddress telephoneNumber olcPcacheTemplate: "(sn=)" 0 3600 0 0 0 olcPcacheTemplate: "(&(sn=)(givenName=))" 0 3600 0 0 0 olcPcacheTemplate: "(&(departmentNumber=)(secretary=))" 0 3600 dn: olcDatabase={0}mdb,olcOverlay={0}pcache,olcDatabase={2}ldap,cn=config objectClass: olcMdbConfig objectClass: olcPcacheDatabase olcDatabase: {0}mdb olcDbDirectory: ./testrun/db.2.a olcDbCacheSize: 20 olcDbIndex: objectClass eq olcDbIndex: cn,sn,uid,mailpres,eq,sub
注:
– 范例适用于LDIF文件
– 范例同样代理缓存ldap.example.com服务器的”dc=example,dc=com”子树
2 最佳实践
2.1 部署OpenLDAP
请按如下链接部署OpenLDAP的环境,
https://www.cmdschool.org/archives/3563
2.2 配置缓存代理
2.1.1 创建ldif定义
vim ~/cmdschool.org-proxy_cache.ldif
加入如下内容,
dn: olcDatabase={2}ldap,cn=config objectClass: olcDatabaseConfig objectClass: olcLDAPConfig olcDatabase: {2}ldap olcSuffix: dc=cmdschool,dc=org olcRootDN: cn=Administrator,cn=User,dc=cmdschool,dc=org olcDbURI: "ldap://10.168.0.250" dn: olcOverlay={0}pcache,olcDatabase={2}ldap,cn=config objectClass: olcOverlayConfig objectClass: olcPcacheConfig olcOverlay: {0}pcache olcPcache: hdb 100000 1 1000 100 olcPcacheAttrset: 0 mail postalAddress telephoneNumber olcPcacheTemplate: "(sn=)" 0 3600 0 0 0 olcPcacheTemplate: "(&(sn=)(givenName=))" 0 3600 0 0 0 olcPcacheTemplate: "(&(departmentNumber=)(secretary=))" 0 3600 dn: olcDatabase={0}mdb,olcOverlay={0}pcache,olcDatabase={2}ldap,cn=config objectClass: olcMdbConfig objectClass: olcPcacheDatabase olcDatabase: {0}mdb olcDbDirectory: ./testrun/db.2.a olcDbCacheSize: 20 olcDbIndex: objectClass eq olcDbIndex: cn,sn,uid,mailpres,eq,sub
2.1.2 导入ldif文件,
ldapadd -x -D "cn=Manager,dc=cmdschool,dc=org" -W -f ~/cmdschool.org-proxy_cache.ldif ldapadd -x -D "cn=Manager,dc=cmdschool,dc=org" -w secret -f ~/cmdschool.org-proxy_cache.ldif
参阅文档:
===============
http://www.openldap.org/doc/admin24/overlays.html#The%20Proxy%20Cache%20Engine
没有评论