2006年05月25日

システム管理者の心得? 〜 設定ファイルはシンプルに

はてなブックマークに登録

今回はシステムの構築や運用をしている中で、各種設定ファイル(httpd.confとか)を記述する際に注意している点などを書きたいと思います。最初にお断りさせていただきますが、この内容は「こうあるべき」とか「こうしなければならない」といった押しつけがましいものでは決してなく、単に普段の生活の中で心がけている事などをご紹介させて頂いているだけですので気軽に眺めてやって下さい。

httpd.conf や syslog.conf などの設定ファイルには、デフォルトで沢山のコメントや初期値設定が含まれていますが、主要な設定が終わり次第それらはほとんど削除していきます。これによって、ファイル全体の見通しがよくなり、意図していない設定が残ってしまうことを防ぎます。「なんか動作がおかしいなあ」と思ったら、必要な設定がコメントアウトされていたみたいな経験ないですか?私はあります(笑)
ファイル全体の見通しを良くすることで、設定変更時やトラブルシューティングの際のストレスを軽減出来ると思います。消してしまうのがどうしても心配であれば、デフォルトの設定ファイルは自分のホームにでも置いておけばよいですし、大抵は manやら付属ドキュメントを参照しつつ記述するので、実運用で利用するファイルにコメントを残しておく必要性は感じられません。それに、バージョンアップしたときに、そのコメントの内容自体が古くなってしまうこともあります。

※ここでの「コメント」とはあくまで「デフォルト設定に含まれているコメント」を指しています。
当然ながら運用に必要なコメントは自分で記述します。


例として apache2 の httpd.conf を抜粋してみます。
コメントを残したままだと、


#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80

Listen 80




#
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
#ExtendedStatus On

### Section 2: 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# < VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# . On SCO (ODT 3) use "User nouser" and "Group nogroup".
# . On HPUX you may not be able to use shared memory as nobody, and the
# suggested workaround is to create a user www and use that user.
# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
# when the value of (unsigned)Group is above 60000;
# don't use Group #-1 on these systems!
#
User apache
Group www
</IfModule>
</IfModule>



な感じですが、コメントや不要な設定を消すだけで


Listen 80
ExtendedStatus Off
User apache
Group www



あたりまえなんですが圧倒的に見やすくなります。
その上で、いまいち何の設定だったか忘れがちなものなどについては、


Listen 80

# サーバの統計情報は公開しない
# http://httpd.apache.org/docs/2.0/ja/mod/mod_status.html
ExtendedStatus Off

User apache
Group www



な感じにすると、コメントの存在価値が 100倍にもなると思います。
「消すと後で困りそう・・・」なイメージがあるかもしれない設定ファイルですが、機会があれば思い切って綺麗にしてみるのはいかがでしょうか。
klab_gijutsu2 at 13:29│Comments(0)TrackBack(0)

トラックバックURL

この記事にコメントする

名前:
URL:
  情報を記憶: 評価: 顔   
 
 
 
Blog内検索
Archives
このブログについて
DSASとは、KLab が構築し運用しているコンテンツサービス用のLinuxベースのインフラです。現在5ヶ所のデータセンタにて構築し、運用していますが、我々はDSASをより使いやすく、より安全に、そしてより省力で運用できることを目指して、日々改良に勤しんでいます。
このブログでは、そんな DSAS で使っている技術の紹介や、実験してみた結果の報告、トラブルに巻き込まれた時の経験談など、広く深く、色々な話題を織りまぜて紹介していきたいと思います。
最新コメント