配置LDAP 服务器配置(包含对等设置)以 IBM 技术网站和 IBM Redbooks® 中的各种文档为基础。
AIX LDAP 配置是 90% 标准,并可在一些领域进行调整来满足我们的需求。
RSCT 实现是完全在内部构建的。监控脚本基于我们对如何确定 LDAP 服务器是否可访问的经验。
LDAP 服务器LDAP 服务器将在两个主机或 LPAR 上进行配置。在如下示例和脚本中,使用如下变量:
- inst1 LDAP Server1 实例名
- inst2 LDAP Server2 实例名
- host1 LDAP Server1 主机名
- host2 LDAP Server2 主机名
- port1 LDAP Server1 端口号,默认为 20389
- port2 LDAP Server2 端口号,默认为 20389
- ldp1 用于 LDAP1 的 DB2 Server1 端口号
- ldp2 用于 LDAP2 的 DB2 Server2 端口号
- dbp1 DB2 Server1 服务器端口号
- dbp2 DB2 Server2 服务器端口号
- $ITDS /opt/IBM/ldap/V6.3
- $SUFFIX o=ORG,c=US
在 host1 上创建 inst1 实例
确保实例所有者主目录是本地的,即 /home,并注意密码:对于 inst2 实例所有者用户而言,密码配置应相同。
- 为两个实例所有者用户准备相同的基组(primary group)(例如,inst1、inst2 和 pgrp=dba)。
- 为 root 用户做准备,使其成为实例所有者的基组的一部分。
- 为 root 用户做准备,使其成为 idsldap 组的一部分。
- 确保 $DB2INSTPATH/default.env 文件不包含实例 inst1 或 inst2。
- 创建目录 /db2/inst1/NODE0000 和 /db2event/inst1 并确保 /db2/inst1/NODE0000 和 /db2event/inst1 可由实例所有者的基组编写。实例创建后,可以将其设置回 normal。
清单 1. 创建 inst1 实例:1
2
| $ITDS/sbin/idsicrt -q -n -I inst1-e idsldapinst1002007 -g inst100slapd -l /home/inst1
-p 20389 -s 21389 -a 22389 -c 23389 -t inst1
|
注意加密字符串。它应与 inst2 的加密字符串相同。
清单 2. 设置 rootdn 密码:1
| $ITDS/sbin/idsdnpw -q -I inst1 -n -u cn=rootdn -p rootdnpwd
|
清单 3. 定义 LDAP 数据库:1
| $ITDS/sbin/idscfgdb -q -n -I inst1 -a inst1 -t dbinst1 -w rootdnpwd -l /db2
|
清单 4. 在 LDAP 中配置基础后缀:1
| $ITDS/sbin/idscfgsuf -q -I inst1 -s $SUFFIX
|
为 AIX 用户管理准备 LDAP清单 5. 加载 NIS 模式1
2
| file="etc/security/ldap/nisSchema.ldif"
$ITDS/bin/ldapmodify -c -v -a -h host1 -p 20389 -D cn=rootdn -w rootdnpwd -f $file
|
清单 6. 加载 AIX 安全模式1
2
| file="etc/security/ldap/sec.ldif"
$ITDS/bin/ldapmodify -c -v -a -h host1 -p 20389 -D cn=rootdn -w rootdnpwd -f $file
|
在 host2 上创建 inst2 实例
执行以下步骤,在 host2 上创建 inst2 实例。
- 准备两个实例所有者用户,两个都属于同一个基组(例如,inst1、inst2 和 pgrp=dba)。
- 为 root 用户做准备,使其成为实例所有者的基组的一部分。
- 为 root 用户做准备,使其成为 idsldap 组的一部分。
- 确保 $DB2INSTPATH/default.env 文件不包含 inst1 或 inst2 实例。
- 创建目录 /db2/inst1/NODE0000 和 /db2event/inst1 并确保 /db2/inst1/NODE0000 和 /db2event/inst1 可由实例所有者的基组编写。创建实例后,将其设置回 normal。
- 确保两个对等的 LDAP 服务器上的种子算法(seed algorithm)是相同的。这是在 idsicrt 命令的 -e 标志中定义的。
清单 7. 创建 inst2 实例:1
2
| $ITDS/sbin/idsicrt -q -n -I inst2 -e idsldapinst1002007 -g inst100slapd -l /home/inst2
-p 20389 -s 21389 -a 22389 -c 23389 -t inst2
|
清单 8. 设置 rootdn 密码:1
| $ITDS/sbin/idsdnpw -q -I inst2 -n -u cn=rootdn -p rootdnpwd
|
清单 9. 定义 LDAP 数据库:1
| $ITDS/sbin/idscfgdb -q -n -I inst1 -a inst1 -t dbinst1 -w rootdnpwd -l /db2
|
清单 10. 在 LDAP 中配置基础后缀:1
| $ITDS/sbin/idscfgsuf -q -I inst2 -s $SUFFIX
|
为 AIX 用户管理准备 LDAP清单 11. 加载 NIS 模式1
2
| file="etc/security/ldap/nisSchema.ldif"
$ITDS/bin/ldapmodify -c -v -a -h host1 -p 20389 -D cn=rootdn -w rootdnpwd -f $file
|
清单 12. 加载 AIX 安全模式1
2
| file="etc/security/ldap/sec.ldif"
$ITDS/bin/ldapmodify -c -v -a -h host1 -p 20389 -D cn=rootdn -w rootdnpwd -f $file
|
在 inst1 和 inst2 实例上加载 /etc/passwd 用户群
使用以下程序序列准备一个 Perl 脚本:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| #!/usr/bin/perl
open(SEC,"< /etc/security/passwd");
@usr = <SEC>;
close(SEC);
chomp(@usr);
foreach $line (@usr) {
if ( $line =~ /(\w):/ ) {
$line =~ s/://;
$uid = $line;
}
if ( $line =~ /lastupdate/ ) {
@row = split("=",$line);
$row[1] += 0;
$lastupdate{$uid} = $row[1];
}
}
$file = "/opt/usrmgt/lib/secinit.ldif";
print("Creating $file containing initial user base ...\n")
$cmd = "/usr/sbin/sectoldif -d \"$SUFFIX\" -S rfc2307aix";
print("Command: $cmd\n");
open(SEC,"$cmd |");
@sec = <SEC>;
close(SEC);
chomp(@sec);
open(SEC,"> $file");
foreach $line (@sec) {
@row = split(":",$line);
if ( $line =~ /^uid:/ ) {
$uid = $row[1];
$uid =~ s/\s+//;
}
if ( $line =~ /^memberuid/ ) {
$row[1] =~ s/ //g;
print(SEC "$row[0]: uid=$row[1],ou=People,$SUFFIX\n");
} elsif ( $line =~ /^shadowlastchange/ ) {
print(SEC "shadowlastchange: $lastupdate{$uid}\n");
} else {
print(SEC "$line\n");
}
}
close(SEC);
print("Loading $file in LDAP Directory Server inst1 ...\n");
$baseauth = "-h host1 -p 20389 -D cn=rootdn -w rootdnpwd";
$cmd = "$ITDS/bin/ldapadd -c -v -a $baseauth -f $file";
print("Command: $cmd\n");
system("$cmd");
print("Loading $file in LDAP Directory Server inst2 ...\n");
$baseauth = "-h host2 -p 20389 -D cn=rootdn -w rootdnpwd";
$cmd = "$ITDS/bin/ldapadd -c -v -a $baseauth -f $file";
print("Command: $cmd\n");
system("$cmd");
|
设置 inst1 和 inst2 之间的对等复制
定义基础复制上下文
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| #!/usr/bin/perl
$ldif = "/opt/usrmgt/logs/suffix_replication.ldif";
open(LDIF,"> $ldif");
print(LDIF "dn: $SUFFIX\n");
print(LDIF "changetype: modify\n");
print(LDIF "add: objectclass\n");
print(LDIF "objectclass: ibm-replicationContext\n");
close(LDIF);
$baseauth = "-h host1 -p 20389 -D cn=rootdn -w rootdnpwd";
$cmd = "$ITDS/bin/ldapmodify -v $baseauth -k -l -i $ldif";
print("Executing $cmd ...\n");
system($cmd);
$baseauth = "-h host2 -p 20389 -D cn=rootdn -w rootdnpwd";
$cmd = "$ITDS/bin/ldapmodify -v $baseauth -k -l -i $ldif";
print("Executing $cmd ...\n");
system($cmd);
|
配置主复制 DN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| #!/usr/bin/perl
$ldif = "$SOURCE/logs/master_replication_dn.ldif";
open(LDIF,"> $ldif");
print(LDIF "dn: cn=MasterServer,cn=configuration\n");
print(LDIF "cn: MasterServer\n");
print(LDIF "ibm-slapdMasterDN: cn=masterdn\n");
print(LDIF "ibm-slapdMasterPW: masterdnpwd \n");
print(LDIF "objectclass: ibm-slapdReplication\n");
print(LDIF "objectclass: ibm-slapdConfigEntry\n");
print(LDIF "objectclass: top\n");
close(LDIF);
$baseauth = "-h host1 -p 20389 -D cn=rootdn -w rootdnpwd";
$cmd = "$ITDS/bin/idsldapadd $baseauth -i $ldif";
print("Executing $cmd ...\n");
system($cmd);
$baseauth = "-h host2 -p 20389 -D cn=rootdn -w rootdnpwd";
$cmd = "$ITDS/bin/idsldapadd $baseauth -i $ldif";
print("Executing $cmd ...\n");
system($cmd);
|
|