Run hadoop example

 

root@u1:/home/sa/hod/hadoop-0.20.1# bin/hadoop fs -put ./conf/core-site.xml  /input
root@u1:/home/sa/hod/hadoop-0.20.1# bin/hadoop jar hadoop-*-examples.jar wordcount /input /output2

root@u1:/home/sa/hod/hadoop-0.20.1# bin/hadoop jar hadoop-*-examples.jar
An example program must be given as the first argument.
Valid program names are:
  aggregatewordcount: An Aggregate based map/reduce program that counts the words in the input files.
  aggregatewordhist: An Aggregate based map/reduce program that computes the histogram of the words in the input files.
  dbcount: An example job that count the pageview counts from a database.
  grep: A map/reduce program that counts the matches of a regex in the input.
  join: A job that effects a join over sorted, equally partitioned datasets
  multifilewc: A job that counts words from several files.
  pentomino: A map/reduce tile laying program to find solutions to pentomino problems.
  pi: A map/reduce program that estimates Pi using monte-carlo method.
  randomtextwriter: A map/reduce program that writes 10GB of random textual data per node.
  randomwriter: A map/reduce program that writes 10GB of random data per node.
  secondarysort: An example defining a secondary sort to the reduce.
  sleep: A job that sleeps at each map and reduce task.
  sort: A map/reduce program that sorts the data written by the random writer.
  sudoku: A sudoku solver.
  teragen: Generate data for the terasort
  terasort: Run the terasort
  teravalidate: Checking results of terasort
  wordcount: A map/reduce program that counts the words in the input files.

localadmin@node1:~/hadoop-0.20.2$ hadoop jar hadoop-0.20.2-examples.jar wordcount
Usage: wordcount <in> <out>

 

转载于:https://www.cnblogs.com/licheng/archive/2011/11/08/2241780.html

### Hadoop与Hive的集成概述 Hive 是一种建立在 Hadoop 上的数据仓库工具,用于简化大数据分析过程。它允许用户通过 SQL 类似的查询语言 (HQL) 来操作存储在 HDFS 中的大规模数据集[^1]。 为了实现 Hadoop 和 Hive 的无缝集成,通常需要完成以下几个方面的配置: --- ### 1. **环境准备** #### a. 安装 Hadoop 并验证其功能 确保 Hadoop 已经成功部署并正常运行。可以通过以下命令提供必要的类路径支持: ```bash export HADOOP_CLASSPATH=`hadoop classpath` ``` 此步骤对于后续 Hive 的正确执行至关重要,因为它依赖于 Hadoop 提供的核心库来访问分布式文件系统和 MapReduce 功能。 #### b. 使用 Docker 构建集群(可选) 如果希望通过容器化的方式快速搭建测试环境,则可以利用 Docker 创建一个包含 Hadoop、Hive 和其他组件的基础镜像。以下是启动基础容器的一个示例命令: ```bash docker run -d --network hadoop --env-file hadoop.env --name hadoop-base bde2020/hadoop-base:2.0.0-hadoop3.2.1-java8 tail -f /dev/null ``` 上述命令会创建一个名为 `hadoop-base` 的辅助容器,并将其加入到指定网络中以便与其他服务通信[^2]。 --- ### 2. **Hive Server 配置调整** 当计划使用 HiveServer2 处理复杂业务逻辑时,需特别注意并发控制机制的设计。具体来说,应该启用表级锁定管理器以防止潜在冲突发生。为此,在 `/etc/hive/conf/hive-site.xml` 文件内添加如下参数定义即可满足需求[^3]: ```xml <property> <name>hive.support.concurrency</name> <value>true</value> <description>Enable Hive's Table Lock Manager Service.</description> </property> <property> <name>hive.zookeeper.quorum</name> <value>zoo1.example.com,zoo2.example.com,zoo3.example.com</value> <description>Zookeeper quorum used by Hive's Table Lock Manager.</description> </property> ``` 这里需要注意的是,实际部署过程中应将占位符替换为真实的 ZooKeeper 节点地址列表;同时确认这些服务器均已按照官方文档指引完成了初始化工作。 --- ### 3. **简单案例演示——加载外部表格至 Hive** 假设存在一份 CSV 格式的原始记录存放在本地磁盘上,目标是导入该资料作为新关系型结构的一部分参与进一步计算流程。下面给出了一套完整的脚本片段展示如何达成这一目的: ```sql -- Step A: Create an external table pointing to the raw data location. CREATE EXTERNAL TABLE IF NOT EXISTS my_external_table ( id INT, name STRING, age INT ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LOCATION '/path/to/csv'; -- Step B: Query from this newly created resource directly within your session context. SELECT * FROM my_external_table LIMIT 10; ``` 以上代码首先声明了一个指向特定目录下的外部表对象,接着尝试读取其中若干条目加以预览。 --- ### 总结 综上所述,从基本概念介绍直至实践演练环节均围绕着怎样有效衔接起这两个关键技术展开讨论。希望读者能够从中受益匪浅!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值