apache mesos_试用Apache Mesos HTTP API获得乐趣和收益

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/396277.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

epoll哪些触发模式_5.epoll的水平触发和边缘触发

本篇是多路复用的第五篇,主要来讲解epoll的水平触发和边缘触发是怎么回事。一、概念介绍EPOLL事件有两种模型,水平出发和边缘触发,如下所示:1. Level Triggered (LT) 水平触发1. socket接收缓冲区不为空 有数据可读 读事件一直触发…

HC系列蓝牙模块连接单片机与电脑,传输数据(蓝牙心电测试)

毕设做无线心电监护。有线的做出来了,AD8232MCULabVIEW上位机。pcb还没时间搞,这个9*7*2.5cm拿来测试能用。 自己做了AD8232的模拟前端,打的板子还没到没法测试。 虽然比较水,但看起来任务也完成的差不多了,于是就想加…

java实现社交平台_GitHub - akpaul9527/symphony: 一款用 Java 实现的现代化社区(论坛/BBS/社交网络/博客)平台。...

下一代的社区系统,为未来而构建简介Symphony([ˈsɪmfəni],n.交响乐)是一个现代化的社区平台,因为它:实现了面向内容讨论的论坛实现了面向知识问答的社区包含了面向用户分享、交友、游戏的社交网络100% 开源动机很多社区论坛系统…

远程连接本地mongodb 数据库

绑定本地IP即可 start mongod --dbpath D:\mongodb\data\db --bind_ip 192.168.31.143 转载于:https://www.cnblogs.com/yang-xiansen/p/9884598.html

qt日志实现

qt的日志有四个级别&#xff1a;qDebug&#xff1a; 调试信息qWarning&#xff1a; 警告信息qCritical&#xff1a; 严重错误qFatal&#xff1a; 致命错误可以通过<QtGlobal>下的void qCritical ( const char * msg, ... );void qDebug ( const char *…

mvc 视图和模型的对应_通过在酒吧订购饮料来解释模型视图控制器(MVC)

mvc 视图和模型的对应by Kevin Kononenko凯文科诺年科(Kevin Kononenko) 通过在酒吧订购饮料来解释模型视图控制器(MVC) (Model-View-Controller (MVC) Explained Through Ordering Drinks At The Bar) 如果您去过酒吧&#xff0c;那么MVC并不难。 (If you have been to a bar…

nodejs计算时间间隔_Javascript计算时间差的函数分享

核心代码/** 获得时间差,时间格式为 年-月-日 小时:分钟:秒 或者 年/月/日 小时&#xff1a;分钟&#xff1a;秒* 其中&#xff0c;年月日为全格式&#xff0c;例如 &#xff1a; 2010-10-12 01:00:00* 返回精度为&#xff1a;秒&#xff0c;分&#xff0c;小时&#xff0c;天*…

jQuery实现鼠标划过展示大图的方法

这篇文章主要介绍了jQuery实现鼠标划过展示大图的方法,实例分析了jQuery操作鼠标事件及图片处理的技巧,具有一定参考借鉴价值,需要的朋友可以参考下 本文实例讲述了jQuery实现鼠标划过展示大图的方法。分享给大家供大家参考。具体如下&#xff1a; 这里用css和jquery实现鼠标移…

精通java益处_你真的精通Java吗?

简历和自我介绍上经常能够读到“精通Java”这样的话&#xff0c;有人和我说&#xff0c;精通Java的人太多了&#xff0c;精通Java已经不能算亮点、不能给自己加分了。可是事实真是这样吗&#xff1f;对于语言的学习&#xff0c;我有一种观点&#xff0c;一是纵向&#xff0c;即…

Luogu P2101 命运石之门的选择(分治+搜索)

P2101 命运石之门的选择 题意 题目描述 在某一条不知名世界线的冈伦今天突然接到了一条\(dmail\)&#xff0c;上面说世界线将会发生巨大变动&#xff0c;未来的他无论如何都无法扭转这种变动回到原来的世界线。而世界线变动的原因是现在的他不久后错过了与助手的约会。他约好要…

Java初级笔记-第五章

第五章 面向对象的特点 5.1 继承 面向对象的重要特点之一就是继承。类的继承使得能够在已有的类的基础上构造新的类&#xff0c;新类除了具有被继承类的属性和方法外&#xff0c;还可以根据需要添加新的属性和方法。继承有利于代码的复用&#xff0c;通过继承可以更有效地组织程…

取模运算性质_求余、取模运算在RTOS中计算优先级的理解

uCOS3中的部分源码&#xff1a;/* 置位优先级表中相应的位 */void OS_PrioInsert (OS_PRIO prio){CPU_DATA bit;CPU_DATA bit_nbr;OS_PRIO ix;/* 求模操作&#xff0c;获取优先级表数组的下标索引 */ix prio / DEF_INT_CPU_NBR_BITS;//32bits//由于数据均为无符号数,prio为8位…

归结原则_被聘为自由职业者归结为一件事:信任。

归结原则by I quit Medium我退出Medium 被聘为自由职业者归结为一件事&#xff1a;信任。 (Getting hired as a freelancer comes down to one thing: trust.) When I ask freelancers what they think is the most important factor in landing a client project, they usual…

关于JS的传递方式的小理解

var test function() {//将其看成是创建了一个对象alert(1);}var otherTest test;//赋值导致test和otherTest指向同一个对象otherTest();test.sd 9;//对对象进行操作&#xff0c;两者都发生改变alert(otherTest.sd);//9var test function() {//test重新创建了一个对象&…

java p代表哪种数据类型_java数据类型(八种基本数据类型+三种引用类型)

1、整型类型 占用字节 取值范围byte 1 -128~127 (7次方)short 2 -32 768~32 767 (15次方)int …

python中的随机函数

python--随机函数&#xff08;random,uniform,randint,randrange,shuffle,sample&#xff09; 本文转载自:[chamie] random() random()方法&#xff1a;返回随机生成的一个实数&#xff0c;它在[0,1)范围内 运用random()方法的语法&#xff1a; import random #random()方法不…

Setuptool+pip安装

https://pypi.python.org/pypi/setuptools 1. 下载ez_setup.py文件&#xff0c;cmd进入安装目录&#xff1b; 2. python setup.py install https://pip.pypa.io/en/latest/index.html 1、cmd进入ez_setup.py文件目录2、用setuptools安装&#xff1a;easy_install pip转载于:htt…

rss 阅读源_如何使用RSS更有效地阅读

rss 阅读源by Naman Kamra通过纳曼卡姆拉(Naman Kamra) 如何使用RSS更有效地阅读 (How to read more efficiently with RSS) Rich Site Summary (RSS) was developed way back in 1999 as a way to quickly subscribe to blogs and newspapers, back before tools like Twitte…

python 遍历usb设备_python程序员教你写脚本玩微信跳一跳,只要有耐心,你就是王者!...

温馨提示&#xff1a;微信已经开始检测分数异常高的情况了&#xff0c;请大家不要跑太高哦游戏模式这是一个 2.5D 插画风格的益智游戏&#xff0c;玩家可以通过按压屏幕时间的长短来控制这个「小人」跳跃的距离。可能刚开始上手的时候&#xff0c;因为时间距离之间的关系把握不…

一个电脑同时运行 64bit 和 32bit 的eclipse 如何匹配 jdk环境

一个电脑同时运行 64bit 和 32bit 的 eclipse 如何匹配 jdk环境 1 eclipse 分 64bit 和 32bit 两种. 64bit的eclipse 只能搭配 64bit的 jdk 使用. 32bit的eclipse 只能搭配 32bit的 jdk 使用. 2 电脑上安装好 32bit 和 64bit 的 jdk ,分别安装在不同的路径中. 比如我的3…