分类:
2008-07-20 22:58:42
这一部分是OPENLDAP的安装
1、Openldap2.0.25安装
./configure --prefix=/home/openldap --with-ldbm-api=gdbm
./make
./make intall
我测试机的sldap.conf需要添加如下:
include /usr/local/openldap/etc/openldap/schema/core.schema
include /usr/local/openldap/etc/openldap/schema/cosine.schema
include /usr/local/openldap/etc/openldap/schema/inetorgperson.schema
#上面两项在编译完生成的slapd.conf中是没有添加的,所以需要我们手工添加。
#因为下面的例子不如的objectClass:inetOrgPerson是在inetorgperson.schema中定义的,所以如果不在此处include加入的话,在导入ldif文件的时候会提示不识别inetOrgPerson这个属性的。
#######################################################################
# ldbm database definitions
#######################################################################
database ldbm
suffix "dc=stooges,dc=com"
rootdn "cn=Manager,dc=stooges,dc=com"
rootpw secret
directory /var/lib/ldap/stooges
lastmod on
并且stooges.ldif文件内容为:
dn: dc=stooges,dc=com
objectClass:dcObject
objectClass: organization
o: stooges
dc: stooges
description: this is stooges domain
dn: uid=bbb,dc=stooges,dc=com
objectClass: Person
objectClass: inetOrgPerson
uid: bbb
sn: bbb
cn: bbb
telephoneNumber: 111-111-111
mail: bbb@stooges.com
dn: uid=ccc,dc=stooges,dc=com
objectClass: Person
objectClass: inetOrgPerson
uid: ccc
sn: ccc
cn: ccc
telephoneNumber: 222-111-111
[root@oradb openldap]#libexec/slapd 启动slapd进程,只有启动进程后,才可以看ldap中添加数据库
[root@oradb openldap]#ps -ef | grep slapd
[root@oradb openldap]# ps -ef | grep slapd
root 27461 1 0 21:32 ? 00:00:00 libexec/slapd
root 27462 27461 0 21:32 ? 00:00:00 libexec/slapd
root 27463 27462 0 21:32 ? 00:00:00 libexec/slapd
root 27465 27462 0 21:32 ? 00:00:00 libexec/slapd
root 27466 27462 0 21:32 ? 00:00:00 libexec/slapd
root 27474 6419 0 21:36 pts/0 00:00:00 grep slapd
[root@oradb openldap]# bin/ldapadd -f stooges.ldif -W -x -D 'cn=Manager,dc=stooges,dc=com' 将数据添加到ldap数据库中
Enter LDAP Password:
adding new entry "dc=stooges,dc=com"
adding new entry "uid=bbb,dc=stooges,dc=com"
adding new entry "uid=ccc,dc=stooges,dc=com"
[root@oradb openldap]#
#ldpasearch -LLL -b 'dc=stooges,dc=com' -W -x
查询数据库的内容
[root@oradb openldap]# bin/ldapsearch -LLL -b 'dc=stooges,dc=com' -W -x
Enter LDAP Password:
dn: dc=stooges,dc=com
objectClass: dcObject
objectClass: organization
o: stooges
dc: stooges
description: this is stooges domain
dn: uid=bbb,dc=stooges,dc=com
objectClass: Person
objectClass: inetOrgPerson
uid: bbb
sn: bbb
cn: bbb
telephoneNumber: 111-111-111
mail: bbb@stooges.com
dn: uid=ccc,dc=stooges,dc=com
objectClass: Person
objectClass: inetOrgPerson
uid: ccc
sn: ccc
cn: ccc
telephoneNumber: 222-111-111
mail: ccc@stooges.com
[root@oradb openldap]#
这一部分是loadrunner测试的脚本
Action()
{
mldap1 = 0;
mldap_logon_ex(&mldap1,
"LdapLogon",
"URL=ldap://cn=Anonymous:@192.168.198.162",
LAST);
mldap_search_ex(&mldap1,
"LdapSearch",
"Base=dc=stooges,dc=com",
"Scope=Onelevel",
"Filter=objectClass=*",
LAST);
mldap_search_ex(&mldap1,
"LdapSearch",
"Base=dc=stooges,dc=com",
"Scope=Base",
"Filter=objectClass=*",
LAST);
lr_think_time(11);
mldap_search_ex(&mldap1,
"LdapSearch",
"Base=uid=bbb,dc=stooges,dc=com",
"Scope=Base",
"Filter=(objectclass=*)",
LAST);
lr_think_time(7);
mldap_search_ex(&mldap1,
"LdapSearch",
"Base=uid=ccc,dc=stooges,dc=com",
"Scope=Base",
"Filter=(objectclass=*)",
LAST);
mldap_logoff_ex(&mldap1);
return 0;
}
需要再server的slapd.conf添加如下,因为loadrunner发起的ldap请求是ldap bind_v2,刚开始的时候slapd.conf会不认为是bind_V2请求,因为现在已经都使用bind_v3请求,所以loadrunner测试的时候有如下报错日志.需要修改slapd.conf让openldap支持bind_v2请求.
access to *
by * write
allow bind_v2
还需要在loadrunner测试脚本当中添加一个聚合点,在Insert-->下面选择rendezvous,随意起个名字就可以.
lr_rendezvous("11");
下面是loadrunner测试的日志.
Mar 9 19:40:08 test162 slapd[2425]: conn=1 fd=8 ACCEPT from IP=192.168.198.17:17290 (IP=0.0.0.0:389)
Mar 9 19:40:08 test162 slapd[2425]: daemon: added 8r
Mar 9 19:40:08 test162 slapd[2425]: daemon: activity on:
Mar 9 19:40:08 test162 slapd[2425]:
Mar 9 19:40:08 test162 slapd[2425]: daemon: select: listen=6 active_threads=0 tvp=NULL
Mar 9 19:40:08 test162 slapd[2425]: daemon: select: listen=7 active_threads=0 tvp=NULL
Mar 9 19:40:08 test162 slapd[2425]: daemon: activity on 1 descriptors
Mar 9 19:40:08 test162 slapd[2425]: daemon: activity on:
Mar 9 19:40:08 test162 slapd[2425]: 8r
Mar 9 19:40:08 test162 slapd[2425]:
Mar 9 19:40:08 test162 slapd[2425]: daemon: read activity on 8
Mar 9 19:40:08 test162 slapd[2425]: connection_get(8)
Mar 9 19:40:08 test162 slapd[2425]: connection_get(8): got connid=1
Mar 9 19:40:08 test162 slapd[2425]: connection_read(8): checking for input on id=1
Mar 9 19:40:08 test162 slapd[2425]: ber_get_next on fd 8 failed errno=11 (Resource temporarily unavailable)
Mar 9 19:40:08 test162 slapd[2425]: do_bind
Mar 9 19:40:08 test162 slapd[2425]: daemon: select: listen=6 active_threads=0 tvp=NULL
Mar 9 19:40:08 test162 slapd[2425]: >>> dnPrettyNormal:
Mar 9 19:40:08 test162 slapd[2425]: daemon: select: listen=7 active_threads=0 tvp=NULL
Mar 9 19:40:08 test162 slapd[2425]: <<< dnPrettyNormal:
Mar 9 19:40:08 test162 slapd[2425]: do_bind: version=2 dn="cn=root,dc=myhome,dc=com" method=128
Mar 9 19:40:08 test162 slapd[2425]: conn=1 op=0 BIND dn="cn=root,dc=myhome,dc=com" method=128
Mar 9 19:40:08 test162 slapd[2425]: send_ldap_result: conn=1 op=0 p=2
Mar 9 19:40:08 test162 slapd[2425]: send_ldap_result: err=2 matched="" text="historical protocol version requested, use LDAPv3 inst
ead"
Mar 9 19:40:09 test162 slapd[2425]: send_ldap_response: msgid=1 tag=97 err=2
Mar 9 19:40:09 test162 slapd[2425]: conn=1 op=0 RESULT tag=97 err=2 text=historical protocol version requested, use LDAPv3 instead
Mar 9 19:40:09 test162 slapd[2425]: daemon: activity on 1 descriptors
Mar 9 19:40:09 test162 slapd[2425]: daemon: activity on:
Mar 9 19:40:09 test162 slapd[2425]: 8r
Mar 9 19:40:09 test162 slapd[2425]:
Mar 9 19:40:09 test162 slapd[2425]: daemon: read activity on 8
Mar 9 19:40:09 test162 slapd[2425]: connection_get(8)
Mar 9 19:40:09 test162 slapd[2425]: connection_get(8): got connid=1
Mar 9 19:40:09 test162 slapd[2425]: connection_read(8): checking for input on id=1
Mar 9 19:40:09 test162 slapd[2425]: ber_get_next on fd 8 failed errno=104 (Connection reset by peer)
Mar 9 19:40:09 test162 slapd[2425]: connection_read(8): input error=-2 id=1, closing.
Mar 9 19:40:09 test162 slapd[2425]: connection_closing: readying conn=1 sd=8 for close
Mar 9 19:40:09 test162 slapd[2425]: connection_close: conn=1 sd=8
Mar 9 19:40:09 test162 slapd[2425]: daemon: removing 8
Mar 9 19:40:09 test162 slapd[2425]: conn=1 fd=8 closed
Mar 9 19:40:09 test162 slapd[2425]: daemon: select: listen=6 active_threads=0 tvp=NULL
Mar 9 19:40:09 test162 slapd[2425]: daemon: select: listen=7 active_threads=0 tvp=NULL
Mar 9 19:40:09 test162 slapd[2425]: daemon: activity on 1 descriptors
Mar 9 19:40:09 test162 slapd[2425]: daemon: select: listen=6 active_threads=0 tvp=NULL
Mar 9 19:40:09 test162 slapd[2425]: daemon: select: listen=7 active_threads=0 tvp=NULL