ubuntu16.04下安装部署mesos+marathon+docker
一 MESOS安装
1 http://archive.apache.org/dist/mesos/1.0.0/ 下载安装包
mesos-1.0.0 .tar.gz
2 通过apt-get下载安装相关的依赖包
在下载先做些热身
1 )apt-get clean
2 )apt-get update
3 )apt-get grade
4 )apt-get install apt-file
5 )apt-file update
apt-file主要是为了在编译过程中发现缺包时可以通过 apt-file search来定位 ,比如缺了libz的时候,执行apt-file search libz来定位相关包在什么源包中,用通过apt-get来下载源包,从而获取所缺包。
$ apt-get -y install build-essential python-dev python-boto libcurl4-nss-dev libsasl2-dev libsasl2-modules maven libapr1-dev libsvn-dev lib32z1 zlib1g zlib1g-dev
3 配置maven
$ vi /etc/maven/setting.xml
添加本地库
<localRepository>/usr/share/maven-repo</localRepository>
4 编译mesos
$ tar -zxvf mesos-1.0.0 .tar.gz
$ cd mesos-1.0.0
$ mkdir build
$ cd build
$ ../configure
$ make(十分漫长的过程,网上说make -j N能提速)
$ make install
5 视人品来填坑,人品好的可以跳过
当运行是有可能报erro while loading shared libraries:libmisos-1.0.0.so:cannot open shared object file: No such file or directory
这是因为没有把libmisos-1.0.0.so成功关联linux的usr/lib下
$ ln -s /usr/local/lib/*.so /usr/lib
$ ldconfig
6 运行mesos
$ cd /usr/local/sbin
Master:
$ mesos-master --ip=10.92.7.10 --quorum=1 --work_dir=/opt/mesos/mesos-1.0.0 --zk=zk://10.108.68.140:2181/mesos,10.108.68.140:2182/mesos,10.108.68.140:2183/mesos --cluster=mesos-cluster --log_dir=/opt/mesos/mesos-1.0.0/log --logging_level=ERROR
$ mesos-master --ip=10.92.7.11 --quorum=1 --work_dir=/usr/local/mesos-1.0.0 --zk=zk://10.108.68.140:2181/mesos,10.108.68.140:2182/mesos,10.108.68.140:2183/mesos --cluster=mesos-cluster --log_dir=/opt/mesos/mesos-1.0.0/log --logging_level=ERROR
$ mesos-master --ip=10.92.7.12 --quorum=1 --work_dir=/opt/mesos/mesos-1.0.0 --zk=zk://10.108.68.140:2181/mesos,10.108.68.140:2182/mesos,10.108.68.140:2183/mesos --cluster=mesos-cluster --log_dir=/opt/mesos/mesos-1.0.0/log --logging_level=ERROR
Slaver:
$ mesos-agent --ip=10.92.21.68 --work_dir=/opt/mesos/mesos-1.0.0 --master=zk://10.108.68.140:2181/mesos,10.108.68.140:2182/mesos,10.108.68.140:2183/mesos --log_dir=/opt/mesos/mesos-1.0.0/log --logging_level=ERROR --docker=/usr/bin/docker
$ mesos-master --ip=10.92.7.9 --quorum=1 --work_dir=/opt/mesos/mesos-1.0.0 --zk=zk://10.108.68.140:2181/mesos,10.108.68.140:2182/mesos,10.108.68.140:2183/mesos --cluster=mesos-cluster --log_dir=/opt/mesos/mesos-1.0.0/log --logging_level=ERROR
二 安装marathon
1 下载包http://downloads.mesosphere.com/marathon/v1.2.0/marathon-1.2.0.tgz
marathon-1.2.0.tgz
2 解压
$ tar -zxvf marathon-1.2.0.tgz
$ cd marathon-1.2.0
3 运行
分别在三台mesos管理节点上运行(10.92.7.10/11/12)
$ ./bin/start --master zk://10.108.68.140:2181/mesos,10.108.68.140:2182/mesos,10.108.68.140:2183/mesos --zk zk://10.108.68.140:2181/marathon,10.108.68.140:2182/marathon,10.108.68.140:2183/marathon
三 启动swarm
10.92.7.10:
$ docker swarm init --listen-addr 10.92.7.10:2375
docker swarm join-token manager
10.92.7.11:
$ docker swarm join \
--token SWMTKN-1-47sw4sahh155dh541ue3befx5bzhdav29ew3hzekmlsm17fzjr-57bvcosjnupcrl0jjlxfgd91r \
10.92.7.10:2375
10.92.7.12:
$ docker swarm join \
--token SWMTKN-1-47sw4sahh155dh541ue3befx5bzhdav29ew3hzekmlsm17fzjr-57bvcosjnupcrl0jjlxfgd91r \
10.92.7.10:2375
成员节点
10.92.21.68:
$ docker swarm join \
--token SWMTKN-1-47sw4sahh155dh541ue3befx5bzhdav29ew3hzekmlsm17fzjr-4jcyj0q8wb1u59tk34w9dil4e \
10.92.7.10:2375
10.92.7.9:
$ docker swarm join \
--token SWMTKN-1-47sw4sahh155dh541ue3befx5bzhdav29ew3hzekmlsm17fzjr-4jcyj0q8wb1u59tk34w9dil4e \
10.92.7.10:2375
四 启动overlay
$ docker network create -d overlay overlay_net
五 在marathon上配置docker容器,并运行
/webserver/nginxlua
Command
Unspecified
Constraints
Unspecified
Dependencies
Unspecified
Labels
Unspecified
Resource Roles
Unspecified
Container
{
"type": "DOCKER",
"volumes": [],
"docker": {
"image": "10.92.21.160:5000/csmbp/nginx:latest",
"network": "BRIDGE",
"portMappings": [
{
"containerPort": 80,
"hostPort": 0,
"servicePort": 10000,
"protocol": "tcp",
"labels": {}
}
],
"privileged": false,
"parameters": [],
"forcePullImage": false
}
}
CPUs
1
Environment
Unspecified
Executor
Unspecified
Health Checks
[
{
"path": "/",
"protocol": "HTTP",
"portIndex": 0,
"gracePeriodSeconds": 300,
"intervalSeconds": 60,
"timeoutSeconds": 20,
"maxConsecutiveFailures": 3,
"ignoreHttp1xx": false
}
]
Instances
1
IP Address
Unspecified
Memory
128 MiB
Disk Space
0 MiB
Port Definitions
[
{
"port": 10000,
"protocol": "tcp",
"labels": {}
}
]
Backoff Factor
1.15
Backoff
1 seconds
Max Launch Delay
3600 seconds
URIs
Unspecified
User
Unspecified
Args
Unspecified
Version
2016-10-20T14:36:54.795Z
tomcat
/app/tomcat
Command
Unspecified
Constraints
Unspecified
Dependencies
Unspecified
Labels
Unspecified
Resource Roles
Unspecified
Container
{
"type": "DOCKER",
"volumes": [],
"docker": {
"image": "10.92.21.160:5000/csmbp/tomcat:8.0",
"network": "BRIDGE",
"portMappings": [
{
"containerPort": 8080,
"hostPort": 0,
"servicePort": 10002,
"protocol": "tcp",
"labels": {}
}
],
"privileged": false,
"parameters": [],
"forcePullImage": false
}
}
CPUs
2
Environment
Unspecified
Executor
Unspecified
Health Checks
[
{
"path": "/CSMBP/",
"protocol": "HTTP",
"portIndex": 0,
"gracePeriodSeconds": 500,
"intervalSeconds": 500,
"timeoutSeconds": 300,
"maxConsecutiveFailures": 3,
"ignoreHttp1xx": false
}
]
Instances
1
IP Address
Unspecified
Memory
4096 MiB
Disk Space
0 MiB
Port Definitions
[
{
"port": 10002,
"protocol": "tcp",
"labels": {}
}
]
Backoff Factor
1.15
Backoff
1 seconds
Max Launch Delay
3600 seconds
URIs
Unspecified
User
Unspecified
Args
Unspecified
Version
2016-10-20T17:30:06.459Z
tomcat健康检查的时间要和垃圾回收的时候设长一点