Chapter 26 Mesos

26.1 Source Code

https://github.com/apache/mesos/blob/master/docs/container-image.md

http://jolestar.com/parallel-programming-model-thread-goroutine-actor/

https://www.zhihu.com/question/38861287
http://gaopenghigh.github.io/mesos/2016/12/06/01_master_start.html
https://blog.csdn.net/popsuper1982/article/details/52736049

26.1.1 Install in Ubuntu 17.10

git clone and then build, install to /opt/share/mesos_build:

apt-get -y install build-essential python-dev \
 libcurl4-nss-dev libsasl2-dev libsasl2-modules maven\
 libapr1-dev libsvn-dev zlib1g-dev
mkdir build
cd build
 /opt/share/git_mesos/build [master {origin/master}|✔] 
../configure --prefix=/opt/share/mesos_build
make -j8
make -j8 install

ansible allvm -a "mkdir /var/lib/mesos"
ansible allvm -a "mkdir /var/lib/mesos/log"
ansible allvm -a "mkdir /var/lib/mesos/data"
ansible allvm -a "mkdir /var/lib/mesos/run"
ansible allvm -a "apt-get -y install build-essential python-dev \
libcurl4-nss-dev libsasl2-dev libsasl2-modules maven \
libapr1-dev libsvn-dev zlib1g-dev"
  • Java

jabba install 1.8.172

  • start zookeeper

check this

  • start Mesos Cluster
ansible u3 -a "mesos-start-cluster.sh"
  • stop Mesos Cluster
ansible u3 -a "mesos-stop-cluster.sh"

http://u3:5050/#/


If this doesnot work, it means your config is wrong, you can try the following.

Create a cluster named HenryWu:

In master:

mesos-master --ip=192.168.0.103 --work_dir=/var/lib/mesos --cluster=HenryWu --zk=zk://u3:2181,u4:2181,u5:2181/mesos --quorum=1

In slave:

mesos-agent --master=u3:5050 --work_dir=/var/lib/mesos

http://blog.csdn.net/jfengamarsoft/article/details/74375968

All the python packae is in:

/opt/share/mesos_build/lib/python2.7/site-packages

  • Build Mesos Python EGG
12:40 # unzip -l /opt/share/git_aurora/3rdparty//ubuntu/artful64/python/mesos.executor-1.6.0-py2.7-linux-x86_64.egg
Archive:  /opt/share/git_aurora/3rdparty//ubuntu/artful64/python/mesos.executor-1.6.0-py2.7-linux-x86_64.egg
  Length      Date    Time    Name
---------  ---------- -----   ----
      505  2018-05-08 03:01   mesos/__init__.py
      355  2018-06-10 16:38   mesos/__init__.pyc
      855  2018-05-08 03:01   mesos/executor/__init__.py
 16532912  2018-06-10 16:38   mesos/executor/_executor.so
      563  2018-06-10 16:38   mesos/executor/_executor.pyc
      239  2018-06-10 16:38   mesos/executor/__init__.pyc
      285  2018-06-10 16:38   mesos/executor/_executor.py
      439  2018-06-10 16:38   EGG-INFO/SOURCES.txt
      296  2018-06-10 16:38   EGG-INFO/PKG-INFO
        6  2018-06-10 16:38   EGG-INFO/namespace_packages.txt
        1  2018-06-10 16:38   EGG-INFO/dependency_links.txt
        6  2018-06-10 16:38   EGG-INFO/top_level.txt
        1  2018-06-10 16:38   EGG-INFO/not-zip-safe
       28  2018-06-10 16:38   EGG-INFO/native_libs.txt
       25  2018-06-10 16:38   EGG-INFO/requires.txt
---------                     -------
 16536516                     15 files
✔ /opt/share/git_aurora/build-support/python [henrywu L|✔] 
12:45 # ./make-mesos-native-egg artful64 1.6.0 /opt/share/git_aurora/3rdparty/

26.2 Aurora

26.2.1 Overview

http://aurora.apache.org/documentation/0.20.0/getting-started/overview/

https://andyyoung01.github.io/2016/08/10/Apache-Mesos-11-%E4%BD%BF%E7%94%A8Aurora%E5%88%9B%E5%BB%BA%E4%BB%BB%E5%8A%A1/

  • Compile:

Old ref: http://aurora.apache.org/documentation/0.9.0/deploying-aurora-scheduler/#creating-the-distribution-zip-file-optional

 /opt/share/git_aurora [master {origin/master}|✔] 
17:57 # ./gradlew distZip
...
 /opt/share/git_aurora/dist/distributions [master {origin/master}|✔] 
17:58 # l
./  ../  aurora-scheduler-0.20.0-SNAPSHOT.tar  aurora-scheduler-0.20.0-SNAPSHOT.zip
 /opt/share/git_aurora/dist/distributions [master {origin/master}|✔] 
17:58 # unzip -l aurora-scheduler-0.20.0-SNAPSHOT.zip |gp bin
1599:    81866  2018-02-25 21:11   aurora-scheduler-0.20.0-SNAPSHOT/lib/guice-multibindings-4.1.0.jar
1609:  1138921  2018-02-25 21:11   aurora-scheduler-0.20.0-SNAPSHOT/lib/jackson-databind-2.5.1.jar
1694:        0  2018-03-10 17:09   aurora-scheduler-0.20.0-SNAPSHOT/bin/
1695:     9413  2018-02-25 21:36   aurora-scheduler-0.20.0-SNAPSHOT/bin/recovery-tool
1696:     9411  2018-02-25 21:36   aurora-scheduler-0.20.0-SNAPSHOT/bin/aurora-scheduler
1697:     6500  2018-02-25 21:36   aurora-scheduler-0.20.0-SNAPSHOT/bin/aurora-scheduler.bat
1698:     6496  2018-02-25 21:36   aurora-scheduler-0.20.0-SNAPSHOT/bin/recovery-tool.bat
1699:     9413  2018-02-25 21:36   aurora-scheduler-0.20.0-SNAPSHOT/bin/recovery-tool
1700:     9411  2018-02-25 21:36   aurora-scheduler-0.20.0-SNAPSHOT/bin/aurora-scheduler
1701:     6500  2018-02-25 21:36   aurora-scheduler-0.20.0-SNAPSHOT/bin/aurora-scheduler.bat
1702:     6496  2018-02-25 21:36   aurora-scheduler-0.20.0-SNAPSHOT/bin/recovery-tool.bat

Official binary:

https://apache.bintray.com/aurora/

mkdir -p /var/lib/aurora/scheduler/db

/opt/share/git_aurora/aurora-packaging/builder/deb/ubuntu-artful/build.sh

change:

THIRD_PARTY_REPO=“https://svn.apache.org/repos/asf/aurora/3rdparty/ubuntu/xenial64/python/

/opt/share/git_aurora/3rdparty/python/requirements.txt

change:

protobuf>=3.3.0

✔ /opt/share/git_aurora [henrywu L|✔] 
16:49 # git archive --prefix=apache-aurora-$(cat .auroraversion)/ -o snapshot-$(cat .auroraversion).tar.gz HEAD
cd aurora-packaging
./build-artifact.sh builder/deb/ubuntu-artful ../snapshot-0.21.0-SNAPSHOT.tar.gz 0.21.0-SNAPSHOT

to generate debian packages.

To this for all mesos machines:

echo 'export MESOS_NATIVE_JAVA_LIBRARY=/opt/share/mesos_build/lib/libmesos.so' >> ~/.bashrc
cd /opt/share/git_aurora/aurora-packaging/artifacts/aurora-ubuntu-artful/dist
dpkg -i *deb
mesos-log initialize --path=/var/lib/aurora/scheduler/db
systemctl  start thermos
systemctl  start aurora-scheduler

then go to master u3 to run: aurora-scheduler-startup

https://github.com/shadowwalker2718/mesos_build

Now access webui of aruora: http://u3:8081/

$ll /usr/bin/*aurora*
lrwxrwxrwx 1 root root   31 Jun  9 16:50 /usr/bin/aurora -> ../share/aurora/bin/kaurora.pex*
lrwxrwxrwx 1 root root   37 Jun  9 16:50 /usr/bin/aurora-admin -> ../share/aurora/bin/kaurora_admin.pex*
-rwxr-xr-x 1 root root 1534 Jun  9 16:50 /usr/bin/aurora-scheduler-startup*

26.2.2 Example:

systemctl start thermos and systemctl -a

mesos-log initialize --path=/var/lib/aurora/scheduler/db

http://aurora.apache.org/documentation/latest/getting-started/tutorial/

[1882][u3][1][-bash](21:29:47)[0](root) : /opt/share/aurora/jobs
$cat /etc/aurora/clusters.json
[
  {
    "auth_mechanism": "UNAUTHENTICATED",
    "name": "HenryWu",
    "scheduler_zk_path": "/aurora/scheduler",
    "slave_root": "/var/lib/mesos",
    "slave_run_directory": "latest",
    "zk": "u3"
  }
]
[1883][u3][1][-bash](21:30:06)[0](root) : /opt/share/aurora/jobs
$aurora job create HenryWu/www-data/devel/hello_world /opt/share/aurora/jobs/hello_world.aurora
 INFO] Creating job hello_world
 INFO] Checking status of HenryWu/www-data/devel/hello_world
Job create succeeded: job url=http://192.168.0.103:8081/scheduler/www-data/devel/hello_world
...
$aurora job killall HenryWu/www-data/devel/hello_world
 INFO] Killing tasks for job: HenryWu/www-data/devel/hello_world
 INFO] Instances to be killed: [0]
Successfully killed instances [0]
Job killall succeeded
$aurora update start HenryWu/www-data/devel/hello_world /opt/share/aurora/jobs/hello_world.aurora
This job update will:
add instances: [0]
 INFO] Starting update for: hello_world
Job update has started. View your update progress at http://192.168.0.103:8081/scheduler/www-data/devel/hello_world/update/a1154b1a-3c47-4054-abd5-0a62ecda3c7b
[1894][u3][1][-bash](21:45:55)[0](root) : /opt/share/aurora/jobs
$aurora job killall HenryWu/www-data/devel/hello_world
 INFO] Killing tasks for job: HenryWu/www-data/devel/hello_world
 INFO] Instances to be killed: [0]
Kill of instances [0] failed with error:
    Job is currently updating
    Error: job is locked by an active update.
      Run 'aurora update abort' or wait for the active update to finish.
[1895][u3][1][-bash](21:47:02)[0](root) : /opt/share/aurora/jobs
$aurora update abort
usage: aurora update abort [-h] [--message MESSAGE] [--verbose]
                           [--skip-hooks hook,hook,...]
                           CLUSTER/ROLE/ENV/NAME
aurora update abort: error: too few arguments
[1896][u3][1][-bash](21:48:18)[0](root) : /opt/share/aurora/jobs
$aurora update abort HenryWu/www-data/devel/hello_world
Update has been aborted.

admin:

$/usr/share/aurora/bin/kaurora_admin.pex get_cluster_config HenryWu
{"slave_run_directory": "latest", "auth_mechanism": "UNAUTHENTICATED", "name": "HenryWu", "slave_root": "/var/lib/mesos", "zk": "u3,u4,u5", "scheduler_zk_path": "/aurora/sche

http://aurora.apache.org/documentation/latest/reference/task-lifecycle/

  • Failed to load native Mesos library from /usr/local/lib
export MESOS_NATIVE_JAVA_LIBRARY=/opt/share/mesos_build/lib/libmesos.so
cd /opt/share/git_aurora/aurora-packaging/artifacts/aurora-ubuntu-artful/dist
dpkg -i *deb
mesos-log initialize --path=/var/lib/aurora/scheduler/db
systemctl  start thermos
systemctl  start aurora-scheduler

pstree -pacglt should see aurora process(java) and /usr/sbin/thermos_observer process(Python).

http://u3:1338/

还要注意Mesos master启动时指定了--roles=www-data选项,并且每个slave节点上存在www-data的用户!