Docker系列之(二):使用Mesos管理Docker集群(Mesos + Marathon + Chronos + Docker)

來自: http://www.cnblogs.com/ee900222/p/docker_2.html

1. Mesos簡介

1.1 Mesos

Apache Mesos 是一個分布式系統的管理軟件,對集群的資源進行分配和管理。

Mesos主要由以下幾部分組成:

Master: 管理各Slave節點

Slave: 為集群提供資源

Framework: scheduler從Master請求資源,executor在Slave上執行任務

Slave節點上的每個executor是一個容器

官方文檔:

http://mesos.apache.org/documentation/latest/architecture/

http://mesos.apache.org/documentation/latest/getting-started/

Mesos主服務器使用Zookeeper進行服務選舉和發現。它有一個注冊器記錄了所有運行任何和從服務器信息,使用MultiPaxos進行日志復制實現一致性。

Mesos有一個從服務器恢復機制,無論什么時候一個從服務器死機了,用戶的任務還是能夠繼續運行,從服務器會將一些關鍵點信息如任務信息 狀態更新持久化到本地磁盤上,重新啟動時可以從磁盤上恢復運行這些任務(類似Java中的鈍化和喚醒)

1.2 Marathon

Marathon 是Mesos的一個Framework,用來執行需要長時間運行的任務。如果把Mesos比喻成Kernel的話,那么Marathon就是它的守護進程Daemon。

它還具備HA,Health Checks,服務發現等功能。如果某個Docker進程崩潰,Marathon會重新啟動同樣的進程。

1.3 Chronos

Chronos本質上是cron-on-mesos,這是一個用來運行基于容器定時任務的Mesos框架。

1.4 ZooKeeper

ZooKeeper用于集群的管理,包括統一配置管理,選舉Leader等。

2. 安裝Mesos

本次測試環境的構成如下:

Mesos Master: test166

Mesos Slave:  test166,test167

Marathon:  test166

Chronos:  test166

ZooKeeper:  test166

2.1 安裝準備

在所有機器上,安裝Mesos源

# rpm -Uvh http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm

在所有機器的/etc/hosts中,指定主機名

# vi /etc/hosts
10.86.255.166  test166
10.86.255.167  test167

2.2 安裝Master

2.2.1 在Master上安裝Mesos,Marathon,Chronos,ZooKeeper

# yum install mesos marathon chronos mesosphere-zookeeper

如果服務器上之前裝過jdk,升級到最新版本

2.2.2 ZooKeeper設定

本次配置的Master是單節點環境,ZooKeeper也是單點

# vi /etc/mesos/zk
zk://test166:2181/mesos

2.2.3 啟動服務

# systemctl start zookeeper

systemctl start mesos-master

systemctl start marathon

systemctl start chronos</pre>

2.3 安裝Slave

2.3.1 在Slave上安裝Mesos,Docker

# yum install mesos docker

2.3.2 Docker相關設定

# echo 'docker,mesos' > /etc/mesos-slave/containerizers

echo '5mins' > /etc/mesos-slave/executor_registration_timeout</pre>

2.3.3 ZooKeeper設定

# vi /etc/mesos/zk
zk://test166:2181/mesos

2.3.4 啟動服務

# systemctl start docker

systemctl start mesos-slave</pre>

2.4 確認

Mesos的頁面

http://10.86.255.166:5050 /

Marathon的頁面

http://10.86.255.166:8080/

Chronos的頁面

http://10.86.255.166:4400/

</div>

 本文由用戶 KindraLefeb 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!