[ITPASS2011]サーバ交換作業(DNS)

phase 1 (入替え開始)

DNS 班が行う作業は特にない

phase 2

new 側の old に対する通信許可の設定

new の /etc/ssh/sshd_config で,

PermitRootLogin no

という部分を

PermitRootLogin yes

に変更する.

さらに, 任意のコマンドを実行出来るように,

PermitRootLogin forced-commands-only

という部分があればコメントアウトする. その後,

new# /etc/init.d/ssh restart

として設定を反映すること. これにより, root のログインを許可することとなる.

old から new へ各種データをコピー

  • old の /var/spool/cron/crontabs 以下の各ファイルを new へコピー

    • scp コマンドで移す際には, パーミッションやグループ等の設定を変えてしまわないように注意 (オプション p の使用).
    root@old-itpass:/var/spool/cron# scp -p -r crontabs root@new-itpass:/var/spool/cron/
  • old の /etc/shadow のユーザ部分を new へコピー (注意)
    • old, new に別々の仮想端末でログインする.

      new の /etc/shadow を/etc/shadow~にバックアップ. old の /etc/shadow を new へ /etc/tmp として一時的にコピーする. /etc/tmp と /etc/shadow を diff コマンドで比較して, /etc/shadow に書かれていない UID のうち 1000 〜 29999 までのものが /etc/tmp にあるか確認する. あれば /etc/tmp からコピーする. (UID とユーザ名の対応については /etc/passwd を参照)

      作業が終われば /etc/tmp を削除する.

  • /home ディレクトリを rsync する

前回 rsync を行ってからこの作業をするまでの間に変更があった分のために再度 rsync を行う.

new 側の old に対する通信制限の設定

先ほど, old から new に rsync でファイルを転送するために, root のログインを許可したので, 設定を以下のように変更して元に戻す.

/etc/ssh/sshd_config の

PermitRootLogin yes

という部分を

PermitRootLogin no

に変更したのち,

new# /etc/init.d/ssh restart

として設定を反映することにより元に戻る.

old の authorized_keys を編集

  • new-itpass の公開鍵の行の冒頭に以下を加える.

    command="rsync --server -vlogDtpr --delete . /home/",no-pty,from="old-itpass.scitec.kobe-u.ac.jp",
    no-port-forwarding,no-X11-forwarding,no-agent-forwarding
  • ファイル名を authorized_keys.bk に変更し, root ログインを完全に拒否するようにする.

phase 3

これ以降、new, old が入れ替わるので注意すること.

  • old
    • bind を止めてサーバ起動時に bind が立ち上がらないように、起動スクリプトを変更する.

      root@old-itpass:/etc/init.d# /etc/init.d/bind stop
      root@old-itpass:/etc/init.d# update-rc.d -f bind remove
       Removing any system startup links for /etc/init.d/bind ...
        /etc/rc0.d/K20bind
        /etc/rc1.d/K20bind
        /etc/rc2.d/S20bind
        /etc/rc3.d/S20bind
        /etc/rc4.d/S20bind
        /etc/rc5.d/S20bind
        /etc/rc6.d/K20bind
  • new
    • namedb のバックアップを作成(日付は適宜変更)

      root@new-itpass:/usr/local/bind/etc# cp -r namedb namedb-20111104
    • サーバ起動時に bind が立ち上がるよう, 起動スクリプトを変更

      root@new-itpass:/usr/local/bind/etc# update-rc.d bind defaults

      ここで

      insserv: warning: script 'K01tcpserver' missing LSB tags and overrides
      insserv: warning: script 'tcpserver' missing LSB tags and overrides

      のような LSB の警告が出た場合, 以下を /etc/init.d/tcpserver の冒頭に追記する.

      ### BEGIN INIT INFO
      # Provides:          tcpserver
      # Required-Start:    $remote_fs
      # Required-Stop:     $remote_fs
      # Should-Start:      $network $syslog
      # Should-Stop:       $network $syslog
      # Default-Start:     2 3 4 5
      # Default-Stop:      0 1 6
      # Short-Description: Start and stop tcpserver
      # Description:       tcpserver is  access control program
      #        which translates ip addresses to and from internet names
      ### END INIT INFO

      その後, update-rc.d -f bind remove を実行してから, もういちど update-rc.d bind defaults を実行し, 警告が出ないことを確認する.

      毎年異なる箇所でエラーが起きる可能性があるため, 適宜修正内容は変更する.

    • interfaces と resolv.conf の書き換え

      new をフルサービスリゾルバにするために, resolv.conf に書いてあるIPアドレスを学術情報基盤センターから new 自身のものに書き換える.

      /etc/network/interfaces を以下の様に変更する.

      address 133.30.109.22
      netmask 255.255.255.0
      network 133.30.109.0
      broadcast 133.30.109.255
      gateway 133.30.109.254
      # dns-* options are implemented by the resolvconf package, if installed
      dns-nameservers 133.30.109.22
                      ^^^^^^^^^^^^^
      dns-search scitec.kobe-u.ac.jp 

      その後, ネットワークを再起動させるために

      # /etc/init.d/networking stop
      # /etc/init.d/networking start

      を実行.

      /etc/resolv.conf の中身が以下の様になっているかを確認する.

      # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
      #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
      nameserver 133.30.109.22
      search scitec.kobe-u.ac.jp

      (注意) /etc/resolv.conf は手動で編集しても自動で書き換わるようになっている. そのことは /etc/resolv.conf の冒頭に記述されている.

      # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
      #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

bind の起動確認

サーバ交換作業が終わったら, reboot して bind が起動することを確認する.

  • new (bindが起動していることを確認)

    ika-itpass:$ ps ax | grep bind
    1674 ?        Ss     0:00 /usr/local/bind/sbin/named -c /usr/local/bind/etc/namedb/named.conf -u bind
    2496 pts/0    S+     0:00 grep bind
  • old (bindを起動していないことを確認)

    tako-itpass:$ ps ax | grep bind
    3380 pts/0    R+     0:00 grep bind

phase 4

移行の最終チェック

  • old と new でそれぞれ問い合わせに応じるか, 正しいデータを返すかをチェックする.

    $ dig itpass.scitec.kobe-u.ac.jp 
    
    --> 133.30.109.22を返せば OK.
    
    $ dig old-itpass.scitec.kobe-u.ac.jp 
    
    --> 133.30.109.21を返せば OK.
    
    $ dig new-itpass.scitec.kobe-u.ac.jp 
    
    --> 133.30.109.22を返せば OK.

後日の作業

  • 要らないファイルの削除

    運用開始から 1 週間をめどに, 参考のために old からコピーしたファイル類を削除する. また emacs で編集した際の一時ファイル(ファイル名~ など)もあれば削除する.

[ITPASSサーバ構築ドキュメント へ戻る]

Last modified:2011/12/13 14:18:20
Keyword(s):
References:[[ITPASS2011]2011年度サーバ構築ログ] [ITPASSサーバ構築ドキュメント]