今回は、プロセスを手動で順次実行してみる。
ちょっと特殊なのはCassandraにストアしていること。
- さくらVPS
- CentOS 6.2
- OpenJDK 1.6.0_24
- Apache Nutch 2.1
- Apache Cassandra 1.2
- Inject クローリングの始点をデータベース、つまり今回はCassandraに、登録する。
- Generate クロール対象の選択。
- Fetch 対象サイトのデータを取得する。
- Parse 次は、取得したデータの解析・情報抽出。
- UpdateDB Parseでリンクも抽出しており、これを次のクロールの候補としてデータベースに反映させる。
- おさらい 再度以下を1巡行うと、
Apacheのコミュニティサイトを3つをクロール始点としてファイルに登録。
# pwd /opt/apache-nutch-2.1 # cat urls/seed.txt http://nutch.apache.org/ http://lucene.apache.org/ http://cassandra.apache.org/ # nutch inject urls/ InjectorJob: starting InjectorJob: urlDir: urls <省略> InjectorJob: finished確かめる。
# nutch readdb -dump ./out_dir
# cat out_dir/part-r-00000
http://cassandra.apache.org/ key: org.apache.cassandra:http/
baseUrl: null
status: 0 (null)
fetchInterval: 2592000
fetchTime: 1358584769397
prevFetchTime: 0
retries: 0
modifiedTime: 0
protocolStatus: (null)
parseStatus: (null)
title: null
score: 1.0
markers: {dist=0, _injmrk_=y}
metadata _csh_ : ?�
http://lucene.apache.org/ key: org.apache.lucene:http/
baseUrl: null
status: 0 (null)
fetchInterval: 2592000
fetchTime: 1358584769397
prevFetchTime: 0
retries: 0
modifiedTime: 0
protocolStatus: (null)
parseStatus: (null)
title: null
score: 1.0
markers: {dist=0, _injmrk_=y}
metadata _csh_ : ?�
http://nutch.apache.org/ key: org.apache.nutch:http/
baseUrl: null
status: 0 (null)
fetchInterval: 2592000
fetchTime: 1358584769397
prevFetchTime: 0
retries: 0
modifiedTime: 0
protocolStatus: (null)
parseStatus: (null)
title: null
score: 1.0
markers: {dist=0, _injmrk_=y}
metadata _csh_ : ?�
たしかに3つのサイトが登録されている。# nutch generate <省略>そして確認。readdb -dumpの出力先ディレクトリは、存在するとエラーになる。ここでは同じディレクトリにするので最初に消しておく。
# rm -rf out_dir
# nutch readdb -dump ./out_dir
<省略>
# cat out_dir/part-r-00000
http://cassandra.apache.org/ key: org.apache.cassandra:http/
baseUrl: null
status: 0 (null)
fetchInterval: 2592000
fetchTime: 1358584769397
prevFetchTime: 0
retries: 0
modifiedTime: 0
protocolStatus: (null)
parseStatus: (null)
title: null
score: 1.0
markers: {dist=0, _injmrk_=y, _gnmrk_=1358585856-208596666}
metadata _csh_ : ?�
http://lucene.apache.org/ key: org.apache.lucene:http/
baseUrl: null
status: 0 (null)
fetchInterval: 2592000
fetchTime: 1358584769397
prevFetchTime: 0
retries: 0
modifiedTime: 0
protocolStatus: (null)
parseStatus: (null)
title: null
score: 1.0
markers: {dist=0, _injmrk_=y, _gnmrk_=1358585856-208596666}
metadata _csh_ : ?�
http://nutch.apache.org/ key: org.apache.nutch:http/
baseUrl: null
status: 0 (null)
fetchInterval: 2592000
fetchTime: 1358584769397
prevFetchTime: 0
retries: 0
modifiedTime: 0
protocolStatus: (null)
parseStatus: (null)
title: null
score: 1.0
markers: {dist=0, _injmrk_=y, _gnmrk_=1358585856-208596666}
metadata _csh_ : ?�
markersのところが追記されているが、大きな変化はなし。Generate実行時に-topNオプションを付けると対象サイトをしぼれる。
# nutch generate -topN 1
<省略>
# nutch readdb -dump out_dir
# cat out_dir/part-r-00000
http://cassandra.apache.org/ key: org.apache.cassandra:http/
<省略>
markers: {dist=0, _injmrk_=y, _gnmrk_=1358586890-1155183335}
metadata _csh_ : ?�
http://lucene.apache.org/ key: org.apache.lucene:http/
<省略>
markers: {dist=0, _injmrk_=y}
metadata _csh_ : ?�
http://nutch.apache.org/ key: org.apache.nutch:http/
<省略>
markers: {dist=0, _injmrk_=y}
metadata _csh_ : ?�
最初のサイトに対してのみ、markersに追記がなされている。fetchの引数には、generate実行時の最後に出力されるBatch Idを指定する。
# nutch fetch 1358585856-208596666 <省略>Cassandraをのぞくと、確かにコンテンツが格納されている模様。
ColumnFamily「f」に入っている。
# cassandra-cli Connected to: "Cassandra Cluster" on 127.0.0.1/9160 Welcome to Cassandra CLI version 1.2.0 Type 'help;' or '?' for help. Type 'quit;' or 'exit;' to quit. [default@unknown] use webpage; [default@webpage] list f; Using default limit of 100 Using default column limit of 100 ------------------- RowKey: 6f72672e6170616368652e6e757463683a687474702f => (column=bas, value=http://nutch.apache.org/, timestamp=1358588578114000) => (column=cnt, value= <省略> , timestamp=1358588578191000) => (column=fi, value=2592000, timestamp=1358588024031000) => (column=pts, value=1358588021620, timestamp=1358588578188001) => (column=s, value=1.0, timestamp=1358588024032000) => (column=st, value=2, timestamp=1358588578187000) => (column=ts, value=1358588574261, timestamp=1358588578188000) => (column=typ, value=application/xhtml+xml, timestamp=1358588578192000) 3 Rows Returned. Elapsed time: 27 msec(s). [default@webpage]
# nutch parse 1358588033-175013002 <省略>CassandraのColumnFamily「p」に解析されたデータが格納される。
[default@webpage] list sc;
Using default limit of 100
Using default column limit of 100
-------------------
RowKey: 6f72672e6170616368652e6e757463683a687474702f
=> (super_column=h,
(column=Accept-Ranges, value=bytes, timestamp=1358588578175000)
(column=Connection, value=close, timestamp=1358588578168000)
(column=Content-Encoding, value=gzip, timestamp=1358588578162000)
(column=Content-Length, value=8631, timestamp=1358588578171000)
(column=Content-Type, value=text/html; charset=utf-8, timestamp=1358588578169000)
(column=Date, value=Sat, 19 Jan 2013 09:42:53 GMT, timestamp=1358588578173000)
(column=ETag, value="84c4-4d0994769b476-gzip", timestamp=1358588578166000)
(column=Last-Modified, value=Tue, 11 Dec 2012 20:10:53 GMT, timestamp=1358588578172000)
(column=Server, value=Apache/2.4.3 (Unix) OpenSSL/1.0.0g, timestamp=1358588578176000)
(column=Vary, value=Accept-Encoding, timestamp=1358588578178000))
=> (super_column=mk,
(column=__prsmrk__, value=1358588033-175013002, timestamp=1358590210616000)
(column=_ftcmrk_, value=1358588033-175013002, timestamp=1358590210613000)
(column=_gnmrk_, value=1358588033-175013002, timestamp=1358590210614000)
(column=_injmrk_, value=y, timestamp=1358590210611000)
(column=dist, value=0, timestamp=1358590210610000))
=> (super_column=mtdt,
(column=_csh_, value=, timestamp=1358590006461000))
=> (super_column=ol,
(column=http://lucene.apache.org/java/, value=Lucene, timestamp=1358590210557000)
(column=http://lucene.apache.org/solr/, value=Solr, timestamp=1358590210581000)
(column=http://nutch.apache.org/, value=Nutch, timestamp=1358590210606000)
<省略>
developers and community members hang out in the #cassandra channel on irc.freenode.net . If you are new to IRC, you can use a web-based client . Dead Trees Cassandra High Performance Cookbook , by Ed Capriolo. Covers Cassandra 0.8. Also on Amazon . Copyright © 2009 The Apache Software Foundation . Licensed under the Apache License, Version 2.0. Apache and the Apache feather logo are trademarks of The Apache Software Foundation. Privacy Policy ., timestamp=1358590210680000)
=> (column=sig, value=�#)�2s��D��j�, timestamp=1358590210678000)
=> (column=t, value=The Apache Cassandra Project, timestamp=1358590210679000)
3 Rows Returned.
Elapsed time: 13 msec(s).
# nutch updatedbCassandraをのぞくとデータ件数が45に増えている。
[default@webpage] list f; <省略&pt; => (column=ts, value=1358590521209, timestamp=1358590521282000) 45 Rows Returned. Elapsed time: 80 msec(s).readdbでも確認してみる。
# cat ./out_dir/part-r-00000
http://cassandra.apache.org/ key: org.apache.cassandra:http/
baseUrl: http://cassandra.apache.org/
status: 2 (status_fetched)
fetchInterval: 2592000
fetchTime: 1363772574261
prevFetchTime: 1358588021620
retries: 0
modifiedTime: 0
protocolStatus: SUCCESS, args=[]
parseStatus: success/ok (1/0), args=[]
title: The Apache Cassandra Project
score: 1.0
signature: 14efbfbd2329efbfbd3273efbfbdefbfbd44efbfbdefbfbd6aefbfbd000000
markers: {dist=0, _injmrk_=y, _updmrk_=1358588033-175013002, _gnmrk_=1358588033-175013002, _ftcmrk_=1358588033-175013002, __prsmrk__=1358588033-175013002}
metadata _csh_ :
http://cassandra.apache.org/download/ key: org.apache.cassandra:http/download/
baseUrl: null
status: 1 (status_unfetched)
fetchInterval: 2592000
fetchTime: 1358590521209
prevFetchTime: 0
retries: 0
modifiedTime: 0
protocolStatus: UNKNOWN_CODE_0, args=[]
parseStatus: notparsed/ok (0/0), args=[]
title: null
score: 0.0
markers: {dist=1}
metadata _csh_ :
http://cassandra.apache.org/privacy.html key: org.apache.cassandra:http/privacy.html
baseUrl: null
status: 1 (status_unfetched)
fetchInterval: 2592000
fetchTime: 1358590521210
prevFetchTime: 0
retries: 0
modifiedTime: 0
protocolStatus: UNKNOWN_CODE_0, args=[]
parseStatus: notparsed/ok (0/0), args=[]
title: null
score: 0.0
markers: {dist=1}
metadata _csh_ :
http://lucene.apache.org/ key: org.apache.lucene:http/
baseUrl: http://lucene.apache.org/
status: 2 (status_fetched)
fetchInterval: 2592000
fetchTime: 1363772574561
prevFetchTime: 1358588021620
retries: 0
modifiedTime: 0
protocolStatus: SUCCESS, args=[]
parseStatus: success/ok (1/0), args=[]
title: Apache Lucene - Welcome to Apache Lucene
score: 1.0
signature: efbfbdefbfbdefbfbdefbfbd67efbfbd74efbfbd5cefbfbdefbfbd21413befbfbdefbfbd0000000000000000000000000000000000000000000000000000000000000000000000
markers: {dist=0, _injmrk_=y, _updmrk_=1358588033-175013002, _gnmrk_=1358588033-175013002, _ftcmrk_=1358588033-175013002, __prsmrk__=1358588033-175013002}
metadata _csh_ :
# nutch generate -topN 10 <省略> GeneratorJob: generated batch id: 1358607691-1967365662 # nutch fetch 1358607691-1967365662 # nutch parse 1358607691-1967365662 # nutch updatedbColumnFamily「p」が13件に、ColumnFamily「f」が125件となった。
0 件のコメント:
コメントを投稿