Posted at
MesosDay 13

minimesosでMesosる

More than 1 year has passed since last update.

この記事は、Mesos Advent Calendar 2017 13日目の記事です。


概要

ローカル環境でKubernetesを試すminikubeの紹介記事はよく見るが、ローカル環境でMesosを試すminimesosの話をあまり見ないので紹介してみる。


minimesosとは

ローカルでApache Mesosを試すためのツール。

DockerコンテナでMesosプロセスを実行して構築しています。


環境

PC : MacBookPro

OS : macOS Sierra(Version 10.12.6)

Docker : 17.09.1-ce

$docker version

Client:
Version: 17.09.1-ce
API version: 1.32
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:22:25 2017
OS/Arch: darwin/amd64

Server:
Version: 17.09.1-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:28:28 2017
OS/Arch: linux/amd64
Experimental: true


minimesosのインストール

$curl -sSL https://minimesos.org/install | sh


minimesos起動

$minimesos init

Initialized minimesosFile in this directory

$minimesos up
Detected Mac Environment X, running with '--mapPortsToHost' so master and marathon ports are mapped to localhost
Detected Mac Environment X so running with --mapPortsToHost so master and marathon ports are mapped to localhost.
Minimesos cluster is running: 2178808731
Mesos version: 1.0.0
export MINIMESOS_NETWORK_GATEWAY=172.17.0.1
export MINIMESOS_AGENT=http://172.17.0.6:5051; export MINIMESOS_AGENT_IP=172.17.0.6
export MINIMESOS_ZOOKEEPER=zk://172.17.0.3:2181/mesos; export MINIMESOS_ZOOKEEPER_IP=172.17.0.3
export MINIMESOS_MARATHON=http://172.17.0.5:8080; export MINIMESOS_MARATHON_IP=172.17.0.5
export MINIMESOS_CONSUL=http://172.17.0.7:8500; export MINIMESOS_CONSUL_IP=172.17.0.7
export MINIMESOS_MASTER=http://172.17.0.4:5050; export MINIMESOS_MASTER_IP=172.17.0.4
You are running Docker on Mac so use localhost instead of container IPs for Master, Marathon, Zookeepr and Consul

起動できたっぽい。立ち上がってるコンテナを確認してみる。

$docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
99a5237a0595 weaveworks/scope:0.13.1 "/home/weave/entry..." 18 minutes ago Up 18 minutes mesos-8473ee67-54a5-42d8-a429-db620ba6634c-S0.c3d26fe9-93a5-4a31-8f37-a9ca8096d1f6
fc0aa08949da gliderlabs/registrator:v6 "/bin/registrator ..." 19 minutes ago Up 19 minutes minimesos-registrator-1410255284-1881417418
1b4eb71e3d8d consul:0.7.1 "docker-entrypoint..." 19 minutes ago Up 19 minutes 8300-8302/tcp, 8400/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp minimesos-consul-1410255284-3254448349
fdf3d3d0dbf7 containersol/mesos-agent:1.0.0-0.1.0 "mesos-slave --no-..." 19 minutes ago Up 19 minutes 5051/tcp, 31000-32000/tcp minimesos-agent-1410255284-31841581
b72d7c39184f mesosphere/marathon:v1.3.5 "./bin/start --mas..." 19 minutes ago Up 19 minutes 0.0.0.0:8080->8080/tcp minimesos-marathon-1410255284-1693853479
89c152fd4f58 containersol/mesos-master:1.0.0-0.1.0 "mesos-master --no..." 20 minutes ago Up 20 minutes 0.0.0.0:5050->5050/tcp minimesos-master-1410255284-2893467418
5d0348c20954 jplock/zookeeper:3.4.6 "/opt/zookeeper/bi..." 21 minutes ago Up 21 minutes 2181/tcp, 2888/tcp, 3888/tcp

なんかいっぱい立ち上がってる...

Mesos Masterが1台とSlaveが1台立ち上がってるみたい。

ステータスを確認してみる。

$curl http://localhost:5050/state.json

{"version":"1.0.0","git_sha":"c9b70582e9fccab8f6863b0bd3a812b5969a8c24","git_tag":"1.0.0","build_date":"2016-07-27 20:23:20","build_time":1469651000.0,"build_user":"ubuntu","start_time":1513148480.24348,"elected_time":1513148480.29761,"id":"a0a67bd6-aec9-48be-897c-b2363300c39a","pid":"master@172.17.0.4:5050","hostname":"172.17.0.4","activated_slaves":1.0,"deactivated_slaves":0.0,"leader":"master@172.17.0.4:5050","cluster":"Change Cluster Name in minimesosFile file","log_dir":"\/var\/log","flags":{"agent_ping_timeout":"15secs","agent_reregister_timeout":"10mins","allocation_interval":"1secs","allocator":"HierarchicalDRF","authenticate_agents":"false","authenticate_frameworks":"false","authenticate_http_frameworks":"false","authenticate_http_readonly":"false","authenticate_http_readwrite":"false","authenticators":"crammd5","authorizers":"local","cluster":"Change Cluster Name in minimesosFile file","framework_sorter":"drf","help":"false","hostname_lookup":"false","http_authenticators":"basic","initialize_driver_logging":"true","log_auto_initialize":"true","log_dir":"\/var\/log","logbufsecs":"0","logging_level":"INFO","max_agent_ping_timeouts":"5","max_completed_frameworks":"50","max_completed_tasks_per_framework":"1000","port":"5050","quiet":"false","quorum":"1","recovery_agent_removal_limit":"100%","registry":"in_memory","registry_fetch_timeout":"1mins","registry_store_timeout":"20secs","registry_strict":"false","root_submissions":"true","user_sorter":"drf","version":"false","webui_dir":"\/usr\/share\/mesos\/webui","zk":"zk:\/\/172.17.0.3:2181\/mesos","zk_session_timeout":"10secs"},"slaves":[{"id":"a0a67bd6-aec9-48be-897c-b2363300c39a-S0","pid":"slave(1)@172.17.0.6:5051","hostname":"172.17.0.6","registered_time":1513148561.60812,"resources":{"disk":2000.0,"mem":1024.0,"gpus":0.0,"cpus":4.0,"ports":"[31000-32000]"},"used_resources":{"disk":0.0,"mem":128.0,"gpus":0.0,"cpus":1.0,"ports":"[31130-31130]"},"offered_resources":{"disk":0.0,"mem":0.0,"gpus":0.0,"cpus":0.0},"reserved_resources":{},"unreserved_resources":{"disk":2000.0,"mem":1024.0,"gpus":0.0,"cpus":4.0,"ports":"[31000-32000]"},"attributes":{},"active":true,"version":"1.0.0"}],"frameworks":[{"id":"a0a67bd6-aec9-48be-897c-b2363300c39a-0000","name":"marathon","pid":"scheduler-63798854-4059-42d9-a02f-06ce0cfd2278@172.17.0.5:34789","used_resources":{"disk":0.0,"mem":128.0,"gpus":0.0,"cpus":1.0,"ports":"[31130-31130]"},"offered_resources":{"disk":0.0,"mem":0.0,"gpus":0.0,"cpus":0.0},"capabilities":[],"hostname":"8469b61c63b8","webui_url":"http:\/\/8469b61c63b8:8080","active":true,"user":"root","failover_timeout":604800.0,"checkpoint":true,"role":"*","registered_time":1513148562.87555,"unregistered_time":0.0,"resources":{"disk":0.0,"mem":128.0,"gpus":0.0,"cpus":1.0,"ports":"[31130-31130]"},"tasks":[{"id":"weave-scope.acaf913b-dfd3-11e7-aa4a-0242ac110005","name":"weave-scope","framework_id":"a0a67bd6-aec9-48be-897c-b2363300c39a-0000","executor_id":"","slave_id":"a0a67bd6-aec9-48be-897c-b2363300c39a-S0","state":"TASK_RUNNING","resources":{"disk":0.0,"mem":128.0,"gpus":0.0,"cpus":1.0,"ports":"[31130-31130]"},"statuses":[{"state":"TASK_RUNNING","timestamp":1513148602.98276,"container_status":{"network_infos":[{"ip_addresses":[{"ip_address":"172.17.0.6"}]}]}}],"discovery":{"visibility":"FRAMEWORK","name":"weave-scope","ports":{"ports":[{"number":31130,"protocol":"tcp"}]}},"container":{"type":"DOCKER","volumes":[{"mode":"RW","container_path":"\/var\/run\/docker.sock","host_path":"\/var\/run\/docker.sock"}],"docker":{"image":"weaveworks\/scope:0.13.1","network":"HOST","privileged":true,"parameters":[{"key":"pid","value":"host"},{"key":"name","value":"weavescope"}],"force_pull_image":false}}}],"completed_tasks":[],"offers":[],"executors":[]}],"completed_frameworks":[],"orphan_tasks":[],"unregistered_frameworks":[]}

ブラウザからMesosMarathonにアクセスしてみる。


  • Mesos

    Screen Shot 2017-12-13 at 17.33.56.png


  • Marathon

    Screen Shot 2017-12-13 at 17.34.14.png


立ち上がってる!!!

今回はここまで。

実際に触るのは次回以降に乞うご期待。


終わりに

ローカル環境に簡単にMesos Clusterの構築ができた。

Mesosに興味あるけど構築とか面倒と思っている人に、気軽にローカルで構築できるのでおすすめです。


参考リンク