apache mesos

by Marco Massenzio

由Marco Massenzio

试用Apache Mesos HTTP API获得乐趣和收益 (Experimenting with the Apache Mesos HTTP API for Fun and Profit)

Apache Mesos is a tool used in production at large-scale services like Twitter and Airbnb. Here’s its textbook description:

Apache Mesos是Twitter和Airbnb等大规模服务中用于生产的工具。 这是它的教科书描述:

The Mesos kernel runs on every machine and provides applications (e.g., Hadoop, Spark, Kafka, Elasticsearch) with API’s for resource management and scheduling across entire datacenter and cloud environments. — from the Apache Mesos project site.

Mesos内核在每台机器上运行,并为应用程序(例如Hadoop,Spark,Kafka,Elasticsearch)提供API,用于在整个数据中心和云环境中进行资源管理和调度。 —从Apache Mesos项目站点。

This is the first of a series of three articles that show how to setup a Vagrant-based Apache Mesos test/development environment on your laptop, how to run a Python notebook against the HTTP API, and how to launch Docker containers on the running Agent VM.

这是三篇系列文章中的第一篇,该系列文章介绍如何在笔记本电脑上设置基于Vagrant的Apache Mesos测试/开发环境,如何针对HTTP API运行Python笔记本以及如何在正在运行的Agent上启动Docker容器虚拟机。

This series is an extended (and updated) version of the talk I gave at MesosCon Europe 2015 updated for Apache Mesos 1.0.0, which has just been released (August 2016) — you can also find the slides there.

本系列是我在MesosCon Europe 2015上 演讲的扩展(和更新)版本,该演讲针对Apache Mesos 1.0.0(已于2016年8月发布)进行了更新-您也可以在此处找到幻灯片 。

This post is pretty jam-packed, and will require you to be familiarity with some concepts around containers, VMs, and Mesos. But I’ll take the time to show all the intermediate steps (hence, the 3-parts). It should be easy to follow, even if you’ve never used Vagrant, Mesos, or even Jupyter notebooks before.

这篇文章挤满了人,需要您熟悉有关容器,VM和Mesos的一些概念。 但是,我将花一些时间介绍所有中间步骤(因此分为3部分)。 即使您以前从未使用过Vagrant,Mesos甚至Jupyter笔记本电脑,也应该易于遵循。

I recommend you first have a basic familiarity with Python and handling HTTP requests and responses, as we will not be going those details there.

我建议您首先对Python和处理HTTP请求和响应有一个基本的了解,因为我们在这里不再赘述。

All the code is available on the zk-mesos git repository:

所有代码都可以在zk-mesos git存储库中找到 :

git clone git@github.com:massenz/zk-mesos.git

And you can also view the README.

您还可以查看README 。

入门 (Getting Started)

In order to follow along, you will need to clone the repository (as shown above) and install Virtualbox and Vagrant. Follow the instructions on their respective sites and you’ll be up and running in no time.

为了进行后续操作,您将需要克隆存储库(如上所示)并安装Virtualbox和Vagrant 。 按照其各自站点上的说明进行操作,您将立即启动并运行。

I also recommend quickly scanning the Vagrant documentation. A knowledge of Vagrant beyond `vagrant up` is not really required to get the most out of this series, but it may help if you get stuck (or would like to experiment and improve on our Vagrantfile).

我还建议快速扫描Vagrant文​​档。 要充分利用本系列的知识,并不是真正需要“ vagrant up ”以外的Vagrant知识,但是如果您陷入困境(或者想对我们的Vagrantfile进行试验和改进),则可能会有所帮助。

If you’re not familiar with Apache Mesos I recommend taking a look at the project’s site. I recommend reading Mesos in Action (note that I was one of the manuscript’s reviewers).

如果您不熟悉Apache Mesos ,建议您查看该项目的站点。 我建议阅读《 Mesos in Action》 (请注意,我是手稿的审阅者之一)。

We will not be building Mesos from source here, but will instead use Mesosphere packages. You don’t need to download them. The Vagrantfile will automatically download and install on the VMs.

我们不会在这里从源代码构建Mesos,而是使用Mesosphere软件包 。 您不需要下载它们。 Vagrantfile将自动下载并安装在VM上。

To run the Python notebook, we’ll take advantage of the Jupyter packages, and use a virtualenv to run all of our code. Virtualenv isn’t strictly necessary, but will prevent you messing up your system Python.

要运行Python笔记本,我们将利用Jupyter软件包,并使用virtualenv运行所有代码。 Virtualenv不是严格必需的,但是可以防止您弄乱系统Python。

If you‘ve never used virtualenv before:

如果您以前从未使用过virtualenv :

$ sudo pip install virtualenv

And then create and run a virtualenv:

然后创建并运行一个virtualenv

$ cd zk-mesos $ virtualenv mesos-demo$ source mesos-demo/bin/activate $ pip install -r requirements.txt

Finally, verify that you can run and load the Jupyter notebook:

最后,确认您可以运行并加载Jupyter笔记本:

$ jupyter notebook

This should automatically open your browser and point it to http://localhost:8888. From here you can select the notebooks/Demo-API.ipynb file. Don’t run it just yet, but if it shows up, it will confirm that your Python setup is just fine.

这应该会自动打开浏览器,并将其指向http:// localhost:8888 。 在这里,您可以选择notebooks / Demo-API.ipynb文件。 暂时不要运行它,但是如果显示出来,它将确认您的Python设置很好。

构建和安装Apache Mesos (Building and installing Apache Mesos)

This is where the beauty of Vagrant shines in all its glory. Installing Apache Mesos Master and Agent are not trivial tasks, but in our case, it’s just a matter of:

这就是流浪者的美丽在所有荣耀中闪耀的地方。 安装Apache Mesos Master和Agent并不是一件容易的事,但就我们而言,这只是一个问题:

$ cd vagrant $ vagrant up

Make sure that you’re in the same directory as the Vagrantfile when issuing any of the Vagrant commands, or it will complain about it.

发出任何Vagrant命令时,请确保与Vagrantfile位于同一目录中,否则它将抱怨。

It is worth noting that we are building two Vagrant boxes, so any command will operate on both unless specified. To avoid this, you can specify the name of the VM after the command. For example, to SSH onto the Agent:

值得注意的是,我们正在构建两个 Vagrant框,因此,除非指定,否则任何命令都将对 两个框进行操作。 为避免这种情况,您可以在命令后指定VM的名称。 例如,要SSH到代理上:

$ vagrant ssh agent

This should log you in on that box. From there, you can explore, experiment, and diagnose any issues.

这将使您登录该框。 从那里,您可以探索,试验和诊断任何问题。

The vagrant up command will take some time to execute, but it should eventually lead your Virtualbox to have two VMs, named respectively mesos-master and mesos-agent. Incidentally, you should never need to use VirtualBox to manage them. All the tasks can be undertaken via Vagrant commands. But you can manage them manually if necessary or desired.

vagrant up命令将花费一些时间来执行,但最终将导致您的Virtualbox具有两个VM,分别命名为mesos-mastermesos-agent 。 顺便说一句,您永远不需要使用VirtualBox来管理它们。 所有任务都可以通过Vagrant命令执行。 但是,如有必要或期望,您可以手动管理它们。

Once your VMs are built, ensure you can access Mesos HTTP UI at:

构建完虚拟机后,请确保可以通过以下方式访问Mesos HTTP UI:

http://192.168.33.10:5050

You should also see one agent running, accessible either via the Master UI.

您还应该看到一个正在运行的代理,可以通过主UI进行访问。

Or directly at:

或直接在:

http://192.168.33.11:5051/state

Note that the Agent runs not only on a different IP address than the Master, but also on a different port (5051 instead of 5050).

请注意,代理不仅在与主服务器不同的IP地址上运行,而且在不同的端口(5051而不是5050)上运行。

Look into vagrant/run-agent.sh to see a few of the command line flags that we use to run the Agent (and in run-master.sh for the Master).

查看vagrant / run-agent.sh,以查看我们用于运行代理的一些命令行标志(对于Master,在run-master.sh中)。

动物园管理员 (Zookeeper)

It’s worth noting that we are also running an instance of Zookeeper (for Leader election and Master/Agent coordination) on the mesos-master VM, inside a Docker container: partly because we can, but also to show how easy it is to do so using containers.

值得注意的是,我们还在Docker容器内的mesos-master VM上运行了Zookeeper实例(用于Leader选举和Master / Agent协调):部分原因是我们可以这样做,但同时也表明这样做很容易使用容器。

This one line (in run-master.sh), will give you a perfectly good ZK instance (albeit, a catastrophically unreliable one in a production environment, where you’d want to run at least 3–5 nodes, at least, on physically separate machines/racks):

这一行(在run-master.sh中 )将为您提供一个非常好的ZK实例(尽管在生产环境中,这是一个灾难性的不可靠实例),在该生产环境中,您至少要在3-5个节点上运行物理上分开的机器/机架):

docker run -d --name zookeeper -p 2181:2181 -p 2888:2888 \    -p 3888:3888 jplock/zookeeper:3.4.8

And because we expose the ports (in particular, 2181) to the host VM, we can connect to it via the Zookeeper CLI utility (zkCli.sh) and explore it. From your development machine (you will need to first download Zookeeper) you can use:

并且由于我们将端口(特别是2181)公开给主机VM,因此我们可以通过Zookeeper CLI实用程序( zkCli.sh )连接到它并进行浏览。 在开发机器(您需要首先下载Zookeeper)中,可以使用:

$ zkCli.sh -server 192.168.33.10:2181...[zk: 192.168.33.10:2181(CONNECTED) 4] get /mesos/vagrant/json.info_0000000000
# Formatted for better readability:{"address":  { "hostname": "mesos-master",    "ip":"192.168.33.10",    "port":5050  },  "hostname":"mesos-master",  "id":"7eb34f10-b07c-4921-aece-bbaece09dfd1",  "ip":169978048,  "pid":"master@192.168.33.10:5050",  "port":5050,  "version":"1.0.0"}
cZxid = 0xbctime = Sat Aug 27 14:00:44 PDT 2016...

This is how Agents get information about how to connect to the Master node.

这是代理如何获取有关如何连接到主节点的信息。

The _000000 suffix gets incremented every time a new Leader gets elected, so depending on how long the ZK instance has been running and whether the Master was restarted, it may become something like _0000005. That is an “ephemeral node” in Zookeeper’s parlance.

每次选举新的Leader时,后缀_000000都会增加,因此取决于ZK实例运行了多长时间以及是否重新启动了主服务器,它的后缀可能类似于_0000005。 在Zookeeper的说法中,这是一个“ 短暂节点”

In that record above, it is worth noting that “pid” is libprocess unique identifier and “ip” as a compressed 4-byte representation of an IPv4 octect quadruple. These legacy fields and may eventually be removed.

在上面的记录中,值得注意的是,“ pid”是libprocess唯一标识符,“ ip”是IPv4 octect四元组的压缩4字节表示形式。 这些旧字段可能最终会被删除。

结语 (Wrap Up)

You are now the proud owner of a Master/Agent 2-node Apache Mesos deployment. Welcome in the same league as Twitter and Airbnb production wizards.

您现在是Master / Agent 2节点Apache Mesos部署的骄傲拥有者。 欢迎与Twitter和Airbnb制作向导同盟。

In Part 2, we’ll run our Python notebook against the Master API and will accept the Agent’s offers to launch a Docker container.

在第2部分中,我们将针对Master API运行Python笔记本,并将接受代理提供的启动Docker容器的报价。

If you’ve got time, let’s jump on in and learn how to connect to Mesos Master and accept Resource Offers.

如果您有时间,请继续学习如何连接到Mesos Master并接受Resource Offer 。

Originally published at codetrips.com on August 27, 2016.

最初于2016年8月27日发布在codetrips.com 。

翻译自: https://www.freecodecamp.org/news/experimenting-with-the-apache-mesos-http-api-for-fun-and-profit-part-1-of-3-cf5736e84f85/

apache mesos

apache mesos_试用Apache Mesos HTTP API获得乐趣和收益相关推荐

  1. apache mesos_在Twitter上使用Apache Mesos和Apache Aurora进行资源调度和任务启动

    apache mesos 播客的第23集是与Bill Farner的谈话 Bill解释了Twitter如何使用Apache Mesos和Apache Aurora在硬件上获得更多收益,并通过在整个基础 ...

  2. Apache Storm 官方文档 —— Trident API 概述

    转载自并发编程网 – ifeve.com本文链接地址: Apache Storm 官方文档 -- Trident API 概述 窗口部分的内容是我自己翻译的 Trident 的核心数据模型是" ...

  3. Apache Flink vs Apache Spark——感觉二者是互相抄袭啊 看谁的好就抄过来 Flink支持在runtime中的有环数据流,这样表示机器学习算法更有效而且更有效率...

    Apache Flink是什么 Flink是一款新的大数据处理引擎,目标是统一不同来源的数据处理.这个目标看起来和Spark和类似.没错,Flink也在尝试解决 Spark在解决的问题.这两套系统都在 ...

  4. 今日直播 | Apache Hudi x Apache Pulsar Meetup线上专场如期而至 大咖齐聚

    简介:Apache Hudi 与 Apache Pulsar 联合 Meetup 线上专场将于2021 年 8 月 30 日(今天) 14:00开启直播,你准备好了吗? Apache Hudi 与 A ...

  5. ssis组件_使用SSIS Hadoop组件连接到Apache Hive和Apache Pig

    ssis组件 In our previously published articles in this series, we talked about many SSIS Hadoop compone ...

  6. Apache工具库——Apache Commons的使用

    Apache Commons是Apache开源的一个java组件库,其中包含了大量子项目,其中常用的组件有: 组件 功能介绍 BeanUtils 提供了对于JavaBean进行各种操作,克隆对象,属性 ...

  7. Apache 基金会宣布 Apache Kylin 成为顶级项目

    Apache软件基金会宣布Apache Kylin成为顶级项目 Apache Kylin是可扩展到PB规模的开源分布式大数据分析引擎,已被应用在eBay,Exponential, 京东,美团,明略数据 ...

  8. Apache Pulsar和Apache BookKeeper

    文章目录 Apache Pulsar 诞生背景及追求 诞生背景 发展历程 追求.愿景 安装部署 安装参考 相关知识介绍 消息消费模型 生产(发布) 消费模型 ACK机制 消息的保留策略 对比Kafka ...

  9. 社区活动|Apache Hudi x Apache Pulsar Meetup 杭州站来啦!

    关于 Apache Pulsar Apache Pulsar 是 Apache 软件基金会顶级项目,是下一代云原生分布式消息流平台,集消息.存储.轻量化函数式计算为一体,采用计算与存储分离架构设计,支 ...

最新文章

  1. MacOS上的包管理工具
  2. Jfreechart显示数据点图表(线上可以显示点数据)
  3. Windows Embedded Standard 7 剪裁随笔
  4. MFC工作笔记0003---WindowsAPI与MFC的关系
  5. VS下如何配置才能使用 cl 命令行方式编译 C/C++ 程序
  6. 经济学的思维方式二 效率 交换与比较优势
  7. protues仿真控制舵机
  8. 麻省理工18年春软件构造课程阅读06“规格说明”
  9. Hive On Spark搭建报错:Failed to create Spark client for Spark session xx: ..TimeoutException
  10. 在知网上找不到的英文文献应该去哪里找?
  11. ffmpeg截取视频指定帧方法
  12. android壁纸和手机屏幕之间要怎么对应,安卓Android手机屏幕壁纸分辨率选择技巧...
  13. 【linux命令学习】— cut 和 tr 命令学习
  14. pgsql之create user与create role的区别
  15. C++面试题目及面试经验
  16. UiPath Robotic Enterprise Framework 学习笔记
  17. 计算机操作系统——操作系统概述
  18. 数字电子技术实验作业(7)
  19. php mysql收款系统下载_php+mysql简易扫码付教育收费系统 v1.2
  20. 分段式多级离心泵_D型卧式分段式多级离心泵结构图

热门文章

  1. python字符串是用双引号括起来的_用python连接字符串列表并用引号将每个字符串括起来...
  2. 利用layui前端框架实现对不同文件夹的多文件上传
  3. python 编码规范
  4. docker在Centos上的安装
  5. jQUery中closest和parents的主要区别是
  6. STM32f4 ARM Bootloader
  7. 分享网页设计当中使用进度条打造精美界面最佳例子
  8. 解决FTPClient上传文件为空,显示0字节
  9. RUNOOB python练习题4
  10. 相机添加多张图片css布局