Apache Hadoop HDFS数据节点Apache Mesos框架

介绍

该项目允许在Mesos上运行HDFS。 您应该熟悉HDFS和Mesos基础知识:



项目要求:

  • Mesos 0.23.0+
  • JDK 1.7.x
  • Hadoop 1.2.x或2.7.x

流浪汉

项目包括无所事事的环境 ,允许在本地运行Mesos集群。 如果您要使用外部Mesos群集,则可以跳过本节。

1.启动流浪节点:

# cd hdfs-mesos/vagrant
# vagrant up

它创建mesos主节点和从节点。

2.流浪者节点名称添加到/etc/hosts

现在,流浪汉中的Mesos应该正在运行。 您可以继续启动调度程序。 有关流浪者环境的更多详细信息,请阅读vagrant / README.md

运行调度程序

1.下载hdfs-mesos\*.jar或克隆并构建项目:

下载jar:

# mkdir hdfs-mesos
# cd hdfs-mesos
# wget https://github.com/elodina/hdfs-mesos/releases/download/0.0.1.0/hdfs-mesos-0.0.1.0.jar

克隆并构建:

# git clone https://github.com/elodina/hdfs-mesos.git
# cd hdfs-mesos
# ./gradlew jar

2.下载hadoop tarball:

# wget https://archive.apache.org/dist/hadoop/core/hadoop-2.7.2/hadoop-2.7.2.tar.gz

3.启动调度程序:

# ./hdfs-mesos.sh scheduler --api=http://$scheduler:7000 --master=zk://$master:2181/mesos --user=vagrant
2016-03-18 15:04:48,785 [main] INFO hdfs.Scheduler - Starting Scheduler:
api: http://$scheduler:7000
files: jar:./hdfs-mesos-0.0.1.0.jar, hadoop:./hadoop-1.2.1.tar.gz
mesos: master:master:5050, user:vagrant, principal:<none>, secret:<none>
framework: name:hdfs, role:*, timeout:30d
2016-03-18 15:04:48,916 [main] INFO hdfs.HttpServer - started on port 7000
I0318 15:04:49.008314 19123 sched.cpp:164] Version: 0.25.0
I0318 15:04:49.017160 19155 sched.cpp:262] New master detected at master@192.168.3.5:5050
I0318 15:04:49.019287 19155 sched.cpp:272] No credentials provided. Attempting to register without authentication
I0318 15:04:49.029218 19155 sched.cpp:641] Framework registered with 20160310-141004-84125888-5050-10895-0006
2016-03-18 15:04:49,044 [Thread-17] INFO hdfs.Scheduler - [registered] framework:#-0006 master:#326bb pid:master@192.168.3.5:5050 hostname:master
2016-03-18 15:04:49,078 [Thread-18] INFO hdfs.Scheduler - [resourceOffers]
slave0#-O761 cpus:1.00; mem:2500.00; disk:35164.00; ports:[5000..32000]
master#-O762 cpus:1.00; mem:2500.00; disk:35164.00; ports:[5000..32000]
...
2016-03-18 15:04:49,078 [Thread-18] INFO hdfs.Scheduler - [resourceOffers]

哪里:

  • $scheduler是可从节点访问的$scheduler程序地址;
  • $master可从调度程序节点访问的主地址;

调度程序应自行注册并开始接收资源报价。 如果调度程序未收到报价,则可能需要指定LIBPROCESS_IP:

# export LIBPROCESS_IP=$scheduler_ip

现在调度程序应该正在运行,您可以继续启动HDFS节点。

运行HDFS群集

Project提供了CLI和REST API,用于管理HDFS节点。 我们将首先关注CLI。

1.添加名称节点和数据节点:

# ./hdfs-mesos.sh node add nn --type=namenode
node added:
  id: nn
  type: namenode
  state: idle
  resources: cpus:0.5, mem:512

# ./hdfs-mesos.sh node add dn0 --type=datanode
node added:
  id: dn0
  type: datanode
  state: idle
  resources: cpus:0.5, mem:512

2.启动节点:

# ./hdfs-mesos.sh node start \*
nodes started:
  id: nn
  type: namenode
  state: running
  resources: cpus:0.5, mem:512
  reservation: cpus:0.5, mem:512, ports:http=5000,ipc=5001
  runtime:
    task: 383aaab9-982b-400e-aa35-463e66cdcb3b
    executor: 19065e07-a006-49a4-8f2b-636d8b1f2ad6
    slave: 241be3a2-39bc-417c-a967-82b4018a0762-S0 (master)

  id: dn0
  type: datanode
  state: running
  resources: cpus:0.5, mem:512
  reservation: cpus:0.5, mem:512, ports:http=5002,ipc=5003,data=5004
  runtime:
    task: 37f3bcbb-10a5-4323-96d2-aef8846aa281
    executor: 088463c9-5f2e-4d1d-8195-56427168b86f
    slave: 241be3a2-39bc-417c-a967-82b4018a0762-S0 (master)

节点已启动并正在运行。

注意:开始可能需要一些时间。 您可以通过Mesos UI查看进度。

3.执行一些FS操作:

# hadoop fs -mkdir hdfs://master:5001/dir
# hadoop fs -ls hdfs://master:5001/
Found 1 items
drwxr-xr-x   - vagrant supergroup          0 2016-03-17 12:46 /dir

注意:在fs url中使用了namenode主机和ipc端口。

使用CLI

Project提供具有以下结构的CLI:

# ./hdfs-mesos.sh help
Usage: <cmd> ...

Commands:
  help [cmd [cmd]] - print general or command-specific help
  scheduler        - start scheduler
  node             - node management

为每个命令和子命令提供了帮助:

# ./hdfs-mesos.sh help node
Node management commands
Usage: node <cmd>

Commands:
  list       - list nodes
  add        - add node
  update     - update node
  start      - start node
  stop       - stop node
  remove     - remove node

Run `help node <cmd>` to see details of specific command

# ./hdfs-mesos.sh help node add
Add node
Usage: node add <ids> [options]

Option (* = required)  Description
---------------------  -----------
--core-site-opts       Hadoop core-site.xml options.
--cpus <Double>        CPU amount (0.5, 1, 2).
--executor-jvm-opts    Executor JVM options.
--hadoop-jvm-opts      Hadoop JVM options.
--hdfs-site-opts       Hadoop hdfs-site.xml options.
--mem <Long>           Mem amount in Mb.
* --type               node type (name_node, data_node).

Generic Options
Option  Description
------  -----------
--api   REST api url (same as --api option for
          scheduler).

所有与节点相关的命令都支持使用node-id-expressions进行批量操作。 例子:

# ./hdfs-mesos.sh node add dn0..1 --type=datanode
nodes added:
  id: dn0
  type: datanode
  ...

  id: dn1
  type: datanode
  ...

# ./hdfs-mesos.sh node update dn* --cpus=1
nodes updated:
  id: dn0
  ...
  resources: cpus:1.0, mem:512

  id: dn1
  ...
  resources: cpus:1.0, mem:512

# ./hdfs-mesos.sh node start dn0,dn1
nodes started:
  id: dn0
  ...

  id: dn0
  ...

ID表达式示例:

  • nn –匹配ID为nn的节点
  • * –匹配任何节点(应在外壳中使用斜线转义)
  • dn* –匹配ID以dn开头的节点
  • dn0..2 –匹配节点dn0,dn1,dn2

使用REST

计划程序使用嵌入式HTTP服务器。 服务器具有两个功能:

  • 分发Hadoop,JRE和执行程序的二进制文件;
  • 提供REST API,由CLI调用;

大多数CLI命令都映射到REST API调用。 例子:

CLI命令 REST电话
node add nn --type=namenode --cpus=2 /api/node/add?node=nn&type=namenode&cpus=2
node start dn* --timeout=3m- /api/node/start?node=dn*&timeout=3m
node remove dn5 /api/node/remove?node=dn5

REST调用接受纯HTTP参数,并返回JSON响应。 例子:

# curl http://$scheduler:7000/api/node/list
[
    {
        "id": "nn",
        "type": "namenode",
        ...
    },
    {
        "id": "dn0",
        "type": "datanode",
        ...
    }
]

# curl http://$scheduler:7000/api/node/start?node=nn,dn0
{
    "status": "started",
    "nodes": [
        {
            "id": "nn",
            "state": "running",
            ...
        },
        {
            "id": "dn0",
            "state": "running",
            ...
        }
    ]
}

CLI参数将一对一映射到REST参数。 CLI参数使用虚线样式,而REST参数使用驼峰式。 映射示例:

CLI参数 REST参数
<id> (节点添加|更新| ...) node
timeout (节点开始|停止) timeout
core-site-opts (节点添加|更新) coreSiteOpts
executor-jvm-opts (节点添加|更新) executorJvmOpts

在某些情况下,REST API调用可能返回错误。 错误标记为状态代码,而不是200。错误响应以JSON格式返回。

例:

# curl -v http://192.168.3.1:7000/api/node/start?node=unknown
...
HTTP/1.1 400 node not found
...
{"error":"node not found","code":400}

有关REST API的更多详细信息,请参阅源。

翻译自: https://www.javacodegeeks.com/2016/06/apache-hadoop-hdfs-data-node-apache-mesos-framework.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值