自作クラスタ計算機:openldapを使ったldapサーバの基本設定

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
自作クラスタ計算機:openldapを使ったldapサーバの基本設定 [2026/07/03 00:48] koudai自作クラスタ計算機:openldapを使ったldapサーバの基本設定 [2026/07/09 02:07] (current) – [LDAPクライアント] koudai
Line 9: Line 9:
  
 ===== OpenLDAPのインストールと初期設定 ===== ===== OpenLDAPのインストールと初期設定 =====
- 
-(UFWを使用している場合)LDAPサーバ用のポートを開放 
-<code> 
-$ sudo ufw allow ldap 
-</code> 
  
 ソフトウェアのインストール ソフトウェアのインストール
Line 31: Line 26:
  
   * Omit OpenLDAP server Configuration?: No   * Omit OpenLDAP server Configuration?: No
-  * DNS domain name: cluster.internal+  * DNS domain name: cluster.internal など(任意) 
 +    * プライベートLANの名前と思えばよい。
     * 世の中(インターネットの中)にある他のドメイン名と衝突しなければなんでもよい。     * 世の中(インターネットの中)にある他のドメイン名と衝突しなければなんでもよい。
-    * そのため、固定IPと対応するドメイン名をもらったのなら、それを使うのが一般的。 +    * そのため、固定IPと対応する公開ドメイン名をもらったのなら、それを使うのが一般的。 
-      * たとえば、固定IPとともに toaru.daigaku.ac.jp というドメイン名をもらったのならそのまま使ってよいが、管理ノードの個別名と明確に区別したいということであれば、 cluster.toaru.daigaku.ac.jp みたいにする。+      * たとえば、固定IPとともに taro-lab.phys.daigaku.ac.jp という公開ドメイン名をもらったとして、そのまま使うのありだし、管理ノードの個別名と明確に区別したいということであれば cluster.taro-lab.phys.daigaku.ac.jp みたいにする。
     * LDAPサーバーがプライベートLANで閉じることが確約しているのなら、hogehoge.internal や hogehoge.home.arpa が広く使われている、らしい     * LDAPサーバーがプライベートLANで閉じることが確約しているのなら、hogehoge.internal や hogehoge.home.arpa が広く使われている、らしい
       * https://en.wikipedia.org/wiki/.internal       * https://en.wikipedia.org/wiki/.internal
Line 91: Line 87:
   * ユーザー   * ユーザー
   * グループ   * グループ
-  * ホスト名(Kea DHCPを使用した場合) 
 を管理します。 を管理します。
  
Line 155: Line 150:
 ===== ユーザーの追加 ===== ===== ユーザーの追加 =====
  
-ユーザーの初期パスワードを設定する。+ハッシュ化されたユーザーの初期パスワードを設定する。
  
 <code> <code>
Line 219: Line 214:
 $ ldapdelete -x -W -D "cn=admin,dc=cluster,dc=internal" 'uid=taro,ou=people,dc=cluster,dc=internal' $ ldapdelete -x -W -D "cn=admin,dc=cluster,dc=internal" 'uid=taro,ou=people,dc=cluster,dc=internal'
 </code> </code>
- 
- 
-===== ホストの追加 ===== 
- 
-LDIFファイルは必要な分だけ書いてください。 
- 
-<file - hosts.ldif> 
-dn: cn=head,ou=hosts,dc=cluster,dc=internal 
-objectClass: top 
-objectClass: ipHost 
-objectClass: device 
-cn: head 
-ipHostNumber: 192.168.0.1 
- 
-dn: cn=node11,ou=hosts,dc=cluster,dc=internal 
-objectClass: top 
-objectClass: ipHost 
-objectClass: device 
-cn: node11 
-ipHostNumber: 192.168.0.11 
- 
-dn: cn=node12,ou=hosts,dc=cluster,dc=internal 
-objectClass: top 
-objectClass: ipHost 
-objectClass: device 
-cn: node12 
-ipHostNumber: 192.168.0.12 
-</file> 
- 
-登録 
- 
-<code> 
-$ ldapadd -x -D "cn=admin,dc=cluster,dc=internal" -W -f hosts.ldif 
-</code> 
- 
  
 確認 確認
Line 273: Line 233:
     * LDAP server URI: ldap://192.168.0.1/     * LDAP server URI: ldap://192.168.0.1/
     * LDAP server search base: dc=cluster,dc=internal     * LDAP server search base: dc=cluster,dc=internal
-    * Name services to configure: passwd, group, shadow, hosts (スペースキーでチェックを入れられます) +    * Name services to configure: passwd, group, shadow (スペースキーでチェックを入れられます) 
-  - 管理ノードのみ実行<code>+  - 管理ノードのみ)PAM(Pluggable Authentication Modules)の認証設定<code>
 $ sudo pam-auth-update $ sudo pam-auth-update
 </code> </code>
     * 「LDAP Authentication」を有効化(通常は自動で有効化済み)     * 「LDAP Authentication」を有効化(通常は自動で有効化済み)
     * Create home directory on login を有効化     * Create home directory on login を有効化
-  - nscd+nslcdを再起動<code>+  - (管理ノードのみ)nscd+nslcdを再起動<code>
 $ sudo systemctl restart nslcd nscd $ sudo systemctl restart nslcd nscd
 </code> </code>
Line 290: Line 250:
 </code> </code>
     * uidとgidが見えます。     * uidとgidが見えます。
-  - ホストが反映されているか確認<code> 
-$ getent hosts 
-</code> 
   - ユーザーに切り替えるには<code>   - ユーザーに切り替えるには<code>
 $ su - taro $ su - taro
Line 341: Line 298:
 $ sudo systemctl reload apparmor $ sudo systemctl reload apparmor
 </code> </code>
 +
 +
 +
 +
 +
 +
 +
 +
 +====== おまけ ======
 +
 +===== ホスト名の共有 =====
 +
 +LDAPでは、ユーザー情報だけでなくホスト名も共有できます。
 +通常はDNSサーバーを使って名前解決すべきなのであまり推奨されません。
 +しかし、DNSサーバーを立てる必要がない分だけ楽にクラスター計算機が構築できます。
 +
 +==== 管理ノードでの作業 ====
 +
 +  - LDAPでホスト情報を扱えるようにする。<file - base-hosts.ldif>
 +dn: ou=hosts,dc=cluster,dc=internal
 +objectClass: organizationalUnit
 +ou: hosts
 +</file><code>
 +$ ldapadd -x -D cn=admin,dc=cluster,dc=internal -W -f base-hosts.ldif
 +</code>
 +  - 個別のホスト情報を登録(LDIFファイルには必要な分だけ書いてください。)<file - hosts.ldif>
 +dn: cn=head,ou=hosts,dc=cluster,dc=internal
 +objectClass: top
 +objectClass: ipHost
 +objectClass: device
 +cn: head
 +ipHostNumber: 192.168.0.1
 +
 +dn: cn=node11,ou=hosts,dc=cluster,dc=internal
 +objectClass: top
 +objectClass: ipHost
 +objectClass: device
 +cn: node11
 +ipHostNumber: 192.168.0.11
 +
 +dn: cn=node12,ou=hosts,dc=cluster,dc=internal
 +objectClass: top
 +objectClass: ipHost
 +objectClass: device
 +cn: node12
 +ipHostNumber: 192.168.0.12
 +</file><code>
 +$ ldapadd -x -D "cn=admin,dc=cluster,dc=internal" -W -f hosts.ldif
 +</code>
 +
 +
 +
 +==== 管理・計算ノードでの作業 ====
 +
 +libnss-ldapdをインストールするときにhostsも共有するか聞かれますが、そこで共有しないようにしてしまった人向け。
 +
 +
 +  - /etc/nsswitch.confのhostsにldapを追加<file - /etc/nsswitch.conf>
 +# /etc/nsswitch.conf
 +#
 +# Example configuration of GNU Name Service Switch functionality.
 +# If you have the `glibc-doc-reference' and `info' packages installed, try:
 +# `info libc "Name Service Switch"' for information about this file.
 +
 +passwd:         files systemd ldap
 +group:          files systemd ldap
 +shadow:         files systemd ldap
 +gshadow:        files systemd
 +
 +hosts:          files dns ldap
 +networks:       files
 +
 +protocols:      db files
 +services:       db files
 +ethers:         db files
 +rpc:            db files
 +
 +netgroup:       nis
 +</file>
 +  - nscd, nslcdの再起動<code>
 +$ sudo systemctl restart nslcd nscd
 +</code>
 +  - ホストが反映されているか確認<code>
 +$ getent hosts
 +</code>
 +
 +
 +
 +
 ====== 参考資料 ====== ====== 参考資料 ======
  
   * https://server-network-note.net/2022/11/openldap-client-ubuntu22-04lts-server/   * https://server-network-note.net/2022/11/openldap-client-ubuntu22-04lts-server/
   * https://zenn.dev/iasl/articles/1d35c87a66ee35   * https://zenn.dev/iasl/articles/1d35c87a66ee35
自作クラスタ計算機/openldapを使ったldapサーバの基本設定.1783007317.txt.gz · Last modified: 2026/07/03 00:48 by koudai