《日子》mesos集群安装

“Mesos是Apache下的开源分布式资源管理框架,它被称为是分布式系统的内核。Mesos最初是由加州大学伯克利分校的AMPLab开发的,后在Twitter得到广泛使用”------百度百科。

一、出现背景

随着互联网的发展,各种大数据计算框架不断出现,支持离线处理的MapReduce、在线处理的Storm,迭代计算框架Spark、及流式处理框架S4……各种分布式计算框架应运而生,各自解决某一类应用中的问题。而在互联网公司中,几种不同的框架都可能会被采用。考虑到资源的利用率、运维成本、数据共享等因素,我们往往会把不同的计算框架部署到一个公共的集群中,使其共享集群资源,而不同任务往往需要的资源(CPU、内存、网络I/O等)不同,它们运行在同一个集群中不免会相互干扰、资源竞争导致效率低下,因此就诞生了资源统一管理与调度平台,两个典型代表---Mesos和Yarn
</div>

二、Mesos框架

Mesos Architecture

Mesos Architecture

The above figure shows the main components of Mesos. Mesos consists of a master daemon that manages agent daemons running on each cluster node, and Mesos frameworks that run tasks on these agents.

The master enables fine-grained sharing of resources (CPU, RAM, …) across frameworks by making them resource offers. Each resource offer contains a list of <agent ID, resource1: amount1, resource2: amount2, ...>
(NOTE: as keyword ‘slave’ is deprecated in favor of ‘agent’, driver-based frameworks will still receive offers with slave ID, whereas frameworks using the v1 HTTP API receive offers with agent ID). The master decides how many resources to offer to each framework according to a given organizational policy, such as fair sharing or strict priority. To support a diverse set of policies, the master employs a modular architecture that makes it easy to add new allocation modules via a plugin mechanism.

A framework running on top of Mesos consists of two components: a scheduler that registers with the master to be offered resources, and an executor process that is launched on agent nodes to run the framework’s tasks (see the App/Framework development guide for more details about framework schedulers and executors). While the master determines how many resources are offered to each framework, the frameworks' schedulers select which of the offered resources to use. When a framework accepts offered resources, it passes to Mesos a description of the tasks it wants to run on them. In turn, Mesos launches the tasks on the corresponding agents.

Example of resource offer

The figure below shows an example of how a framework gets scheduled to run a task.


Mesos Architecture

Let’s walk through the events in the figure.
1.Agent 1 reports to the master that it has 4 CPUs and 4 GB of memory free.

2. The master then invokes the allocation policy module, which tells it that framework 1 should be offered all available resources.The master sends a resource offer describing what is available on agent 1 to framework 1.

3.The framework’s scheduler replies to the master with information about two tasks to run on the agent, using <2 CPUs, 1 GB RAM> for the first task, and <1 CPUs, 2 GB RAM> for the second task.

4.Finally, the master sends the tasks to the agent, which allocates appropriate resources to the framework’s executor, which in turn launches the two tasks (depicted with dotted-line borders in the figure). Because 1 CPU and 1 GB of RAM are still unallocated, the allocation module may now offer them to framework 2.

In addition, this resource offer process repeats when tasks finish and new resources become free.

While the thin interface provided by Mesos allows it to scale and allows the frameworks to evolve independently, one question remains: how can the constraints of a framework be satisfied without Mesos knowing about these constraints? For example, how can a framework achieve data locality without Mesos knowing which nodes store the data required by the framework? Mesos answers these questions by simply giving frameworks the ability to reject offers. A framework will reject the offers that do not satisfy its constraints and accept the ones that do. In particular, we have found that a simple policy called delay scheduling, in which frameworks wait for a limited time to acquire nodes storing the input data, yields nearly optimal data locality.

以上部分摘自mesos官网,用于初学者对mesos理解

正式安装

一、机器及系统准备

机器准备3台 Ubuntu 16.04
分配IP:192.168.0.124,192.168.0.125,192.168.0.126

参照mesos官方配置

Ubuntu 16.04
Following are the instructions for stock Ubuntu 16.04. If you are using a different OS, please install the packages accordingly.

<code>
# Update the packages.
$ sudo apt-get update

# Install a few utility tools.
$ sudo apt-get install -y tar wget git

# Install the latest OpenJDK.
$ sudo apt-get install -y openjdk-8-jdk

# Install autotools (Only necessary if building from git repository).
$ sudo apt-get install -y autoconf libtool

# Install other Mesos dependencies.
$ sudo apt-get -y install build-essential python-dev libcurl4-nss-dev libsasl2-dev libsasl2-modules maven libapr1-dev libsvn-dev zlib1g-dev
</code>

二、环境及安装

<1>mesos源码安装包
<2> oracle jdk-1.8.0_171(安装略过请参考unbunt基础配置中jdk安装部分)

  1. Download the latest stable release from Apache (Recommended)
    <code>
    $ wget http://www.apache.org/dist/mesos/1.2.0/mesos-1.2.0.tar.gz
    $ tar -zxf mesos-1.2.0.tar.gz
    $ cd mesos-1.2.0
    $ mkdir -p /usr/local/mesos/mesos
    $./configure --prefix=/usr/local/mesos/mesos
    $make -j4 && make -j4 install
    </code>
  2. Clone the Mesos git repository (Advanced Users Only)
    <code>
    $ git clone https://git-wip-us.apache.org/repos/asf/mesos.git
    </code>

Building Mesos (Posix)
<code>
# Change working directory.
$ cd mesos

# Bootstrap (Only required if building from git repository).
$ ./bootstrap

# Configure and build.
$ mkdir build
$ cd build
$ ../configure
$ make
In order to speed up the build and reduce verbosity of the logs, you can append -j <number of cores> V=0 to make.

# Run test suite.
$ make check

# Install (Optional).
$ make install
</code>

make 过程中出现错误:

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,

解决办法:

主要原因大体上是因为内存不足,有点坑 临时使用交换分区来解决吧

sudo dd if=/dev/zero of=/swapfile bs=64M count=16
sudo mkswap /swapfile
sudo swapon /swapfile

After compiling, you may wish to

Code:
sudo swapoff /swapfile
sudo rm /swapfile

重复以上步骤安装完三台机

安装zookeeper并启动

三、配置并启动

./mesos-master.sh --ip=192.168.0.126 --work_dir=/tmp/mesos --zk=zk://192.168.0.126:2181,192.168.0.125:2181,192.168.0.124:2181/mesos --quorum=1

./mesos-master.sh --ip=192.168.15.125 --work_dir=/tmp/mesos --zk=zk://192.168.15.126:2181,192.168.15.125:2181,192.168.12.124:2181/mesos --quorum=1

./mesos-master.sh --ip=192.168.15.124 --work_dir=/tmp/mesos --zk=zk://192.168.15.126:2181,192.168.15.125:2181,192.168.12.124:2181/mesos --quorum=1

./mesos-agent.sh --master=192.168.15.126:5050 --work_dir=/tem_mesos (125,124 slave机器上启动,注意 加--port)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,036评论 6 506
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,046评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,411评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,622评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,661评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,521评论 1 304
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,288评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,200评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,644评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,837评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,953评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,673评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,281评论 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,889评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,011评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,119评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,901评论 2 355

推荐阅读更多精彩内容