nutch with hbase

来源:互联网 发布:日本语言翻译软件 编辑:程序博客网 时间:2024/06/15 16:43

nutch 2.1 分布式hbase部署

    博客分类: 
  • nutch
  • hadoop
hbasehadoopnutch
官方文档:http://wiki.apache.org/nutch/Nutch2Tutorial?action=show&redirect=GORA_HBase 

现在网上针对nutch 2.0 以上版本的部署内容很残缺。经过两天奋战,终于把nutch 2.1在hbase上部署成功了!在此与网友分享。 

准备两台机器: 
cr5(master):192.168.8.185,cr8(slave):192.168.8.188 
这两台机器必须保证相互的ssh是通的(具体可以问谷歌) 
修改两台机器的/etc/hostname文件 
Java代码  收藏代码
  1. cr5  
  2. 或者  
  3. cr8  

修改两台机器的/etc/hosts文件 
Java代码  收藏代码
  1. 192.168.8.185   cr5  
  2. 192.168.8.188   cr8  



我准备在cr5机上运行进程: 

Hadoop: NameNode, SecondaryNameNode, JobTracker 
Hbase: HMaster 

在cr8机上运行进程: 

Hadoop: DataNode, TaskTracker 
Hbase: HQuorumPeer, HRegionServer 

接下来我们开始部署hadoop和hbase 
官网上有很多hadoop和hbase的版本,并不是所有的版本都可以被nutch 2.1支持的。 

官方文档有这么一句话: 
•Install and configure HBase. You can get it here (N.B. Gora 0.2 uses HBase 0.90.4, however the setup is known to work with more recent versions of the HBase 0.90.x branch) 

保险起见还是采用推荐的 hbase 0.90.x 版本吧。 

我选择的是 hadoop-1.0.4 和 hbase-0.90.6 

那如果采用其他版本在运行nutch的时候会报以下异常 
Java代码  收藏代码
  1. Exception in thread "main" java.lang.NoSuchMethodError:  
  2. org.apache.hadoop.hbase.HColumnDescriptor.setMaxVersions(I)V  

我觉得是因为gora的原因,因为gora的版本已经很久没有更新。 

一、配置hadoop 
   1. wget 命令下载对应的hadoop版本.tar.gz 
   2. tar zxvf hadoop版本.tar.gz 解压hadoop 
   3. cd conf 下修改配置文件 
     a. hadoop-env.sh 
     
Java代码  收藏代码
  1. export JAVA_HOME=/opt/jdk1.6.0_21  
  2.         

     b. core-site.xml 
     
Java代码  收藏代码
  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3.   <!-- Put site-specific property overrides in this file. -->  
  4.   <configuration>  
  5.      <property>  
  6.          <name>fs.default.name</name>  
  7.          <value>hdfs://cr5:9000/</value>  
  8.      </property>  
  9.      <property>  
  10.          <name>hadoop.tmp.dir</name>  
  11.          <value>/home/kfs/ww/data/hadoop_tmp</value>  
  12.          <description>此处设置hadoop根目录</description>  
  13.      </property>  
  14.   </configuration>  

     c. hdfs-site.xml 
     
Java代码  收藏代码
  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!-- Put site-specific property overrides in this file. -->  
  4.    <configuration>  
  5.       <property>  
  6.          <name>dfs.replication</name>  
  7.          <value>1</value>  
  8.          <description>副本个数</description>  
  9.       </property>  
  10.    </configuration>  

     d. mapred-site.xml 
    
Java代码  收藏代码
  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!-- Put site-specific property overrides in this file. -->  
  4.   <configuration>  
  5.      <property>  
  6.           <name>mapred.job.tracker</name>  
  7.           <value>cr5:9001</value>  
  8.           <description>jobtracker 标识:端口号</description>  
  9.      </property>  
  10.   </configuration>  

     e. masters 
    
Java代码  收藏代码
  1. cr5  

     f. slaves 
    
Java代码  收藏代码
  1. cr8  


配置完成后,将cr5的hadoop 复制到 cr8下面 
在cr5 的hadoop/bin 下面运行 
./hadoop -namenode format 
./hadoop -datanode format 

然后启动hadoop 
./start-all.sh 

检查启动成功与否 
查看hadoop/logs下面的×.log日志确保没有异常 
然后通过 
http://localhost:50030 
http://localhost:50070 
来查看信息 

二、配置hbase 
   1. wget 命令下载对应的hbase版本.tar.gz 
   2. tar zxvf hbase版本.tar.gz 解压hadoop 
   3. cd conf 下修改配置文件 
     a. hbase-site.xml 
    
Java代码  收藏代码
  1. <configuration>  
  2.         <property>  
  3.                 <name>hbase.rootdir</name>  
  4.                 <value>hdfs://cr5:9000/hbase</value>  
  5.         </property>  
  6.   
  7.         <property>  
  8.                 <name>hbase.cluster.distributed</name>  
  9.                 <value>true</value>  
  10.         </property>  
  11.   
  12.         <property>  
  13.                 <name>hbase.zookeeper.quorum</name>  
  14.                 <value>cr8</value>  
  15.         </property>  
  16.   
  17.         <property>  
  18.                 <name>hbase.zookeeper.property.dataDir</name>  
  19.                 <value>/home/kfs/ww/data/zookeeper_data</value>  
  20.         </property>  
  21.   
  22.         <property>  
  23.                 <name>hbase.zookeeper.property.clientPort</name>  
  24.                 <value>2181</value>  
  25.         </property>  
  26.   
  27.         <property>  
  28.                 <name>hbase.tmp.dir</name>  
  29.                 <value>/home/kfs/ww/data/hbase_tmp</value>  
  30.         </property>  
  31. </configuration>  
  32.        

     注意:这里的hdfs://cr5:9000/hbase和hadoop配置需对应 

     b. hadoop-env.sh 
     
Java代码  收藏代码
  1. export JAVA_HOME=/opt/jdk1.6.0_21  
  2. export HBASE_CLASSPATH=~/ww/hbase-0.90.6/conf  
  3. export HBASE_MANAGES_ZK=true  
  4.         

     c. regionservers 
Java代码  收藏代码
  1. cr8  


hbase 配置完成 
当然还有后续的工作 
1. 删除hbase中的hadoop-core-版本.jar,然后把hadoop中的hadoop-core-版本.jar和commons-collections-3.2.1.jar拷贝到hbase的lib中。 
否则hbase 的HMaster无法启动! 
2. 关闭防火墙 

到hbase/bin 下 通过 ./start-hbase.sh 启动hbase 
验证启动与否查看log是否有异常 
或者 http://localhost:60010查看具体信息 

三、nutch 配置 
部署到eclipse中就不加累述了,主要是配置~ 
   1. wget 命令下载对应的hadoop版本.tar.gz 
   2. tar zxvf hadoop版本.tar.gz 解压hadoop 
   3. cd conf 下修改配置文件 
      a. gora.properties 
Java代码  收藏代码
  1. gora.datastore.default=org.apache.gora.hbase.store.HBaseStore  

     b. nutch-site.xml 
Java代码  收藏代码
  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3.   
  4. <!-- Put site-specific property overrides in this file. -->  
  5.   
  6. <configuration>  
  7.     <property>  
  8.         <name>http.agent.name</name>  
  9.         <value>test-nutch</value>  
  10.     </property>  
  11.   
  12.     <property>  
  13.         <name>http.robots.agents</name>  
  14.         <value>test-nutch,*</value>  
  15.     </property>  
  16.   
  17.     <property>  
  18.         <name>http.agent.name.check</name>  
  19.         <value>true</value>  
  20.     </property>  
  21.   
  22.     <!-- property> <name>plugin.includes</name> <value>.*</value> <description>Enable   
  23.         all plugins during unit testing.</description> </property -->  
  24.   
  25.     <property>  
  26.         <name>distributed.search.test.port</name>  
  27.         <value>60000</value>  
  28.         <description>TCP port used during junit testing.</description>  
  29.     </property>  
  30.   
  31.     <property>  
  32.         <name>http.accept.language</name>  
  33.         <value>ja-jp, en-us,en-gb,en;q=0.7,*;q=0.3</value>  
  34.         <description>Value of the “Accept-Language” request header field.  
  35.             This  
  36.             allows selecting non-English language as default one to retrieve.  
  37.             It  
  38.             is a useful setting for search engines build for certain national  
  39.             group.  
  40.         </description>  
  41.     </property>  
  42.   
  43.     <property>  
  44.         <name>parser.character.encoding.default</name>  
  45.         <value>utf-8</value>  
  46.         <description>The character encoding to fall back to when no other  
  47.             information  
  48.             is available  
  49.         </description>  
  50.     </property>  
  51.   
  52.     <property>  
  53.         <name>storage.data.store.class</name>  
  54.         <value>org.apache.gora.hbase.store.HBaseStore</value>  
  55.         <description>The Gora DataStore class for storing and retrieving data.  
  56.             Currently the following stores are available: ….  
  57.         </description>  
  58.     </property>  
  59.       
  60.     <property>  
  61.         <name>hadoop.tmp.dir</name>  
  62.         <value>C:/data/hadoop_tmp</value>  
  63.         <description>此处设置hadoop根目录</description>  
  64.     </property>  
  65.   
  66. </configuration>  

     c. nutch-site.xml 
Java代码  收藏代码
  1. <property>  
  2.   <name>plugin.folders</name>  
  3.   <value>./src/plugin</value>  
  4.   <description>Directories where nutch plugins are located.  Each  
  5.   element may be a relative or absolute path.  If absolute, it is used  
  6.   as is.  If relative, it is searched for on the classpath.</description>  
  7. </property>  

     d. hbase-site.xml 
Java代码  收藏代码
  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3.   
  4. <configuration>  
  5.   
  6.     <property>  
  7.         <name>hbase.master</name>  
  8.         <value>cr5:60000</value>  
  9.     </property>  
  10.   
  11.     <property>  
  12.         <name>hbase.zookeeper.quorum</name>  
  13.         <value>cr8</value>  
  14.     </property>  
  15.   
  16.     <property>  
  17.         <name>hbase.zookeeper.property.clientPort</name>  
  18.         <value>2181</value>  
  19.     </property>  
  20.   
  21. </configuration>  

     e. ivy.xml 
Java代码  收藏代码
  1. <dependency org="org.apache.gora" name="gora-hbase" rev="0.2.1" conf="*->default" />  

     f. 新建urls文件夹,然后再文件夹中创建seed.txt ,在seed.txt中写入需要抓取的链接 
     g. regex-urlfilter.txt 加入抓取条件正则 

配置完成,后续工作 
nutch中的hbase-版本.jar需和部署的hbase的版本统一 

运行nutch 
配置Arguments信息 
1. Proguam arguments 
Java代码  收藏代码
  1. urls -depth 3 topN 5  
  2. 这里的urls就是nutch配置中生成的url种子文件夹  


2. VM arguments 
Java代码  收藏代码
  1. -Xms256m -Xmx512m -Dhadoop.log.dir=logs -Dhadoop.log.file=hadoop.log  


大功告成~~~ 


四、运行过程中异常处理 
1. point org.apache.nutch.net.URLNormalizer not found.请参见http://youkimra.iteye.com/blog/1039903 

2. ERROR org.apache.hadoop.mapred.TaskTracker: Can not start task tracker because java.io.IOException: Failed to set permissions of path: \tmp\hadoop-admin\mapred\local\ttprivate to 0700 
请参见:http://download.csdn.net/detail/java2000_wl/4326323 

3. nutch 中有一些plugin 的类缺少包,遇到问题补全包即可 


转载请注明来自:http://wangwei3.iteye.com/blog/1818599

0 0
原创粉丝点击