1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"><head><!--
4        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5              This file is generated from xml source: DO NOT EDIT
6        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7      -->
8<title>ファイル記述子の限界 - Apache HTTP サーバ</title>
9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
12<script src="/style/scripts/prettify.min.js" type="text/javascript">
13</script>
14
15<link href="/images/favicon.ico" rel="shortcut icon" /></head>
16<body id="manual-page" class="no-sidebar"><div id="page-header">
17<p class="menu"><a href="/mod/">モジュール</a> | <a href="/mod/directives.html">ディレクティブ</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">用語</a> | <a href="/sitemap.html">サイトマップ</a></p>
18<p class="apache">Apache HTTP サーバ バージョン 2.4</p>
19<img alt="" src="/images/feather.gif" /></div>
20<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
21<div id="path">
22<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP サーバ</a> &gt; <a href="http://httpd.apache.org/docs/">ドキュメンテーション</a> &gt; <a href="../">バージョン 2.4</a> &gt; <a href="./">バーチャルホスト</a></div><div id="page-content"><div id="preamble"><h1>ファイル記述子の限界</h1>
23<div class="toplang">
24<p><span>翻訳済み言語: </span><a href="/en/vhosts/fd-limits.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
25<a href="/fr/vhosts/fd-limits.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
26<a href="/ja/vhosts/fd-limits.html" title="Japanese">&nbsp;ja&nbsp;</a> |
27<a href="/ko/vhosts/fd-limits.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
28<a href="/tr/vhosts/fd-limits.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
29</div>
30<div class="outofdate">この日本語訳はすでに古くなっている
31            可能性があります。
32            最近更新された内容を見るには英語版をご覧下さい。
33        </div>
34
35
36    <p>たくさんのバーチャルホストを運用する場合、もし、
37    各バーチャルホストごとに異なるログファイルが指定してあると、
38    Apache がファイル記述子 (<cite>ファイルハンドル</cite>とも呼ばれます)
39    を使い切ってしまうことがあります。Apache が使用するファイル
40    記述子の数は、各エラーログファイルにつき 1 つ、他のログファイルの
41    ディレクティブにつき 1 つ、さらに内部で使用する 10 から 20、
42    の合計になります。Unix オペレーティングシステムではプロセスごとに
43    使用可能なファイル記述子の数を制限しています。たいていの場合は 64 で、
44    普通は大きな値のハードリミットまで増やすことができます。</p>
45
46    <p>Apache は必要に応じて上限を拡大しようと試みますが、
47    以下のような場合にはうまくいかないかもしれません。</p>
48
49    <ol>
50      <li>利用しているシステムで <code>setrlimit()</code>
51      システムコールが提供されていない。</li>
52
53      <li>システム上で <code>setrlimit</code>(RLIMIT_NOFILE) が動作しない
54      (たとえば Solaris 2.3 のように)。</li>
55
56      <li>要求されるファイル記述子の数が
57      ハードリミットを超えてしまう。</li>
58      
59      <li>システムにファイル記述子に関して別の制限が存在してしまっている。
60      たとえば、stdio ストリームではファイル記述子を 256 以上使えない
61      (Solaris 2)、など。</li>
62    </ol>
63
64    <p>問題が発生した時に取り得る対処方法は次のとおり:</p>
65
66    <ul>
67      <li>ログファイルの数を減らす。<code class="directive"><a href="/mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
68      セクションでログファイルを指定せず、メインのログファイルにのみ記録する。
69      (これに関する詳しい情報は以下の<a href="#splitlogs">ログファイルの分割</a>を読んでください。)</li>
70
71      <li>
72        もし、前述の 1 または 2 の場合であれば、
73        Apache を起動する前にファイル記述子を増やします。
74        たとえば次のようなスクリプトを使います。
75
76        <div class="example"><p><code>
77          <code>#!/bin/sh<br />
78           ulimit -S -n 100<br />
79           exec httpd</code>
80        </code></p></div>
81      </li>
82    </ul>
83</div>
84<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
85<div class="section">
86<h2><a name="splitlogs" id="splitlogs">ログファイルの分割</a></h2>
87
88<p>複数のバーチャルホストのログを同じログファイルに収集しようとしているときには、
89各バーチャルホストについて統計的な解析を実行するために後でログファイルを
90分割したくなるかもしれません。これは以下のようにして実現できます。</p>
91
92<p>まず、バーチャルホストの情報をログのエントリに追加する必要があります。
93これは <code class="directive"><a href="/mod/mod_log_config.html#logformat">LogFormat</a></code>
94ディレクティブの <code>%v</code> 変数を使うことでできます。
95これをログのフォーマット文字列の先頭に追加します:</p>
96
97<div class="example"><p><code>
98LogFormat "%v %h %l %u %t \"%r\" %&gt;s %b" vhost<br />
99CustomLog logs/multiple_vhost_log vhost
100</code></p></div>
101
102<p>これは common log format のログを作成しますが、それぞれの行の先頭に
103正規化されたバーチャルホストの名前
104(<code class="directive"><a href="/mod/core.html#servername">ServerName</a></code>
105ディレクティブに書かれているもの) が付加されます。
106(ログファイルのカスタマイズの詳細については <a href="/mod/mod_log_config.html#formats">Custom Log Formats</a> を
107読んでください。)</p>
108
109<p>ログファイルを各部分 (バーチャルホスト毎に 1 ファイル) に分けたいときは、
110<code><a href="/programs/other.html">split-logfile</a></code>
111を使って行なうことができます。プログラムは Apache 配布の 
112<code>support</code> ディレクトリにあります。</p>
113
114<p>以下のようなコマンドでこのプログラムを実行します:</p>
115
116<div class="example"><p><code>
117split-logfile &lt; /logs/multiple_vhost_log
118</code></p></div>
119
120<p>このプログラムはバーチャルホストのログファイルの名前とともに実行され、
121ログファイルに現れるそれぞれのバーチャルホスト毎に一つのファイルを作成します。
122それぞれのファイルは <code>ホスト名.log</code> という名前になります。</p>
123
124</div></div>
125<div class="bottomlang">
126<p><span>翻訳済み言語: </span><a href="/en/vhosts/fd-limits.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
127<a href="/fr/vhosts/fd-limits.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
128<a href="/ja/vhosts/fd-limits.html" title="Japanese">&nbsp;ja&nbsp;</a> |
129<a href="/ko/vhosts/fd-limits.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
130<a href="/tr/vhosts/fd-limits.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
131</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">コメント</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
132<script type="text/javascript"><!--//--><![CDATA[//><!--
133var comments_shortname = 'httpd';
134var comments_identifier = 'http://httpd.apache.org/docs/2.4/vhosts/fd-limits.html';
135(function(w, d) {
136    if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
137        d.write('<div id="comments_thread"><\/div>');
138        var s = d.createElement('script');
139        s.type = 'text/javascript';
140        s.async = true;
141        s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
142        (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
143    }
144    else { 
145        d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
146    }
147})(window, document);
148//--><!]]></script></div><div id="footer">
149<p class="apache">Copyright 2014 The Apache Software Foundation.<br />この文書は <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> のライセンスで提供されています。.</p>
150<p class="menu"><a href="/mod/">モジュール</a> | <a href="/mod/directives.html">ディレクティブ</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">用語</a> | <a href="/sitemap.html">サイトマップ</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
151if (typeof(prettyPrint) !== 'undefined') {
152    prettyPrint();
153}
154//--><!]]></script>
155</body></html>