移転しました

独自ドメインサイトへ移行しました。5秒後に

https://straypenguin.winfield-net.com/

へジャンプします。

ディレクトリサーバのマルチインスタンス化

ディレクトリサーバインスタンスを追加して複数インスタンス化する手順。ここでは、追加インスタンスは TCPポート 1389 をリッスンさせ、メインインスタンスと同じひとつの管理サーバ及び設定管理用ディレクトリツリーでマネージメントする例を挙げる。また、追加後には、新インスタンスも Dirctory Server Gateway で日常メンテナンスできるよう、DSGW の設定も調整する。

追加ディレクトリインスタンスのデプロイ

初めてのデプロイで使ったのと同じ setup-ds-admin.pl スクリプトを使用すると、新規ディレクトリインスタンスの作成と管理サーバへの登録がいっぺんにできる。他のやり方としては、setup-ds.pl でインスタンスだけ作成してから register-ds-admin.pl で管理サーバに登録する方法もある。下記に、setup-ds-admin.pl のデプロイ画面のサンプルを抜粋で掲載しておく。スクリプトの実行は root で。

==============================================================================
This program will set up the 389 Directory and Administration Servers.
 
It is recommended that you have "root" privilege to set up the software.
Tips for using this program:
  - Press "Enter" to choose the default and go to the next screen
  - Type "Control-B" then "Enter" to go back to the previous screen
  - Type "Control-C" to cancel the setup program
 
Would you like to continue with set up? [yes]: y
 
Do you agree to the license terms? [no]: y
 
==============================================================================
Your system has been scanned for potential problems, missing patches,
etc.  The following output is a report of the items found that need to
be addressed before running this software in a production
environment.
 
389 Directory Server system tuning analysis version 10-AUGUST-2007.
 
NOTICE : System is x86_64-unknown-linux2.6.18-194.32.1.el5 (1 processor).
 
WARNING: 1002MB of physical memory is available on the system. 1024MB is 
recommended for best performance on large production system.
 
NOTICE : The net.ipv4.tcp_keepalive_time is set to 1800000 milliseconds
(30 minutes).  This may cause temporary server congestion from lost
client connections.
 
WARNING  : The warning messages above should be reviewed before proceeding.
 
Would you like to continue? [no]: y
 
==============================================================================
Choose a setup type:
 
   1. Express
       Allows you to quickly set up the servers using the most
       common options and pre-defined defaults. Useful for quick
       evaluation of the products.
 
   2. Typical
       Allows you to specify common defaults and options.
 
   3. Custom
       Allows you to specify more advanced options. This is 
       recommended for experienced server administrators only.
 
Choose a setup type [2]: 2
 
Computer name [centos5u.hoge.com]: <TCP/IPホスト名。既存インスタンスと同一にする。つまり既定のままEnter>
 
System User [dsadmin]: <「デプロイの準備」で作ったシステムユーザ。既存インスタンスと同じにする>
System Group [dsadmin]: <そのグループ>
 
Do you want to register this software with an existing
configuration directory server? [yes]: y <既存の設定管理ディレクトリツリーに登録するので>
 
Configuration directory server URL [ldap://centos5u.hoge.com:389/o=NetscapeRoot]: <既存の設定管理ディレクトリのldap URLが出るのでそのまま>
Configuration directory server admin ID [uid=admin,ou=Administrators,ou=TopologyManagement,o=NetscapeRoot]: <変更してはいけない>
Configuration directory server admin Password: **** <既存管理サーバのadminパスワードをタイプ>
Configuration directory server Aamin Domain [hoge.com]: <既存のインスタンスと同じにする>
 
Directory server network port [54213]: 1389 <新ディレクトリインスタンスのリッスンポート。他インスタンスと重複しないように>
 
Directory server identifier [centos5u]: newhoge <新ディレクトリインスタンス名。他と重複しない名前に>
 
Suffix [dc=hoge, dc=com]: dc=newhoge,dc=com <新ディレクトリで扱うルートDN。既存インスタンスとの重複も可>
 
Directory Manager DN [cn=Directory Manager]: <新ディレクトリのマネージャDN。インスタンス固有なので変えてもよいが管理は面倒になる>
Password: ****
Password (confirm): ****
 
Administration port [9830]: <管理サーバのHTTPリッスンポート。変更すると既にある管理サーバのポートが変わってしまう>

登録が完了すると、新ディレクトリサーバインスタンスが起動され、管理サーバデーモンが再起動される。389-console で管理サーバに接続すれば、新しいディレクトリサーバインスタンスも見えているはずだ。

なお、上記で既存インスタンスとは別の Directory Manager を設定した場合は、389-console で管理サーバにログインする際には既存のディレクトリマネージャの DN とパスワードでログインする。 そして、当該の新ディレクトリインスタンスを Open しようとした時にあらためて DN とパスワードを求められるので、そこで新マネージャDN とパスワードを入力することになる。

DSGWで追加のインスタンスを扱えるようにする

オフィシャルドキュメントの webapps install でも非常にさら~っと触れられているが、例が適切でなく分かりにくい。検証に基づいてできるだけ詳しく解説してみることにする。

DSGW のページの正体は、Apache で駆動される CGI だ。マルチディレクトリサーバインスタンス化に関係するものを中心にまとめると、ファイル/フォルダ構造は下記のようになっている;

/etc/dirsrv/dsgw/
               \_ dsgw-httpd.conf <DSGWのページに関するhttpd設定ピース。../admin-serv/httpd.confからincludeされる>
                  dsgw.conf       <DSGW CGIの基本設定ファイル>
/usr/share/dirsrv/
               \_ html/
                      \_ admserv.html      <管理サーバWEBのトップページ>
                         admserv_dsgw.html <上記ファイル内のCGIディレクティブによってトップページに挿入される
                                            DSGWへのリンク>
               \_ dsgw/
                      \_ html/   <画像, スタイルシート, 比較的スタティックなhtmlコンテンツなど>
                         config/ <CGIによる置換の素となるhtmlテンプレートや, 検索CGIなどの細かい設定ファイル>

別のディレクトリインスタンスに対する DSGW を追加する場合、ファイル配置にはかなり自由度があり決まった配置があるわけではないが、当解説では、比較的オーソドックスと思われる下記のようなレイアウトを採ることにする;

/etc/dirsrv/dsgw/
               \_ dsgw-httpd.conf <DSGWのページに関するhttpd設定ピース。小修正>
                  dsgw.conf         <DSGW CGIの基本設定ファイル(メインサイト用)>
                  newhoge.conf     <追加インスタンス用のCGI基本設定ファイル>
/usr/share/dirsrv/
               \_ html/
                      \_ admserv.html     <管理サーバWEBのトップページ。小修正>
                         admserv_dsgw.html <上記ファイル内のCGIディレクティブによってトップページに挿入される
                                            DSGWへのリンク(メインサイト用)>
                         admserv_dsgw-newhoge.html <同、追加インスタンス用>
               \_ dsgw/
                      \_ html/   <画像, スタイルシート, 比較的スタティックなhtmlコンテンツなど>
                         config/ <CGIによる置換の素となるhtmlテンプレートや, 検索CGIなどの細かい設定ファイル>
                         newhoge-html/   <追加インスタンス用のhtmlフォルダ(メインサイト用を共用することも可能)>
                         newhoge-config/ <追加インスタンス用のconfigフォルダ>

レイアウト構想が決まったら、/etc/dirsrv/dsgw/dsgw.conf をパーミッション付きでコピーして newhoge.conf を作る。dsgw.conf 及び newhoge.conf は管理サーバHTTPDプロセスのオーナーの所有になっていなければならないことを忘れずに;

root# cp -p dsgw.conf newhoge.conf

newhoge.conf というファイル名は DSGW を表示する時の URL (CGIに渡す引数) と符合しなければならない。DSGW の各ページの URL は、

http://<SERVER>:9830/clients/dsgw/bin/lang?context=dsgw

のような形式になっており、`?context=newhoge ' で CGI を呼んだ時に newhoge.conf が読まれる仕組みになっている。newhoge.conf の変更箇所は以下 (変更する箇所のみ掲載。`#'で始まる行は解説用のコメント);

# 追加ディレクトリインスタンスのポート番号と取り扱いルートDNに修正
baseurl    "ldap://centos5u.hoge.com:1389/dc=newhoge, dc=com"
 
# 追加ディレクトリインスタンスの取り扱いルートDN
location-suffix    "dc=newhoge, dc=com"
 
# contextを合わせる
url-orgchart-base   "http://centos5u.hoge.com:9830/dsgwcmd/org?context=newhoge&amp;data="
 
# htmlフォルダ。取り扱うLDAPオブジェクトクラスなどがメインディレクトリインスタンスと同じで個別のカスタマイズが不要なら、
# メインサイトと共用することも可能。メインサイトと共用しない場合なら
htmldir      "/usr/share/dirsrv/dsgw/newhoge-html"
# メインサイトと共用にするのなら、上記は書かずにデフォルトである下記設定を生かしたままにする
#htmldir      "/usr/share/dirsrv/dsgw/html"
 
# configフォルダ。こちらは共用はできないようだ
configdir    "/usr/share/dirsrv/dsgw/newhoge-config"

# CGIが、画像やスタイルシートなどごく一部のURLを生成する際に使用する、フォルダ接頭辞。Apache設定ファイル側のAlias定義
# と符合させる必要がある。htmlフォルダをメインサイトと共用しない場合
gwnametrans    "/dsgw-newhoge/"
# htmlフォルダをメインサイトと共用にするのなら、デフォルトである下記設定のままにする
#gwnametrans    "/dsgw/"
 
# 初期バインドの設定をしてあり尚且つ新ディレクトリインスタンスでの取り扱いルートDN及び初期バインド用DNがメインサイトと異なる
# 場合は、BINDパスワードファイルを別途作る必要がある
binddnfile    /etc/dirsrv/newhoge-dsgwdn

次に、Apache の設定ファイルである /etc/dirsrv/dsgw/dsgw-httpd.conf にディレクティブを追加する (必要箇所のみ掲載);

Alias /dsgw /usr/share/dirsrv/dsgw/html
# htmlフォルダをメインサイトと共用にしない場合は、dsgw.confの`gwnametrans'で指定したフォルダ接頭辞に符合するAliasを加え、
# その参照先をdsgw.confの`htmldir'にする。共用する場合は追記不要
Alias /dsgw-newhoge /usr/share/dirsrv/dsgw/newhoge-html
Alias /pb /usr/share/dirsrv/dsgw/pbhtml
Alias /org /usr/share/dirsrv/dsgw/orghtml
 
Alias /clients/dsgw/html /usr/share/dirsrv/dsgw/html
# htmlフォルダをメインサイトと共用にしない場合はhtmlフォルダのAliasを追加
Alias /clients/dsgw/newhoge-html /usr/share/dirsrv/dsgw/newhoge-html
Alias /clients/dsgw/pbhtml /usr/share/dirsrv/dsgw/pbhtml
Alias /clients/dsgw/config /usr/share/dirsrv/dsgw/config
# configフォルダのAliasは必ず追加
Alias /clients/dsgw/hoge-config /usr/share/dirsrv/dsgw/newhoge-config
 
# htmlフォルダをメインサイトと共用にしない場合はそのアクセス許可ブロックを追加
<Directory "/usr/share/dirsrv/dsgw/newhoge-html">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
 
# configフォルダへのアクセス許可ブロックを追加
<Directory "/usr/share/dirsrv/dsgw/newhoge-config">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

続いて、管理サーバのWEBサイトトップページに新DSGWサイトへのリンクを追加するための処置を行う。/usr/share/dirsrv/html/admserv.html をエディタで開き、下記のように CGI ディレクティブを挿入する。

...
        <tr>
<!-- INCLUDEIFEXISTS admserv_dsgw.html -->
<!-- INCLUDEIFEXISTS admserv_dsgw-newhoge.html -->
        </tr valign="TOP">
...

そして、/usr/share/dirsrv/html/admserv_dsgw.html をコピーして admserv_dsgw-newhoge.html を作り、内容を修正する;

    <tr valign="top">
      <td><img src="/icons/goto.gif" width="10" height="15">&nbsp;</td>
      <td><font face="Verdana, sans-serif"><a href="/clients/dsgw/bin/lang?context=newhoge">
        Directory Server Gateway (newhoge)</a></font><font size="-1" face=...
        ...
      </font></td>
    </tr>
...

htmlフォルダ (メインサイトと共用にしない場合のみ) と configフォルダを新DSGWサイト用に複製する;

root# cd /usr/share/dirsrv/dsgw
root# cp -a config newhoge-config
root# cp -a html newhoge-html   <--共用にしない場合のみ

※ 試してみたところ、newhoge-config, newhoge-html ともシンボリックリンクでもよかった。

以上、全てが終わったら、`service dirsrv-admin restart' で管理サーバHTTPDデーモンを再起動する。

Directory Server Gatewayのカスタマイズ

mailRecipientオブジェクトクラスへの対応

389 DS にデフォルトで含まれている mailRecipient オブジェクトクラスは、メールサーバのユーザ管理に最適で、しかも上位オブジェクトクラスは Top しか必要とせず使いやすい。しかし、ノーマル状態の DSGW では、このオブジェクトクラスのエントリを登録/検索/削除しようとすると、いちいちオブジェクトクラスを足したり属性を追加したりしなければならず大変だ。そこで DSGW をカスタマイズし、修正点をパッチにまとめた。パッチ作成環境の DSGW バージョンは 1.1.4 (389-dsgw-1.1.4-1.el5)。1.1.6 にも問題なく適用できることを確認した。

カスタマイズ方法に関する説明は DSGW のオフィシャルドキュメントに載っている。

ファイル名 説明
dsgw.conf-mailrecipient.diff /etc/dirsrv/dsgw/dsgw.conf の修正箇所
dsgw-html-moz.patch DSGW の WEBページを Firefox で開いた時にタイトル部のフォーマットが崩れるのを修正する。これに含まれるスタイルシートの修正箇所を下記のパッチでも利用しているので、必ず当てていただきたい (構築時に既に当てているなら再適用は不要)。/usr/share/dirsrv/dsgw/html/ 下のファイルに修正を加える
dsgw-config-mailrecipient.patch /usr/share/dirsrv/dsgw/config/ 下のファイルへのパッチ
root# patch -d /etc/dirsrv/dsgw <dsgw.conf-mailrecipient.diff
root# patch -p1 -d /usr/share/dirsrv/dsgw/html <dsgw-html-moz.patch
root# patch -p1 -d /usr/share/dirsrv/dsgw/config \
      <dsgw-config-mailrecipient.patch

適用後には管理サーバデーモンの再起動が必要。

ユーザエントリが登録できない!

素の DSGW 1.1.4 では、DSGW からは PersonNtPersoninetOrgPerson も正常に登録できない。これは AOL の呪い。ノーマルの DSGW では nsAimPresence というオブジェクトクラスを使おうとしている。このオブジェクトクラスは、その人の AOLインスタントメッセンジャー (AIM) でのログイン状態を管理するためのものらしいが、最近の 389 DS では AIM サポートが中途半端に削除されているため、エントリの登録に失敗するのだ。まったく余計なことをしてくれる。DSGW 1.1.6 では下記の部分は既にコメントアウトされていた。

解決法は比較的簡単で、/usr/share/dirsrv/dsgw/config/ にある display-*person.html ファイルから、

<INPUT TYPE="hidden" NAME="add_objectClass" VALUE="nsaimpresence">

という 1行を削除してやるだけ。いちおうパッチも採っておいたので使いたいかたはどうぞ。パッチ作成環境の DSGW バージョンは 1.1.4 (389-dsgw-1.1.4-1.el5)。

また、/etc/dirsrv/dsgw/dsgw.conf の下記のパラメータも false にしておいたほうがいい。

DSGW 1.1.4 の場合

enable-aim-presence    false 

DSGW 1.1.6 (以降?) の場合

enable-aim-presence    false
have-aim-schema    false