CentOS 8
Sponsored Link

NIS : セカンダリーサーバーの設定2019/10/17

 
NIS セカンダリーサーバーを構築し、NIS プライマリーサーバーダウン時も NIS クライアントに対してサービスを継続できるようにします。
当例では以下のような環境で設定します。
+----------------------+          |          +----------------------+
| [    NIS Server    ] |10.0.0.30 | 10.0.0.31| [     NIS Slave    ] |
|     dlp.srv.world    +----------+----------+     yp01.srv.world   |
|                      |          |          |                      |
+----------------------+          |          +----------------------+
+----------------------+          |
| [     NIS Client   ] |10.0.0.51 |
|    node01.srv.world  +----------+
|                      |
+----------------------+

[1]
[2] NIS セカンダリーサーバーとするホストで Ypserv をインストールして設定します。
[root@yp01 ~]#
dnf -y install ypserv rpcbind
[root@yp01 ~]#
vi /var/yp/securenets
# 新規作成

# アクセス許可する NIS クライアントの範囲を指定

255.0.0.0       127.0.0.0
255.255.255.0   10.0.0.0

[root@yp01 ~]#
systemctl enable --now rpcbind ypserv ypxfrd yppasswdd nis-domainname
# プライマリーサーバーのデータベース同期

[root@yp01 ~]#
/usr/lib64/yp/ypinit -s dlp.srv.world

We will need a few minutes to copy the data from dlp.srv.world.
Transferring group.bygid...
Trying ypxfrd ... success
...
...
At this point, make sure that /etc/passwd and /etc/group have
been edited so that when the NIS is activated, the data bases you
have just created will be used, instead of the /etc ASCII files.
[3] NIS セカンダリーサーバーで SELinux を有効にしている場合は、ブール値の変更が必要です。
[root@yp01 ~]#
setsebool -P nis_enabled on

[root@yp01 ~]#
setsebool -P domain_can_mmap_files on
[4] NIS セカンダリーサーバーで Firewalld を有効にしている場合は NIS 関連サービスの許可が必要です。一部の NIS 関連サービスのポートはサービスが起動する度に変動するため、任意のポートに固定する設定をした後に許可設定します。
[root@yp01 ~]#
vi /etc/sysconfig/network
# 最終行に追記

YPSERV_ARGS="-p 944"
YPXFRD_ARGS="-p 945"
[root@yp01 ~]#
vi /etc/sysconfig/yppasswdd
# 該当行に追記

YPPASSWDD_ARGS=
"--port 950"
[root@yp01 ~]#
systemctl restart rpcbind ypserv ypxfrd yppasswdd
[root@yp01 ~]#
firewall-cmd --add-service=rpc-bind --permanent

[root@yp01 ~]#
firewall-cmd --add-port={944-951/tcp,944-951/udp} --permanent

[root@yp01 ~]#
firewall-cmd --reload

[5]
NIS プライマリーサーバーも NIS クライアントである必要があります。
こちらを参考に NIS プライマリーサーバーを NIS クライアントとして設定しておきます。
[6] NIS プライマリーサーバーで、新たに構築した NIS セカンダリーサーバー用の設定をします。
[root@dlp ~]#
vi /var/yp/Makefile
# 23行目:変更

NOPUSH=
false
# NIS データベース更新

[root@dlp ~]#
/usr/lib64/yp/ypinit -m


At this point, we have to construct a list of the hosts which will run NIS
servers.  dlp.srv.world 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:  dlp.srv.world
        next host to add:  yp01.srv.world   # NIS セカンダリーサーバーを指定
        next host to add:  # Ctrl + D キー
The current list of NIS servers looks like this:

dlp.srv.world
yp01.srv.world

Is this correct?  [y/n: y]  y
We need a few minutes to build the databases...
Building /var/yp/srv.world/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory '/var/yp/srv.world'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating hosts.byname...
Updating hosts.byaddr...
Updating rpc.byname...
Updating rpc.bynumber...
Updating services.byname...
Updating services.byservicename...
Updating netid.byname...
Updating protocols.bynumber...
Updating protocols.byname...
Updating mail.aliases...
gmake[1]: Leaving directory '/var/yp/srv.world'

dlp.srv.world has been set up as a NIS master server.

Now you can run ypinit -s dlp.srv.world on all slave server.
[7] NIS クライアントが NIS セカンダリーサーバーも参照できるよう設定します。
以上で、NIS プライマリーサーバーダウン時も、NIS クライアントに対するサービスは継続されます。
[root@node01 ~]#
vi /etc/yp.conf
# 最終行にセカンダリーサーバー追記

# [domain (NIS ドメイン) server (NIS サーバー)]

domain srv.world server dlp.srv.world
domain srv.world server yp01.srv.world
[root@node01 ~]#
systemctl restart ypbind

関連コンテンツ