1

Nutch 2.1 を使用してサイトをクロールしています。問題は、クローラーが取得中の URL のスピン待機中/アクティブを表示し続け、取得に非常に時間がかかるため、mysql への接続がタイムアウトになることです。mysql がタイムアウトしないように、一度にフェッチする回数を減らすにはどうすればよいですか?? 100 または 500 の URL のみをフェッチし、解析して mysql に保存し、次の 100 または 500 の URL を再度フェッチすると言うことができる設定はありますか??

エラーメッセージ:

Unexpected error for http://www.example.com
java.io.IOException: java.sql.BatchUpdateException: The last packet successfully received from the server was 36,928,172 milliseconds ago.  The last packet sent successfully to the server was 36,928,172 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at org.apache.gora.sql.store.SqlStore.flush(SqlStore.java:340)
    at org.apache.gora.mapreduce.GoraRecordWriter.write(GoraRecordWriter.java:65)
    at org.apache.hadoop.mapred.ReduceTask$NewTrackingRecordWriter.write(ReduceTask.java:587)
    at org.apache.hadoop.mapreduce.TaskInputOutputContext.write(TaskInputOutputContext.java:80)
    at org.apache.nutch.fetcher.FetcherReducer$FetcherThread.output(FetcherReducer.java:663)
    at org.apache.nutch.fetcher.FetcherReducer$FetcherThread.run(FetcherReducer.java:534)
Caused by: java.sql.BatchUpdateException: The last packet successfully received from the server was 36,928,172 milliseconds ago.  The last packet sent successfully to the server was 36,928,172 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2028)
    at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1451)
    at org.apache.gora.sql.store.SqlStore.flush(SqlStore.java:328)
    ... 5 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 36,928,172 milliseconds ago.  The last packet sent successfully to the server was 36,928,172 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at sun.reflect.GeneratedConstructorAccessor49.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3364)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1983)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2427)
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1980)
    ... 7 more
Caused by: java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3345)
    ... 13 more
4

1 に答える 1

1

Nutch 2.1 を使用してサイトをクロールしています。問題は、クローラーが取得中の URL のスピン待機中/アクティブを表示し続け、取得に非常に時間がかかるため、mysql への接続がタイムアウトになることです。mysql がタイムアウトしないように、一度にフェッチする回数を減らすにはどうすればよいですか?

取得回数を減らすために、以下のプロパティを nutch-site.xml に追加し、必要に応じて値を編集できます。nutch-default.xml を編集しないでください。プロパティを nutch-site.xml にコピーして、そこから値を管理してください。

  <property>
    <name>fetcher.threads.fetch</name>
    <value>20</value>
  </property>

タイムアウトの問題に関しては、必要と思われる読み込み時間の値を指定して、このプロパティを nutch-site.xml に追加できます。

<property>
  <name>http.timeout</name>
  <value>240000</value>
  <description>The default network timeout, in milliseconds.</description>
</property>

100 または 500 の URL のみを取得し、解析して mysql に保存し、次の 100 または 500 の URL を再度取得することができる設定はありますか?

Nutch は、クロール コマンドで指定した「深さ」と呼ばれる反復回数で、生成/フェッチ/解析/更新のサイクルでクロールします。クロールを制御したい場合は、チュートリアル リンクhttp://wiki.apache.org/nutch/NutchTutorialのセクション 3.2 (Web 全体のクロールに個別のコマンドを使用する) で説明されているように、各ステップを実行できます。これにより、適切な方向性が示され、何が起こっているのかを正確に理解できます。各セグメントを取得する際にステータスを確認して、各セグメントで取得されている URL の数を確認してください。

于 2013-04-08T19:07:16.733 に答える