• hadoop实例 RandomWriter


    参考文献:http://www.hadooper.cn/dct/page/65778

    1.概述

    RandomWriter(随机写)例子利用 Map/Reduce把 数据随机的写到dfs中。每个map输入单个文件名,然后随机写BytesWritable的键和值到DFS顺序文件。map没有产生任何输出,所以reduce没有执行。产生的数据是可以配置的。配置变量如下

    名字
    默认值
    描述

    test.randomwriter.maps_per_host

    10
    每个节点运行的map任务数

    test.randomwrite.bytes_per_map

    1073741824
    每个map任务产生的数据量

    test.randomwrite.min_key

    10
    minimum size of the key in bytes

    test.randomwrite.max_key

    1000
    maximum size of the key in bytes

    test.randomwrite.min_value

    0
    minimum size of the value

    test.randomwrite.max_value

    20000
    maximum size of the value

    test.randomwriter.maps_per_host表示每个工作节点(datanode)上运行map的次数。默认情况下,只有一个数据节点,那么就有10个map,每个map的数据量为1G,因此要将10G数据写入到hdfs中。我配置的试验环境中只有2个工作节点,不过我希望每个工作节点只有1个map任务。

    test.randomwrite.bytes_per_map我原本以为是随机写输出的测试文件的大小,默认为1G=1*1024*1024*1024,但是我将这个数据改成1*1024*1024以后,输出的测试文件还是1G,这让我很不解。(PS:2011-11-2,今天知道这个参数表示没个map任务产生的数据量,如果将其改为1*1024*1024,那么就表示没个map任务产生的数据量为1MB。)(PS:2011-11-3,修改参数test.randomwrite.bytes_per_map并不能更改每个map任务产生的数据量,还是1G,不管我将这个参数设定为什么值。不过修改参数:test.randomwriter.maps_per_host是有效的。测试发现将该参数设为1和2都测试通过。问题:在哪里修改test.randomwrite.bytes_per_map才能真正修改map任务产生的数据量。!

    2.代码实例

    其中test.randomwrite.bytes_per_map=1*1024*1024,test.randomwriter.maps_per_host=1。

    输出信息:

    在hdfs上产生了两个文件,在/home/hadoop/rand目录下,分别是part-00000(1Gb,r3)和part-00001(1Gb,r3)


    作者:xwdreamer
    欢迎任何形式的转载,但请务必注明出处。
    分享到:
  • 相关阅读:
    Deep Reinforcement Learning: Pong from Pixels
    [TensorFlow] Creating Custom Estimators in TensorFlow
    [TensorFlow] Introducing TensorFlow Feature Columns
    [TensorFlow] Introduction to TensorFlow Datasets and Estimators
    [Golang] GoConvey测试框架使用指南
    [机器学习]一个例子完美解释朴素贝叶斯分类器
    [深度学习]理解RNN, GRU, LSTM 网络
    [深度学习]CNN--卷积神经网络中用1*1 卷积有什么作用
    Tensorflow学习笔记(2):tf.nn.dropout 与 tf.layers.dropout
    TensorFlow学习笔记(1):variable与get_variable, name_scope()和variable_scope()
  • 原文地址:https://www.cnblogs.com/xwdreamer/p/2296957.html
Copyright © 2020-2023  润新知