Debian 4.0
Sponsored Link

NISサーバー構築2008/08/24

  各仮想サーバーのネットワークでユーザーのアカウント情報を共有できるようにNISサーバーも構築しておきます。 以下の例ではNISサーバーもNFSサーバーと同様ホストOS上に作っています。

[1] NISシステムをインストールします。前節のNFSもそうでしたが、 インストールをすると自動的にシステム起動時の自動起動設定になるのですが、 Debianでは起動順序を明示的に指定してやらなければなりません。 RedHat系ではこのようなことは気にする必要がないのですが。 前節でNFSをインストールした後、自動起動設定を一旦削除して、起動順序を最遅で登録しなおしましたが、 このNISもそうする必要があります。デフォルトのままでいくと、 少なくとも私の環境では、NFSやNISは portmap より先に起動されてしまうため、自動起動設定になっていても正常に起動されません。 そのため、一旦削除して起動順序を明示的に遅く指定して設定する必要があります。 または portmap を起動順序最早で登録しなおすかになります。 いずれにせよ、NFSやこのNISは portmap より後に起動するようにする必要があります。
ns:~#
aptitude -y install nis


# NISドメインの設定画面が出るのでドメイン名を入力してEnter


ns:~#
update-rc.d -f nis remove
# 一旦削除

  Removing any system startup links for /etc/init.d/nis ...
    /etc/rc0.d/K19nis
    /etc/rc1.d/K19nis
    /etc/rc2.d/S19nis
    /etc/rc3.d/S19nis
    /etc/rc4.d/S19nis
    /etc/rc5.d/S19nis
    /etc/rc6.d/K19nis
ns:~#
update-rc.d nis defaults 98
# 起動順序98で再登録

  Adding system startup for /etc/init.d/nis ...
    /etc/rc0.d/K98nis -> ../init.d/nis
    /etc/rc1.d/K98nis -> ../init.d/nis
    /etc/rc6.d/K98nis -> ../init.d/nis
    /etc/rc2.d/S98nis -> ../init.d/nis
    /etc/rc3.d/S98nis -> ../init.d/nis
    /etc/rc4.d/S98nis -> ../init.d/nis
    /etc/rc5.d/S98nis -> ../init.d/nis
[2] NISサーバーとしての設定をします。
ns:~#
vi /etc/default/nis


# 6行目:変更(サーバーとする)

NISSERVER=
master


# 9行目:変更(クライアントにしない)

NISCLIENT=
false


ns:~#
vi /etc/ypserv.securenets


# 14行目:アクセス許可する範囲追記

255.255.255.0
192.168.0.0


# 16行目:コメント化

#
0.0.0.0
0.0.0.0


ns:~#
vi /var/yp/Makefile


# 114行目:追記

ALL = passwd
shadow
group hosts rpc services netid protocols netgrp

# ユーザー新規追加時にWebサイト格納用のディレクトリを自動生成

ns:~#
mkdir /etc/skel/public_html

ns:~#
chmod 711 /etc/skel/public_html


# ユーザー新規追加時にメール格納用のディレクトリを自動生成

ns:~#
mkdir -p /etc/skel/Maildir/cur

ns:~#
mkdir -p /etc/skel/Maildir/new

ns:~#
mkdir -p /etc/skel/Maildir/tmp

ns:~#
chmod -R 700 /etc/skel/Maildir/


ns:~#
adduser test
# ユーザー新規追加

Adding user `test' ...
Adding new group `test' (1002) ...
Adding new user `test' (1002) with group `test' ...
Creating home directory `/home/test' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for test
Enter the new value, or press ENTER for the default
      Full Name []: test
      Room Number []: test
      Work Phone []:
      Home Phone []:
      Other []:
Is the information correct? [y/N] y
ns:~#
ns:~#
/usr/lib/yp/ypinit -m
# NISデータベース更新

At this point, we have to construct a list of the hosts which will run NIS servers. ns.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: ns.srv.world
next host to add:
# Ctrl + D キーを押す

The current list of NIS servers looks like this:

ns.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'

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

Now you can run ypinit -s ns.srv.world on all slave server.

ns:~#
/etc/init.d/nis restart

Starting NIS services: ypserv.

# 以降、新しくユーザーを追加した場合は、以下のようにしてNISデータベースの更新もする

ns:~#
cd /var/yp

ns:/var/yp#
make
関連コンテンツ