天天看点

RHDS或centos-ds或389目录服务安装总结

1、理论基础

1.1、概念

RHDS是Red Hat Directory Service的简称,如果基于CentOS系统其别名为centos-ds或389目录服务,是一套基于openldap的企业目录服务。

1.2、功能

- 代替LDAP

- 同步微软的活动目录信息

1.3、目录结构

<a href="http://s3.51cto.com/wyfs02/M01/7F/5F/wKioL1ccdkGi-8X5AABkShordpI912.png" target="_blank"></a>

1.4、服务的控制

1.4.1、启动目录控制台命令

1

2

3

4

5

<code>redhat-idm-console</code>

<code>redhat-idm-console -a http:</code><code>//localhost</code><code>:9830</code>

<code>centos-idm-console</code>

<code>centos-idm-console -a http:</code><code>//localhost</code><code>:9830</code>

<code>389-console</code>

注:以上由于历史原因,命令需根据系统的版本选择

1.4.2、命令行方式

6

<code>service dirsrv {start|stop|restart} instance</code>

<code>/usr/sbin/</code><code>{start|stop|restart}-dirsrv instance</code>

<code>/etc/dirsrv/slapd-instance_name/</code><code>{start|stop|restart}-slapd</code>

<code>/usr/sbin/</code><code>{start|stop|restart}-ds-admin</code>

<code>service dirsrv-admin {start|stop|restart}</code>

1.5、工具的使用

<code>ldapmodify -a -D </code><code>"cn=directory manager"</code> <code>-w secret -p 389 -h server.example.com</code>

2、实践部分

2.1、环境配置

2.1.1、主机名称和IP配置

OS=CentOS-5 x86_64 或 CentOS-6 x86_64

hostname=ds.cmdschool.org

ipaddress=10.168.0.155

2.1.2、yum的配置

1)CentOS 5的安装默认版本

默认版本安装

<code>yum groupinstall -y </code><code>'X Window System'</code> <code>'GNOME Desktop Environment'</code>

<code>yum </code><code>install</code> <code>-y centos-ds*</code>

2)CentOS 5安装8.1版

vim编辑/etc/yum.repos.d/CentOS-Extras.repo指定yum源

<code>[CentOS-Extras]</code>

<code>name=CentOS-Extras</code>

<code>baseurl=http:</code><code>//vault</code><code>.centos.org</code><code>/5</code><code>.4</code><code>/extras/x86_64/</code>

<code>gpgcheck=0</code>

<code>enabled=1</code>

安装8.1版

<code>yum </code><code>install</code> <code>-y centos-ds-8.1.0 centos-ds-admin-8.1.0 centos-ds-base-8.1.0 centos-ds-base-devel-8.1.0 centos-ds-console-8.1.0 centos-admin-console-8.1.0</code>

3)CentOS 6的安装默认版本

<code>yum groupinstall -y </code><code>'X Window System'</code> <code>Desktop</code>

<code>yum </code><code>install</code> <code>-y tigervnc-server</code>

<code>yum </code><code>install</code> <code>-y 389*</code>

2.1.3、配置域名解析和主机名称

vim /etc/hosts

<code>127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 ds.cmdschool.org ds</code>

<code>::1         localhost localhost.localdomain localhost6 localhost6.localdomain6</code>

<code>10.168.0.155 ds.cmdschool.org ds</code>

vim /etc/sysconfig/network

<code>HOSTNAME=ds.cmdschool.org</code>

注意(DNS全域名要写前面)

2.1.4、检查进程可打开文件句柄数量

<code>cat</code> <code>/proc/sys/fs/file-max</code>

修改如下参数让其大于64000配置

<code>fs.</code><code>file</code><code>-max = 64000</code>

2.1.5、增加打开文件最大数目限制

vim编辑/etc/security/limits.conf

<code>*        -        nofile        8192</code>

2.1.6、配置密码复杂度

vim编辑/etc/pam.d/system-auth,增加如下内容:

<code>session required </code><code>/lib/security/</code><code>$ISA</code><code>/pam_limits</code><code>.so</code>

2.1.7、重启系统

<code>reboot</code>

2.1.8、配置VNC

1) 配置VNC服务

vim编辑/etc/sysconfig/vncservers

去掉以下两行的注释并修改VNCSERVERS 的参数,详见如下:

<code>VNCSERVERS=</code><code>"1:root"</code>

<code>VNCSERVERARGS[2]=</code><code>"-geometry 800x600 -nolisten tcp -nohttpd -localhost"</code>

设置VNC密码

<code>vncpasswd</code>

启动服务并

<code>/etc/init</code><code>.d</code><code>/vncserver</code> <code>start</code>

<code> </code><code>chkconfig vncserver on</code>

2)CentOS 5配置

vim编辑~/.vnc/xstartup

并修改如下:

<code>#twm &amp;</code>

<code>gnome-session &amp;</code>

vim编辑/etc/sysconfig/iptables配置防火墙规则

<code>-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT</code>

3)CentOS 6 配置

<code>-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT</code>

4)重启防火墙

<code>/etc/init</code><code>.d</code><code>/iptables</code> <code>restart</code>

2.2、实例初始化

使用如下命令初始化:

<code>setup-ds-admin.pl</code>

向导如下:

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

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

<code>==============================================================================</code>

<code>This program will </code><code>set</code> <code>up the CentOS Directory and Administration Servers.</code>

<code>It is recommended that you have </code><code>"root"</code> <code>privilege to </code><code>set</code> <code>up the software.</code>

<code>Tips </code><code>for</code> <code>using this program:</code>

<code>  </code><code>- Press </code><code>"Enter"</code> <code>to choose the default and go to the next </code><code>screen</code>

<code>  </code><code>- Type </code><code>"Control-B"</code> <code>then</code> <code>"Enter"</code> <code>to go back to the previous </code><code>screen</code>

<code>  </code><code>- Type </code><code>"Control-C"</code> <code>to cancel the setup program</code>

<code>Would you like to </code><code>continue</code> <code>with </code><code>set</code> <code>up? [</code><code>yes</code><code>]:</code>

<code>BY SETTING UP AND USING THIS SOFTWARE YOU ARE CONSENTING TO BE BOUND BY</code>

<code>AND ARE BECOMING A PARTY TO THE AGREEMENT FOUND IN THE</code>

<code>LICENSE.TXT FILE. IF YOU DO NOT AGREE TO ALL OF THE TERMS</code>

<code>OF THIS AGREEMENT, PLEASE DO NOT SET UP OR USE THIS SOFTWARE.</code>

<code>Do you agree to the license terms? [no]: </code><code>yes</code>

<code>Your system has been scanned </code><code>for</code> <code>potential problems, missing patches,</code>

<code>etc.  The following output is a report of the items found that need to</code>

<code>be addressed before running this software </code><code>in</code> <code>a production</code>

<code>environment.</code>

<code>CentOS Directory Server system tuning analysis version 10-AUGUST-2007.</code>

<code>NOTICE : System is x86_64-unknown-linux2.6.18-164.el5 (1 processor).</code>

<code>WARNING: 998MB of physical memory is available on the system. 1024MB is recommen                                                                                                                                                             ded </code><code>for</code> <code>best performance on large production system.</code>

<code>NOTICE : The net.ipv4.tcp_keepalive_time is </code><code>set</code> <code>to 7200000 milliseconds</code>

<code>(120 minutes).  This may cause temporary server congestion from lost</code>

<code>client connections.</code>

<code>Would you like to </code><code>continue</code><code>? [no]: </code><code>yes</code>

<code>Choose a setup </code><code>type</code><code>:</code>

<code>   </code><code>1. Express</code>

<code>       </code><code>Allows you to quickly </code><code>set</code> <code>up the servers using the most</code>

<code>       </code><code>common options and pre-defined defaults. Useful </code><code>for</code> <code>quick</code>

<code>       </code><code>evaluation of the products.</code>

<code>   </code><code>2. Typical</code>

<code>       </code><code>Allows you to specify common defaults and options.</code>

<code>   </code><code>3. Custom</code>

<code>       </code><code>Allows you to specify </code><code>more</code> <code>advanced options. This is</code>

<code>       </code><code>recommended </code><code>for</code> <code>experienced server administrators only.</code>

<code>To accept the default shown </code><code>in</code> <code>brackets, press the Enter key.</code>

<code>Choose a setup </code><code>type</code> <code>[2]: 2</code>

<code>Enter the fully qualified domain name of the computer</code>

<code>on </code><code>which</code> <code>you're setting up server software. Using the form</code>

<code>&lt;</code><code>hostname</code><code>&gt;.&lt;domainname&gt;</code>

<code>Example: eros.example.com.</code>

<code>Computer name [ds.cmdschool.org]:</code>

<code>The servers must run as a specific user </code><code>in</code> <code>a specific group.</code>

<code>It is strongly recommended that this user should have no privileges</code>

<code>on the computer (i.e. a non-root user).  The setup procedure</code>

<code>will give this user</code><code>/group</code> <code>some permissions </code><code>in</code> <code>specific paths</code><code>/files</code>

<code>to perform server-specific operations.</code>

<code>If you have not yet created a user and group </code><code>for</code> <code>the servers,</code>

<code>create this user and group using your native operating</code>

<code>system utilities.</code>

<code>System User [nobody]:</code>

<code>System Group [nobody]:</code>

<code>Server information is stored </code><code>in</code> <code>the configuration directory server.</code>

<code>This information is used by the console and administration server to</code>

<code>configure and manage your servers.  If you have already </code><code>set</code> <code>up a</code>

<code>configuration directory server, you should register any servers you</code>

<code>set</code> <code>up or create with the configuration server.  To </code><code>do</code> <code>so, the</code>

<code>following information about the configuration server is required: the</code>

<code>fully qualified host name of the form</code>

<code>&lt;</code><code>hostname</code><code>&gt;.&lt;domainname&gt;(e.g. </code><code>hostname</code><code>.example.com), the port number</code>

<code>(default 389), the suffix, the DN and password of a user having</code>

<code>permission to write the configuration information, usually the</code>

<code>configuration directory administrator, and </code><code>if</code> <code>you are using security</code>

<code>(TLS</code><code>/SSL</code><code>).  If you are using TLS</code><code>/SSL</code><code>, specify the TLS</code><code>/SSL</code> <code>(LDAPS) port</code>

<code>number (default 636) instead of the regular LDAP port number, and</code>

<code>provide the CA certificate (</code><code>in</code> <code>PEM</code><code>/ASCII</code> <code>format</code><code>).</code>

<code>If you </code><code>do</code> <code>not yet have a configuration directory server, enter </code><code>'No'</code> <code>to</code>

<code>be prompted to </code><code>set</code> <code>up one.</code>

<code>Do you want to register this software with an existing</code>

<code>configuration directory server? [no]:</code>

<code>Please enter the administrator ID </code><code>for</code> <code>the configuration directory</code>

<code>server.  This is the ID typically used to log </code><code>in</code> <code>to the console.  You</code>

<code>will also be prompted </code><code>for</code> <code>the password.</code>

<code>Configuration directory server</code>

<code>administrator ID [admin]:</code>

<code>Password:</code>

<code>Password (confirm):</code>

<code>The information stored </code><code>in</code> <code>the configuration directory server can be</code>

<code>separated into different Administration Domains.  If you are managing</code>

<code>multiple software releases at the same </code><code>time</code><code>, or managing information</code>

<code>about multiple domains, you may use the Administration Domain to keep</code>

<code>them separate.</code>

<code>If you are not using administrative domains, press Enter to </code><code>select</code> <code>the</code>

<code>default.  Otherwise, enter some descriptive, unique name </code><code>for</code> <code>the</code>

<code>administration domain, such as the name of the organization</code>

<code>responsible </code><code>for</code> <code>managing the domain.</code>

<code>Administration Domain [cmdschool.org]:</code>

<code>The standard directory server network port number is 389.  However, </code><code>if</code>

<code>you are not logged as the superuser, or port 389 is </code><code>in</code> <code>use, the</code>

<code>default value will be a random unused port number greater than 1024.</code>

<code>If you want to use port 389, </code><code>make</code> <code>sure that you are logged </code><code>in</code> <code>as the</code>

<code>superuser, that port 389 is not </code><code>in</code> <code>use.</code>

<code>Directory server network port [389]:</code>

<code>Each instance of a directory server requires a unique identifier.</code>

<code>This identifier is used to name the various</code>

<code>instance specific files and directories </code><code>in</code> <code>the </code><code>file</code> <code>system,</code>

<code>as well as </code><code>for</code> <code>other uses as a server instance identifier.</code>

<code>Directory server identifier [ds]:</code>

<code>The suffix is the root of your directory tree.  The suffix must be a valid DN.</code>

<code>It is recommended that you use the </code><code>dc</code><code>=domaincomponent suffix convention.</code>

<code>For example, </code><code>if</code> <code>your domain is example.com,</code>

<code>you should use </code><code>dc</code><code>=example,</code><code>dc</code><code>=com </code><code>for</code> <code>your suffix.</code>

<code>Setup will create this initial suffix </code><code>for</code> <code>you,</code>

<code>but you may have </code><code>more</code> <code>than one suffix.</code>

<code>Use the directory server utilities to create additional suffixes.</code>

<code>Suffix [</code><code>dc</code><code>=cmdschool, </code><code>dc</code><code>=org]:</code>

<code>Certain directory server operations require an administrative user.</code>

<code>This user is referred to as the Directory Manager and typically has a</code>

<code>bind Distinguished Name (DN) of cn=Directory Manager.</code>

<code>You will also be prompted </code><code>for</code> <code>the password </code><code>for</code> <code>this user.  The password must</code>

<code>be at least 8 characters long, and contain no spaces.</code>

<code>Press Control-B or </code><code>type</code> <code>the word </code><code>"back"</code><code>, </code><code>then</code> <code>Enter to back up and start over.</code>

<code>Directory Manager DN [cn=Directory Manager]:</code>

<code>The Administration Server is separate from any of your web or application</code>

<code>servers since it listens to a different port and access to it is</code>

<code>restricted.</code>

<code>Pick a port number between 1024 and 65535 to run your Administration</code>

<code>Server on. You should NOT use a port number </code><code>which</code> <code>you plan to</code>

<code>run a web or application server on, rather, </code><code>select</code> <code>a number </code><code>which</code> <code>you</code>

<code>will remember and </code><code>which</code> <code>will not be used </code><code>for</code> <code>anything </code><code>else</code><code>.</code>

<code>Administration port [9830]:</code>

<code>The interactive phase is complete.  The script will now </code><code>set</code> <code>up your</code>

<code>servers.  Enter No or go Back </code><code>if</code> <code>you want to change something.</code>

<code>Are you ready to </code><code>set</code> <code>up your servers? [</code><code>yes</code><code>]:</code>

<code>Creating directory server . . .</code>

<code>Your new DS instance </code><code>'ds'</code> <code>was successfully created.</code>

<code>Creating the configuration directory server . . .</code>

<code>Beginning Admin Server creation . . .</code>

<code>Creating Admin Server files and directories . . .</code>

<code>Updating adm.conf . . .</code>

<code>Updating admpw . . .</code>

<code>Registering admin server with the configuration directory server . . .</code>

<code>Updating adm.conf with information from configuration directory server . . .</code>

<code>Updating the configuration </code><code>for</code> <code>the httpd engine . . .</code>

<code>Starting admin server . . .</code>

<code>The admin server was successfully started.</code>

<code>Admin server was successfully created, configured, and started.</code>

<code>Exiting . . .</code>

<code>Log </code><code>file</code> <code>is </code><code>'/tmp/setupcf5R61.log'</code>

2.3、检查和设置服务自动启动

<code> </code><code>/etc/init</code><code>.d</code><code>/dirsrv</code> <code>status</code>

<code> </code><code>/etc/init</code><code>.d</code><code>/dirsrv-admin</code> <code>status</code>

<code> </code><code>chkconfig dirsrv on</code>

<code> </code><code>chkconfig dirsrv-admin on</code>

2.4、防火墙配置

2.4.1、编辑防火墙规则

1)CentOS 5

vim编辑/etc/sysconfig/iptables

<code>-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 389 -j ACCEPT</code>

<code>-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 9830 -j ACCEPT</code>

2)CentOS 6

<code>-A INPUT -m state --state NEW -m tcp -p tcp --dport 389 -j ACCEPT</code>

<code>-A INPUT -m state --state NEW -m tcp -p tcp --dport 9830 -j ACCEPT</code>

2.4.1、重启防火墙

2.5、启动控制台

1)官方资料

官方文档

<a href="https://access.redhat.com/documentation/en/red-hat-directory-server/" target="_blank">https://access.redhat.com/documentation/en/red-hat-directory-server/</a>

<a href="http://directory.fedoraproject.org/docs/389ds/releases/release-passsync-1-1-6.html" target="_blank">http://directory.fedoraproject.org/docs/389ds/releases/release-passsync-1-1-6.html</a>

<a href="https://technet.microsoft.com/zh-cn/library/cc773087(WS.10).aspx" target="_blank">https://technet.microsoft.com/zh-cn/library/cc773087(WS.10).aspx</a>

官方yum源:

<a href="https://wiki.centos.org/Download" target="_blank">https://wiki.centos.org/Download</a>

2)非官方资料:

<a href="http://candon123.blog.51cto.com/704299/578504/" target="_blank">http://candon123.blog.51cto.com/704299/578504/</a>

3)实例损毁的修复

<a href="https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.1/html/Installation_Guide/Installation_Guide-Advanced_Configuration-Reregistering-with-Config-DS.html" target="_blank">https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.1/html/Installation_Guide/Installation_Guide-Advanced_Configuration-Reregistering-with-Config-DS.html</a>

4)DS之间的复制

<a href="https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.1/html/Administration_Guide/Managing_Replication.html" target="_blank">https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.1/html/Administration_Guide/Managing_Replication.html</a>

5)DS与AD的同步程序下载

<a href="http://directory.fedoraproject.org/docs/389ds/download.html" target="_blank">http://directory.fedoraproject.org/docs/389ds/download.html</a>

6)DS与AD同步程序的配置

<a href="https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.1/html/Administration_Guide/Windows_Sync-Configuring_Windows_Sync.html" target="_blank">https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.1/html/Administration_Guide/Windows_Sync-Configuring_Windows_Sync.html</a>

7)DS与AD同步非官方教程

<a href="http://www.leo-zh.com/70" target="_blank">http://www.leo-zh.com/70</a>

8) 目录结构

<a href="https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.1/html/Installation_Guide/Installation_Guide-Common_Usage.html" target="_blank">https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.1/html/Installation_Guide/Installation_Guide-Common_Usage.html</a>

9)项目源代码

<a href="http://directory.fedoraproject.org/docs/389ds/development/source.html" target="_blank">http://directory.fedoraproject.org/docs/389ds/development/source.html</a>

10)win2008证书服务器的派发

<a href="http://wangchunhai.blog.51cto.com/225186/139451/" target="_blank">http://wangchunhai.blog.51cto.com/225186/139451/</a>

本文转自 tanzhenchao 51CTO博客,原文链接:http://blog.51cto.com/cmdschool/1761441,如需转载请自行联系原作者

继续阅读