手机版
你好,游客 登录 注册
背景:
阅读新闻

Hadoop Herriot测试框架之旅

演示实例

[日期:2011-10-10] 来源:Linux社区  作者:nexus [字体:大 中 小]
我们来演示一下如何利用Herriot框架来跑一个测试用例。Herriot框架完全可以用于真实的HDFS分布式集群,但是为了方便起见,这个例子采用了HDFS的伪分布式集群,即在同一台机器上创建了一个namenode进程和一个datanode进程,并且在该机器上运行Herriot自带的测试用例TestHL040(hdfs工程的src/test/system/test目录下)。

1.  从Hadoop社区上下载hadoop-0.21.0.tar.gz,解压到Linux机器上,如/opt/hadoop/hadoop-0.21.0。

2.  进入到/opt/hadoop/hadoop-0.21.0/hdfs目录下,创建lib目录的符号链接:

  1. ln –s ../lib lib  

3.  修改文件:/opt/hadoop/hadoop-0.21.0/hdfs/ivy/libraries.properties:

  1. hadoop-common.version=0.21.0-SNAPSHOT  
  2. hadoop-hdfs.version=0.21.0-SNAPSHOT  

4.  修改文件:/opt/hadoop/hadoop-0.21.0/hdfs/build.xml:

  1. file="${system-test-build-dir}/ivy/lib/${ant.project.name}/system/hadoop-common-${herriot.suffix}-${hadoop-common.version}.jar"  

5.  在/opt/hadoop/hadoop-0.21.0/hdfs/目录下运行,运行成功后会生成build-fi目录:

  1. ant binary-system  

6.  设置环境变量$JAVA_HOME,并保证其生效:

  1. echo “export JAVA_HOME=/etc/alternatives/java_sdk” >> ~/.bashrc  

7.  设置环境变量$HADOOP_HOME,并保证其生效:

  1. exportHADOOP_HOME=/opt/hadoop/hadoop-0.21.0/hdfs/build-fi/system/hadoop-hdfs-0.21.1-SNAPSHOT  

8.  设置环境变量$HADOOP_CONF_DIR,并保证其生效:

  1. exportHADOOP_CONF_DIR=/opt/hadoop/hadoop-0.21.0/hdfs/build/test/conf  

9.  在$HADOOP_CONF_DIR中放置文件:hdfs-site.xml,为了实现伪分布式集群,hdfs-site.xml需要如下配置:

  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://localhost:9981</value>  
  8.   </property>  
  9.   <property>  
  10.     <name>dfs.replication</name>  
  11.   <value>1</value>  
  12.   </property>  
  13.   <property>  
  14.     <name>dfs.datanode.ipc.address</name>  
  15.     <value>0.0.0.0:9982</value>  
  16.   </property>  
  17. </configuration>  

10. 在$HADOOP_CONF_DIR中放置文件:masters(留空)

11. 在$HADOOP_CONF_DIR中放置文件:slaves,并执行如下命令:

  1. echo “localhost” > slaves  
  2. cp slaves slaves.copy  

12. 在$HADOOP_CONF_DIR中放置文件:system-test.xml,配置如下:

  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. <!-- Mandatory properties that are to be set and uncommented before running the tests -->  
  6.   
  7. <property>  
  8.   <name>test.system.hdrc.hadoophome</name>  
  9.   <value>/opt/hadoop/hadoop-0.21.0/hdfs/build-fi/system/hadoop-hdfs-0.21.1-SNAPSHOT</value>  
  10.   <description> This is the path to the home directory of the hadoop deployment.  
  11.   </description>  
  12. </property>  
  13. <property>  
  14.   <name>test.system.hdrc.hadoopconfdir</name>  
  15.   <value>/opt/hadoop/hadoop-0.21.0/hdfs/build/test/conf</value>  
  16.   <description> This is the path to the configuration directory of the hadoop  
  17.   cluster that is deployed.  
  18.   </description>  
  19. </property>  
  20.   
  21. <property>  
  22.   <name>test.system.hdrc.dn.hostfile</name>  
  23.   <value>slaves.copy</value>  
  24.   <description> File name containing the hostnames where the DataNodes are running.  
  25.   </description>  
  26. </property>  
  27.   
  28. <property>  
  29.   <name>test.system.hdfs.clusterprocess.impl.class</name>  
  30.   <value>org.apache.hadoop.hdfs.test.system.HDFSCluster$HDFSProcessManager</value>  
  31.   <description>  
  32.   Cluster process manager for the Hdfs subsystem of the cluster. The value  
  33.   org.apache.hadoop.hdfs.test.system.HDFSCluster$MultiUserHDFSProcessManager can  
  34.   be used to enable multi user support.  
  35.   </description>  
  36. </property>  
  37.   
  38. <property>  
  39.    <name>test.system.hdrc.deployed.scripts.dir</name>  
  40.    <value>./src/test/system/scripts</value>  
  41.    <description>  
  42.      This directory hosts the scripts in the deployed location where  
  43.      the system test client runs.  
  44.    </description>  
  45. </property>  
  46.   
  47. <property>  
  48.   <name>test.system.hdrc.hadoopnewconfdir</name>  
  49.   <value>/opt/hadoop/hadoop-0.21.0/hdfs/build/test/newconf</value>  
  50.   <description>  
  51.   The directory where the new config files will be copied to in all  
  52.   the clusters is pointed out this directory.   
  53.   </description>  
  54. </property>  
  55.   
  56. <property>  
  57.   <name>test.system.hdrc.suspend.cmd</name>  
  58.   <value>kill -SIGSTOP</value>  
  59.   <description>  
  60.     Command for suspending the given process.  
  61.   </description>  
  62. </property>  
  63.   
  64. <property>  
  65.   <name>test.system.hdrc.resume.cmd</name>  
  66.   <value>kill -SIGCONT</value>  
  67.   <description>  
  68.   Command for resuming the given suspended process.  
  69.   </description>  
  70. </property>  
  71.    
  72. </configuration>  

13.  进入$HADOOP_HOME目录,执行启动HDFS伪分布式集群:

  1. chmod +x bin/*  
  2. ./bin/start-dfs.sh  

14. 回到/opt/hadoop/hadoop-0.21.0/hdfs目录,执行测试用例:

  1. ant test-system –Dhaoop.conf.dir.deployed=$HADOOP_CONF_DIR  
linux
【内容导航】
第1页:简介 第2页:源码分析
第3页:演示实例
相关资讯       集群  Hadoop 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款