User Tools

Site Tools


自作クラスタ計算機:nisの基本設定

Differences

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

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
自作クラスタ計算機:nisの基本設定 [2020/02/25 21:44]
koudai 作成
自作クラスタ計算機:nisの基本設定 [2021/01/24 06:32]
koudai
Line 1: Line 1:
 ====== 概要 ====== ====== 概要 ======
  
-  * プライベートLAN内でコンピュータの設定を共有するシステムをNetwork Information Service (NIS) と呼 +  * プライベートLAN内でコンピュータの設定(ユーザー情報など)を共有するシステムをNetwork Information Service (NIS) と呼びます 
-  * 複数人でクラスタ計算機を使用するとき、計算ノードごとに各自のアカウントを作成するのは非常に手間であるので、このシステムを使+  * 複数人でクラスタ計算機を使用するとき、それぞれの計算ノードに各自のアカウントを一つずつ作成するのは非常に手間であるので、このシステムを使います 
 +  * 共有する設定を管理するサーバをNISサーバと呼び、今回は管理ノードをその役割に当てます
  
  
Line 12: Line 13:
 sudo apt install nis sudo apt install nis
 </code> </code>
 +    * 途中でNISドメイン名というものを聞かれので kanri.nis などとする。
 +    * NISドメイン名は設定を共有するコンピュータのグループの名前のことであり、IPネットワークで使われるドメイン名とはまったく関係ありません
 +    * NISドメイン名は /etc/defaultdomain に保存されるので、変更したくなったらこのファイルを編集してください
 +  - /etc/defalut/nis に管理ノードをNISサーバとすることを指定する<code>
 +$ sudo vi /etc/defalut/nis
 +</code><file - nis>
 +...
 +# Are we a NIS server and if so what kind (values: false, slave, master)?
 +NISSERVER=master
 +
 +# Are we a NIS client?
 +NISCLIENT=false
 +...
 +</file>
 +  - /etc/yp.conf にNISサーバのIPアドレスまたはホスト名を指定する<code>
 +$ sudo vi /etc/yp.conf
 +</code><file - yp.conf>
 +ypserver 192.168.0.1
 +</file>
 +  - /etc/ypserv.securenets の最終行をプライベートLANのネットマスクとIPアドレスに変更する<code>
 +$ sudo vi /etc/ypserv.securenets
 +</code><file - ypserv.securenets>
 +(略)
 +# This line gives access to everybody. PLEASE ADJUST!
 +#0.0.0.0 0.0.0.0
 +255.255.255.0 192.168.0.0
 +</file>
 +    * これによりプライベートネットワークからのみNISサーバへの接続を許可します
 +  - NISを再起動します<code>
 +$ sudo systemctl restart rpcbind nis 
 +</code>
 +  - NISデータベースを更新する<code>
 +$ sudo /usr/lib/yp/ypinit -m
 +
 +At this point, we have to construct a list of the hosts which will run NIS
 +servers.  kanri is in the list of NIS server hosts.  Please continue to add
 +the names for the other hosts, one per line.  When you are done with the
 +list, type a <control D>.
 +        next host to add:  kanri
 +        next host to add:  # Ctrl + D キー
 +The current list of NIS servers looks like this:
 +
 +kanri
 +
 +Is this correct?  [y/n: y]  y
 +We need a few minutes to build the databases...
 +(以下略)
 +</code>
 +
 +
  
  
 ===== 計算ノード ===== ===== 計算ノード =====
 +
 +NISによってUbuntuがハングアップするのを防ぎます。
 +
 +<code>
 +$ sudo vim /lib/systemd/system/systemd-logind.service
 +# IPAddressDeny=any をコメントアウト
 +$ sudo systemctl daemon-reload
 +</code>
 +
 +  * https://qiita.com/kakinaguru_zo/items/18258d4dd296a755badd
 +
 +  - NISのパッケージをインストールする<code>
 +$ sudo apt install nis
 +</code>
 +    * NISドメイン名は管理ノードで設定したものと同じにする
 +  - /etc/yp.conf にNISドメイン名とNISサーバのIPアドレスを指定する<code>
 +$ sudo vi /etc/yp.conf
 +</code><file - yp.conf>
 +domain kanri.nis server 192.168.0.1
 +</file>
 +  - /etc/nsswitch.conf に、/etc/ にある passwd, group, shadow, hosts はNISサーバのものを使用するように指定する(OSのバージョンによって微妙に変わってくるが、それぞれの項目の先頭に nis を付け加えるだけでオーケー)<code>
 +$ sudo vi /etc/nsswitch.conf
 +</code><file - nsswitch.conf>
 +(略)
 +passwd:         nis files systemd
 +group:          nis files systemd
 +shadow:         nis files
 +gshadow:        files
 +
 +hosts:          nis files dns
 +(略)
 +</file>
 +    * ユーザ情報に加えてNISサーバで行われる名前解決も共有するようにしています
 +    * これにより、各計算ノードで /etc/hosts を編集する必要がなくなります
 +    * グループの管理は管理ノードのみで行いたいため、gshadow(グループのパスワードが暗号化されて入っているファイル)は共有しません
 +  - NISを再起動します<code>
 +$ systemctl restart rpcbind nis 
 +</code>
 +    * 割と時間がかかります。
 +
 +
 +
 +====== 使い方 ======
 +
 +  - ユーザーを追加するには、管理ノードで次のようにします(以下はユーザーsugimotoを追加する場合)<code>
 +$ sudo adduser sugimoto
 +$ sudo make -C /var/yp
 +</code>
 +    * **NISサーバの共有する情報を変更したとき(つまりユーザーの追加したり、ホストファイルを編集したりしたとき)は、その都度 make -C /var/yp を実行する必要があります**
 +  - 新しいユーザで計算ノードにログインできるか確認します<code>
 +$ ssh sugimoto@keisan11
 +</code>
 +
 +
 +====== 補足 ======
 +
 +===== ログインにやたら時間がかかる場合 =====
 +
 +  * Ubuntu18.04で発生を確認
 +  * Ubuntu20.04では解決したようです
 +
 +<code>
 +$ sudo vim /lib/systemd/system/systemd-logind.service
 +# IPAddressDeny=any をコメントアウト
 +$ sudo systemctl daemon-reload
 +</code>
 +
 +===== udevのアップデートに失敗する場合 =====
 +
 +  * apt upgrade をすると次のエラーを吐きます<code>
 +Job for systemd-udevd.service failed because a timeout was exceeded.
 +See "systemctl status systemd-udevd.service" and "journalctl -xe" for details.
 +invoke-rc.d: initscript udev, action "restart" failed.
 +● systemd-udevd.service - udev Kernel Device Manager
 +     Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static; vendor preset: enabled)
 +     Active: activating (start) since Xxx xxxx-xx-xx xx:xx:xx UTC; 20ms ago
 +TriggeredBy: ● systemd-udevd-kernel.socket
 +             ● systemd-udevd-control.socket
 +       Docs: man:systemd-udevd.service(8)
 +             man:udev(7)
 +   Main PID: 50463 (systemd-udevd)
 +      Tasks: 1
 +     Memory: 940.0K
 +     CGroup: /system.slice/systemd-udevd.service
 +             └─50463 /lib/systemd/systemd-udevd
 +
 +xxx xx xx:xx:xx keisan11 systemd[1]: Starting udev Kernel Device Manager...
 +dpkg: error processing package udev (--configure):
 + installed udev package post-installation script subprocess returned error exit status 1
 +</code>
 +  * Ubuntu 18.04, 20.04 で発生を確認
 +
 +<code>
 +$ sudo vim /lib/systemd/system/systemd-udevd.service
 +# IPAddressDeny=any をコメントアウト
 +$ sudo systemctl daemon-reload
 +$ sudo apt update
 +$ sudo apt upgrade
 +</code>
 +
 +
 +
 +
 +====== 参考 ======
 +
 +  * http://meme.biology.tohoku.ac.jp/klabo-wiki/index.php?%B7%D7%BB%BB%B5%A1%2FNIS
 +  * http://masahir0y.blogspot.com/2012/12/nis.html
  
自作クラスタ計算機/nisの基本設定.txt · Last modified: 2024/01/20 17:32 by koudai