mesos,marthon集群部署详细步骤
程序员文章站
2022-06-17 08:47:55
...
aaa@qq.com:/mesos-docker-marathon# ls
apache-maven-3.3.9-bin.tar.gz jdk1.8 jdk-8u60-linux-x64.gz marathon marathon-1.3.5.tgz maven mesos mesos-1.0.1 mesos-1.0.1.tar.gz zkui zookeeper
安装的包,随意下载最新版本的,记得JDK1.8 和 maven
export JAVA_HOME=/mesos-docker-marathon/jdk1.8
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=/mesos-docker-marathon/maven/bin:$PATH
aaa@qq.com:/mesos-docker-marathon/marathon# cat /etc/hosts
127.0.0.1 localhost
172.16.126.131 master1 mesos-master-1
172.16.126.132 master2 mesos-master-2
172.16.126.133 master3 mesos-master-3
环境变量设置和hosts的配置
先安装好zk 和 zkui 吧 具体如何安装我这里就不写了。
先把maven装好,编译mesos的时候会用maven下载一些东西。希望你的网络是OK的,不然那是相当长的过程。
先安装mesos的依赖包,这个按照官网的来安装就行了。
配置好清华的源,不然慢的一比
aaa@qq.com:/mesos-docker-marathon# more /etc/apt/sources.list
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
maven仓库的镜像源修改下,在maven的conf目录下的settings.xml
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>
apt-get install -y autoconf libtool build-essential python-dev libcurl4-nss-dev libsasl2-dev libsasl2-modules maven libapr1-dev libsvn-dev libevent-dev python-pip libssl-dev
我记得还需要安装个什么东西,忘了,具体情况看下报错就欧了。
编译mesos
./configure --prefix=/mesos-docker-marathon/mesos
make && make install
这里不要 make check 了 太慢了
编译完成后
aaa@qq.com:/mesos-docker-marathon/mesos# ls
bin etc include lib libexec sbin share
aaa@qq.com:/mesos-docker-marathon/mesos# ls etc/mesos/
masters mesos-agent-env.sh mesos-deploy-env.sh mesos-master-env.sh mesos-slave-env.sh
aaa@qq.com:/mesos-docker-marathon/mesos# more etc/mesos/masters
172.16.126.131
172.16.126.132
172.16.126.133
aaa@qq.com:/mesos-docker-marathon/mesos# more etc/mesos/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_logging_level=INFO
export MESOS_CLUSTER=jastme
export MESOS_hostname=172.16.126.131
export MESOS_offer_timeout=60secs
export MESOS_log_dir=/var/log/mesos
export MESOS_work_dir=/var/run/mesos/master
export MESOS_ZK=zk://172.16.126.131:2181,172.16.126.132:2181,172.16.126.133:2181/mesos
export MESOS_quorum=1
以上是master的配置
启动集群(记住先做好SSH的互信)
aaa@qq.com:/mesos-docker-marathon/mesos# sh sbin/mesos-start-masters.sh
Starting mesos-master on 172.16.126.131
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=2 172.16.126.131 /mesos-docker-marathon/mesos/sbin/mesos-daemon.sh mesos-master </dev/null >/dev/null
Starting mesos-master on 172.16.126.132
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=2 172.16.126.132 /mesos-docker-marathon/mesos/sbin/mesos-daemon.sh mesos-master </dev/null >/dev/null
Starting mesos-master on 172.16.126.133
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=2 172.16.126.133 /mesos-docker-marathon/mesos/sbin/mesos-daemon.sh mesos-master </dev/null >/dev/null
5050端口已经起来了
aaa@qq.com:/mesos-docker-marathon/zookeeper# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 172.16.126.131:3888 0.0.0.0:* LISTEN 1959/java
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1061/sshd
tcp 0 0 0.0.0.0:5050 0.0.0.0:* LISTEN 1842/mesos-master
tcp 0 0 0.0.0.0:41728 0.0.0.0:* LISTEN 1959/java
tcp 0 0 172.16.126.131:2181 0.0.0.0:* LISTEN 1959/java
tcp6 0 0 :::22 :::* LISTEN 1061/sshd
再来看看zookeeper里面的信息
,集群启动成功了。看看页面
marathon 的安装就更为简单一点了。
./configure --prefix=/mesos-docker-marathon/marathon
make && make install
aaa@qq.com:/mesos-docker-marathon/marathon# more start.sh
#!/bin/bash
MESOS_NATIVE_JAVA_LIBRARY=/mesos-docker-marathon/mesos/lib/libmesos.so
nohup /mesos-docker-marathon/marathon/bin/start --master zk://172.16.126.131:2181,172.16.126.132:2181,172.16.126.133:2181/mesos --zk zk://172.16.126.131:2181,172.16.126.13
2:2181,172.16.126.133:2181/marathon &
直接脚本启动吧。然后在zkui里看看状态
看到leader是master1
嗯 有3台机器参加了选举
看看marathon如何进行工作的吧
新版的marathon比老版本的强了不少,再进行测试之前,我们需要搭建一个可以测试的slave。
slave的搭建和master是一样的,只是配置文件稍微有点变动
aaa@qq.com:/mesos-slave/mesos/sbin# cat /etc/hosts
127.0.0.1 localhost
172.16.126.129 web2
172.16.126.131 master1 mesos-master-1
172.16.126.132 master2 mesos-master-2
172.16.126.133 master3 mesos-master-3
aaa@qq.com:/mesos-slave/mesos/sbin# cat ../etc/mesos/mesos-agent-env.sh
# This file contains environment variables that are passed to mesos-agent.
# To get a description of all options run mesos-agent --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=unknown-machine:5050
export MESOS_master=zk://172.16.126.131:2181,172.16.126.132:2181,172.16.126.133:2181/mesos
export MESOS_hostname=172.16.126.129
# 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/cpu,cgroups/mem
配置和master有点不一样
启动slave
aaa@qq.com:/mesos-slave/mesos/sbin# sh mesos-start-agents.sh
Starting mesos-agent on 172.16.126.129
ssh 172.16.126.129 /mesos-slave/mesos/sbin/mesos-daemon.sh mesos-agent </dev/null >/dev/null
看看mesos 控制台
slave已经通过zk成功注册到了集群里。
测试一个shell命令看看是否能成功推送
在mesos集群控制台查看任务,但是为什么了执行了很多次,这个目前我不是很明白,需要进一步探索下
看看沙盒信息
到slave上去看看任务推送成功没
aaa@qq.com:/mesos-slave/mesos/sbin# ls /tmp/
hsperfdata_root mesos test
aaa@qq.com:/mesos-slave/mesos/sbin# cat /tmp/test
push jobs from marathon to mesos slave
OK。成功了。!!!!
转载于:https://my.oschina.net/jastme/blog/791440