神刀安全网

单节点mesos + marathon + zookeeper

1,环境:ubuntu:15.10 (由于apt-get的源只支持15.04,所以今天只采用源码安装)

节点ip : 192.168.1.108

2, 安装第三方包

apt-get install -y autoconf libtool build-essential python-dev python-boto libcurl4-nss-dev libsasl2-dev libsasl2-modules maven libapr1-dev libsvn-dev

3,安装mesos:

wget http://mirror.bit.edu.cn/apach … ar.gz

或者 git clone https://github.com/apache/mesos.git (0.29版本)

安装

# tar -xvf mesos-0.28.0.tar.gz && mv mesos-0.28.0 mesos

# mkdir build

# ./bootstrap

# ../configure

# make (机子性能不太好,半个多小时编译完)

# make install

4, 修改配置文件

修改/etc/hosts 添加hostname ip至最后(本环境是:192.168.1.108 zjx)

mesos默认编译完之后会在/usr/etc/mesos 生成三个配置文件 mesos-deploy-env.sh.template mesos-master-env.sh.template mesos-slave-env.sh.template

# cp mesos-deploy-env.sh mesos-deploy-env.sh.template

# cp mesos-master-env.sh mesos-master-env.sh.template

# cp mesos-slave-env.sh mesos-slave-env.sh.template

下面是我写的参数:

depoly 参数比较简单,按照默认的就好

root@zjx:/usr/etc/mesos# cat mesos-deploy-env.sh

#!/usr/bin/env bash

# This file contains environment variables that modify how the deploy

# scripts are run. For example, it can be used to configure SSH

# options (see below).

# Options for SSH.

export SSH_OPTS="-o StrictHostKeyChecking=no -o ConnectTimeout=2"

# Use sudo for launching masters and slaves.

export DEPLOY_WITH_SUDO=1

mesos master 的参数可以跟mesos-master –help 来进行添加:

root@zjx:/usr/etc/mesos# cat mesos-master-env.sh

# This file contains environment variables that are passed to mesos-master.

# To get a description of all options run mesos-master –help; any option

# supported as a command-line option is also supported as an environment

# variable.

# Some options you’re likely to want to set:

export MESOS_log_dir=/var/log/mesos

export MESOS_hostname=zjx

export MESOS_cluster=zjx

export MESOS_ip=192.168.1.108

export MESOS_work_dir=/var/run/mesos

export MESOS_zk=zk://192.168.1.108:2181/mesos (不使用zookeeper的话,使用ip:5050)

#由于只有一台机器,quorum只能写1,写2,会导致master因core dump无法启动

export MESOS_quorum=1

mesos slave 参数,同样也可以根据mesos-slave –help 来进行设置,如下我只是简单添加了zk:

root@zjx:/usr/etc/mesos# cat mesos-slave-env.sh

# This file contains environment variables that are passed to mesos-slave.

# To get a description of all options run mesos-slave –help; any option

# supported as a command-line option is also supported as an environment

# variable.

# You must at least set MESOS_master.

# The mesos master URL to contact. Should be host:port for

# non-ZooKeeper based masters, otherwise a zk:// or file:// URL.

export MESOS_master=zk://192.168.1.108:2181/mesos (如果不使用zookeeper,写为:export MESOS_master=192.168.1.108:5050)

# Other options you’re likely to want to set:

export MESOS_log_dir=/var/log/mesos

export MESOS_work_dir=/var/run/mesos

export MESOS_isolation=cgroups

创建masters,slaves文件,并写入主机名:

root@zjx:/usr/etc/mesos# echo zjx |tee masters

zjx

root@zjx:/usr/etc/mesos# echo zjx |tee slaves

zjx

root@zjx:/usr/etc/mesos#

至此,mesos的配置已经完成,如果不使用zookeeper,使用命令mesos-start-cluser.sh就可以启动集群

5,安装配置zookeeper:

apt-get install -y zookeeper zookeeperd

修改如下几个配置文件:

# echo 1 |tee /etc/zookeeper/conf/myid

修改/etc/zookeeper/conf/zoo.cfg

更换server.1=192.168.1.108:2888:3888 中的ip为自己的ip(初始为:server.1=1.1.1.1:2888:3888)

其他的参数,可以根据需要自己打开

6,安装配置marathon:

# curl -O http://downloads.mesosphere.co … 1.tgz

# tar xzf marathon-1.1.0-RC1.tgz

7, 启动zookeeper,mesos,marathon

启动zookeeper 服务

root@zjx:~/mesos# service zookeeper start

root@zjx:~/mesos# service zookeeper status

鈼[0m zookeeper.service – LSB: centralized coordination service

Loaded: loaded (/etc/init.d/zookeeper)

Active: active (running) since Sat 2016-04-16 12:05:58 CST; 5s ago

启动mesos单节点集群:

root@zjx:~/mesos# mesos-start-cluster.sh

Starting mesos-master on zjx

ssh -o StrictHostKeyChecking=no -o ConnectTimeout=2 zjx sudo /usr/sbin/mesos-daemon.sh mesos-master </dev/null >/dev/null

Starting mesos-slave on zjx

ssh -o StrictHostKeyChecking=no -o ConnectTimeout=2 zjx sudo /usr/sbin/mesos-daemon.sh mesos-slave </dev/null >/dev/null

Everything’s started!

root@zjx:~/mesos# ps -ef|grep mesos

root 32564 1 2 12:04 ? 00:00:00 /usr/sbin/mesos-master

root 32629 1 9 12:04 ? 00:00:00 /usr/sbin/mesos-slave

root 32646 3325 0 12:05 pts/8 00:00:00 grep –color=auto mesos

root@zjx:/var/log# netstat -nlp |grep 5050

tcp 0 0 192.168.1.108:5050 0.0.0.0:* LISTEN 436/mesos-master

向mesos注册marathon框架:

root@zjx:~/marathon/marathon-1.1.0-RC1# ./bin/start –master zk://192.168.1.108:2181/mesos –zk zk://192.168.1.108:2181/marathon >log

root@zjx:~/marathon/marathon-1.1.0-RC1# ./bin/start –master zk://192.168.1.108:2181/mesos –zk zk://192.168.1.108:2181/marathon >log

I0416 12:13:24.683187 641 sched.cpp:222] Version: 0.28.0

2016-04-16 12:13:24,684:580(0x7f63e4c59700):ZOO_INFO@log_env@712: Client environment:zookeeper.version=zookeeper C client 3.4.5

2016-04-16 12:13:24,685:580(0x7f63e4c59700):ZOO_INFO@log_env@716: Client environment:host.name=zjx

2016-04-16 12:13:24,685:580(0x7f63e4c59700):ZOO_INFO@log_env@723: Client environment:os.name=Linux

2016-04-16 12:13:24,685:580(0x7f63e4c59700):ZOO_INFO@log_env@724: Client environment:os.arch=4.2.0-30-generic

2016-04-16 12:13:24,685:580(0x7f63e4c59700):ZOO_INFO@log_env@725: Client environment:os.version=#36-Ubuntu SMP Fri Feb 26 00:58:07 UTC 2016

2016-04-16 12:13:24,685:580(0x7f63e4c59700):ZOO_INFO@log_env@733: Client environment:user.name=zjx

2016-04-16 12:13:24,685:580(0x7f63e4c59700):ZOO_INFO@log_env@741: Client environment:user.home=/root

2016-04-16 12:13:24,685:580(0x7f63e4c59700):ZOO_INFO@log_env@753: Client environment:user.dir=/home/zjx/marathon/marathon-1.1.0-RC1

2016-04-16 12:13:24,685:580(0x7f63e4c59700):ZOO_INFO@zookeeper_init@786: Initiating client connection, host=192.168.1.108:2181 sessionTimeout=10000 watcher=0x7f63f2d54fa0 sessionId=0 sessionPasswd=<null> context=0x7f644c009c28 flags=0

2016-04-16 12:13:24,704:580(0x7f63e3456700):ZOO_INFO@check_events@1703: initiated connection to server [192.168.1.108:2181]

2016-04-16 12:13:24,714:580(0x7f63e3456700):ZOO_INFO@check_events@1750: session establishment complete on server [192.168.1.108:2181], sessionId=0x1541d3f27be0007, negotiated timeout=10000

I0416 12:13:24.715201 664 group.cpp:349] Group process (group(1)@127.0.1.1:33472) connected to ZooKeeper

I0416 12:13:24.715288 664 group.cpp:831] Syncing group operations: queue size (joins, cancels, datas) = (0, 0, 0)

I0416 12:13:24.715335 664 group.cpp:427] Trying to create path ‘/mesos’ in ZooKeeper

I0416 12:13:24.718236 664 detector.cpp:152] Detected a new leader: (id=’6′)

I0416 12:13:24.718578 664 group.cpp:700] Trying to get ‘/mesos/json.info_0000000006’ in ZooKeeper

I0416 12:13:24.719388 664 detector.cpp:479] A new leading master (UPID=master@192.168.1.108:5050) is detected

I0416 12:13:24.719570 664 sched.cpp:326] New master detected at master@192.168.1.108:5050

I0416 12:13:24.720021 664 sched.cpp:336] No credentials provided. Attempting to register without authentication

I0416 12:13:24.722645 652 sched.cpp:703] Framework registered with 8d8a7f02-c28a-4162-819f-36fb5abe0aee-0000

至此marathon已经成功注册,framework id为8d8a7f02-c28a-4162-819f-36fb5abe0aee-0000

同时也可以从mesos-master 的日志中看到marathon注册的信息:

I0416 12:13:24.720573 437 master.cpp:2231] Received SUBSCRIBE call for framework ‘marathon’ at scheduler-54d237dd-325b-4fda-95ea-310c162f7d43@127.0.1.1:33472

I0416 12:13:24.720669 437 master.cpp:2302] Subscribing framework marathon with checkpointing enabled and capabilities [ ]

I0416 12:13:24.721089 437 hierarchical.cpp:265] Added framework 8d8a7f02-c28a-4162-819f-36fb5abe0aee-0000

I0416 12:13:24.721387 437 master.cpp:5324] Sending 1 offers to framework 8d8a7f02-c28a-4162-819f-36fb5abe0aee-0000 (marathon) at scheduler-54d237dd-325b-4fda-95ea-310c162f7d43@127.0.1.1:33472

I0416 12:13:24.722695 437 master.cpp:4763] Status update TASK_FINISHED (UUID: d74fa63d-51e9-49c2-82f5-9a59e83ba67c) for task test.e82a24ff-037d-11e6-9ff6-ce578d904a3e of framework 8d8a7f02-c28a-4162-819f-36fb5abe0aee-0000 from slave c33427e7-1f5f-425a-9f7f-0b9c3502d243-S0 at slave(1)@127.0.1.1:5051 (zjx)

现在就可以登陆浏览器进行任务测试了。mesos: ip:5050 marathon: ip:8080

a3721659a@hotmail.com , 欢迎一起交流学习成长

ZJX

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » 单节点mesos + marathon + zookeeper

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮