如何搭建拥有服务发现能力的Mesosphere集群环境

云计算
有鉴于Docker集群技术如雨后春笋般不停涌现,我来分享我自己在探索Mesosphere上的经验和结果,我将告诉读者如何在CentOS 7上基于Mesosphere搭建拥有服务发现能力的Docker集群。

有鉴于Docker集群技术如雨后春笋般不停涌现,我来分享我自己在探索Mesosphere上的经验和结果,我将告诉读者如何在CentOS 7上基于Mesosphere搭建拥有服务发现能力的Docker集群。

我GitHub项目上的说明:https://github.com/draculavlad/SetUpMesosphereOnCentos7WithServiceDiscovery

本人语死早,请谅解我的语言组织能力

搭建环境

CentOS 7

系统初始化

  1. yum update -y 
  2. yum install bash curl wget tar zip unzip bzip2 telnet net-tools git -y 
  3. yum groupinstall "Development Tools" –y 
  4. yum -y install ntp ntpdate 
  5. systemctl start ntpd 

如果需要的话关闭防火墙。

 

  1. setenforce Permissive 
  2. systemctl stop firewalld 
  3. systemctl disable firewalld 

 

添加yum源。

 

  1. rpm -Uvh 'http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm' 
  2. rpm -Uvh 'http://archive.cloudera.com/cdh4/one-click-install/redhat/6/x86_64/cloudera-c 

 

安装

 

  1. yum -y install mesos marathon mesosphere-zookeeper 

启动haproxy

haproxy只有master节点才需要

 

  1. yum -y install haproxy && systemctl start haproxy 

安装启动docker

 

  1. rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 
  2. yum install -y docker 

 

预初始化

 

  1. systemctl disable mesos-master 
  2. systemctl disable mesos-slave 
  3. systemctl disable marathon 
  4. systemctl disable zookeeper 

 

ZooKeeper 配置和启动

只有master 节点需要如此操作。

设置文件[/var/lib/zookeeper/myid]为当前mesos master节点的id,id必须为1-255之中的整数,例如:1

添加所有的mesos master节点信息到文件[/etc/zookeeper/conf/zoo.cf],例如:

master_node_id为master节点id同该节点[/var/lib/zookeeper/myid]文件的配置,master_node_ip为master节点的ip地址:

 

  1. server.$master_node_id=$master_node_ip:2888:3888 

启动ZooKeeper:

 

  1. systemctl start zookeeper 

#p#

Mesos 配置和启动

master和slave节点都需要如此设置。添加所有的master节点到文件[/etc/mesos/zk],例如:

 

  1. zk://$first_master_node_ip:2181,$second_master_node_ip:2181,.../mesos 

Mesos master 和 marathon的配置和启动

只有master节点需要如此配置,marathon节点与master节点不同,目前我是把marathon安装在master节点。

设置文件[/etc/mesos-master/quorum]内容为一个大于master节点数除以2的整数。

设置文件[/etc/mesos-master/ip]内容为当前master节点的ip

设置文件[/etc/mesos-master/hostname]内容为当前master节点的域名(必须可被其他节点解析)

 

  1. mkdir -p /etc/marathon/conf 
  2. cp /etc/mesos/zk /etc/marathon/conf/master 
  3. cp /etc/marathon/conf/master /etc/marathon/conf/zk 
  4. sed –i 's|mesos|marathon|g' /etc/marathon/conf/zk 

 

添加Mesosphere的服务发现功能

安装在master节点。因为官方推荐的脚本和Haproxy1.5不兼容所以请使用我的脚本

 

  1. wget 'https://github.com/draculavlad/SetUpMesosphereOnCentos7/blob/master/haproxy-marathon- 

设置文件[/etc/haproxy-marathon-bridge/marathons]:

 

  1. echo "$first_marathon_node_ip:8080" >> /etc/haproxy-marathon-bridge/marathons 
  2. echo "$second_marathon_node_ip:8080" >> /etc/haproxy-marathon-bridge/marathons 
  3. echo "$third_marathon_node_ip:8080" >> /etc/haproxy-marathon-bridge/marathons 

 

执行安装脚本:

 

  1. chmod +x haproxy-marathon-bridge 
  2. ./haproxy-marathon-bridge install_cronjob 

 

启动mesos master和marathon服务

 

  1. systemctl start mesos-master 
  2. systemctl start marathon 

 

mesos slave 节点配置和启动

设置文件[/etc/mesos-slave/ip]内容为当前slave节点的ip地址

设置文件[/etc/mesos-slave/hostname]内容为当前slave节点的域名(必须可被其他节点解析)

使slave节点支持Docker:

 

  1. echo 'docker,mesos' > /etc/mesos-slave/containerizers 
  2. echo '5mins' > /etc/mesos-slave/executor_registration_timeout 

 

启动mesos slave:

 

  1. systemctl start mesos-slave 

测试脚本

测试脚本来自于我参考的youtube视频

 

  1. wget 'https://github.com/draculavlad/SetUpMesosphereOnCentos7WithServiceDiscovery/blob/master/launch.sh' 
  2. wget 'https://github.com/draculavlad/SetUpMesosphereOnCentos7WithServiceDiscovery/blob/master/nginx-bridge.json' 
  3. export marathon_node_ip=$your_marathon_node_ip 
  4. chmod +x launch.sh 
  5. ./launch.sh nginx-bridge.json 

原文链接:http://dockone.io/article/439
 

责任编辑:Ophira 来源: dockerone
相关推荐

2021-01-07 10:18:03

Redis数据库环境搭建

2017-10-19 16:12:57

2015-10-26 10:14:13

Android开发环境robolectric

2012-11-01 17:15:04

2015-03-19 11:30:04

DockerDocker集群服务发现

2019-09-18 16:52:58

hyperf微服务php

2010-02-03 14:37:10

Python 开发环境

2022-02-11 08:41:19

WindowsRedis集群

2019-12-24 09:39:06

Kubernetes工具微服务

2010-06-04 18:17:50

Hadoop集群

2018-06-13 14:42:53

集群虚拟化搭建

2017-01-05 13:34:42

LinuxUbuntu邮件服务器

2011-08-29 15:23:11

Ubuntuapache

2017-01-09 08:59:17

Ubuntu邮件服务器

2016-12-29 10:52:09

LinuxUbuntu邮件服务器

2010-10-19 09:35:08

Ubuntu 10.1云环境

2011-01-28 15:02:13

沃森人机大战

2020-03-23 22:50:36

WindowsNginxTomcat

2010-01-08 17:13:46

Visual C++环

2020-12-14 12:48:51

Kafka集群节点
点赞
收藏

51CTO技术栈公众号