入门

下载 Mesos

这里有不同的方式获取 Mesos:
1.从 Apache下载最新稳定版(推荐)。

  1. $ wget http://www.apache.org/dist/mesos/0.22.1/mesos-0.22.1.tar.gz
  2. $ tar -zxf mesos-0.22.1.tar.gz

2.克隆Mesos的Git库(适合高级用户)。

  1. $ git clone https://git-wip-us.apache.org/repos/asf/mesos.git

系统要求

Mesos可以运行在 Linux (64位)和 Mac OS X(64位)。

Ubuntu14.04

以下是 Ubuntu 14.04现有的说明。如果您使用不同的版本,请安装相应的的软件包。

  1. # Update the packages.
  2. $ sudo apt-get update
  3. # Install the latest OpenJDK.
  4. $ sudo apt-get install -y openjdk-7-jdk
  5. # Install autotools (Only necessary if building from git repository).
  6. $ sudo apt-get install -y autoconf libtool
  7. # Install other Mesos dependencies.
  8. $ sudo apt-get -y install build-essential python-dev python-boto libcurl4-nss-dev libsasl2-dev maven libapr1-dev libsvn-dev

Mac OS X Yosemite

以下是在 Mac OS X Yosemite下的说明。如果您使用不同的版本,请下载相应的软件包。

  1. # Install Command Line Tools.
  2. $ xcode-select --install
  3. # Install Homebrew.
  4. $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  5. # Install libraries.
  6. $ brew install autoconf automake libtool subversion maven

CentOS 6.6

以下是在 CentOS 6.6版本下的说明。如果您使用不同的版本,请下载相应的软件包。

  1. # Install a few utility tools
  2. $ sudo yum install -y tar wget which
  3. # 'Mesos > 0.21.0' requires a C++ compiler with full C++11 support,
  4. # (e.g. GCC > 4.8) which is available via 'devtoolset-2'.
  5. # Fetch the Scientific Linux CERN devtoolset repo file.
  6. $ sudo wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
  7. # Import the CERN GPG key.
  8. $ sudo rpm --import http://linuxsoft.cern.ch/cern/centos/7/os/x86_64/RPM-GPG-KEY-cern
  9. # Fetch the Apache Maven repo file.
  10. $ sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
  11. # 'Mesos > 0.21.0' requires 'subversion > 1.8' devel package, which is
  12. # not available in the default repositories.
  13. # Add the WANdisco SVN repo file: '/etc/yum.repos.d/wandisco-svn.repo' with content:
  14. [WANdiscoSVN]
  15. name=WANdisco SVN Repo 1.8
  16. enabled=1
  17. baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/$basearch/
  18. gpgcheck=1
  19. gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
  20. # Install essential development tools.
  21. $ sudo yum groupinstall -y "Development Tools"
  22. # Install 'devtoolset-2-toolchain' which includes GCC 4.8.2 and related packages.
  23. $ sudo yum install -y devtoolset-2-toolchain
  24. # Install other Mesos dependencies.
  25. $ sudo yum install -y apache-maven python-devel java-1.7.0-openjdk-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-util-devel
  26. # Enter a shell with 'devtoolset-2' enabled.
  27. $ scl enable devtoolset-2 bash
  28. $ g++ --version # Make sure you've got GCC > 4.8!

CentOS 7.1

以下是在 CentOS 7.1版本下的说明。如果您使用不同的版本,请下载相应的软件包。

  1. # Install a few utility tools
  2. $ sudo yum install -y tar wget
  3. # Fetch the Apache Maven repo file.
  4. $ sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
  5. # 'Mesos > 0.21.0' requires 'subversion > 1.8' devel package, which is
  6. # not available in the default repositories.
  7. # Add the WANdisco SVN repo file: '/etc/yum.repos.d/wandisco-svn.repo' with content:
  8. [WANdiscoSVN]
  9. name=WANdisco SVN Repo 1.9
  10. enabled=1
  11. baseurl=http://opensource.wandisco.com/centos/7/svn-1.9/RPMS/$basearch/
  12. gpgcheck=1
  13. gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
  14. # Install essential development tools.
  15. $ sudo yum groupinstall -y "Development Tools"
  16. # Install other Mesos dependencies.
  17. $ sudo yum install -y apache-maven python-devel java-1.7.0-openjdk-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-util-devel

构建 Mesos

  1. # Change working directory.
  2. $ cd mesos
  3. # Bootstrap (Only required if building from git repository).
  4. $ ./bootstrap
  5. # Configure and build.
  6. $ mkdir build
  7. $ cd build
  8. $ ../configure
  9. $ make

为了加快构建以及减少冗长的 log ,你可以在 make 命令后添加 -j \ V=0

  1. # Run test suite.
  2. $ make check
  3. # Install (Optional).
  4. $ make install

示例

Mesos 包含了用 Java , C++ , Python 写的 frameworks 示例。

  1. # Change into build directory.
  2. $ cd build
  3. # Start mesos master (Ensure work directory exists and has proper permissions).
  4. $ ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos
  5. # Start mesos slave.
  6. $ ./bin/mesos-slave.sh --master=127.0.0.1:5050
  7. # Visit the mesos web page.
  8. $ http://127.0.0.1:5050
  9. # Run C++ framework (Exits after successfully running some tasks.).
  10. $ ./src/test-framework --master=127.0.0.1:5050
  11. # Run Java framework (Exits after successfully running some tasks.).
  12. $ ./src/examples/java/test-framework 127.0.0.1:5050
  13. # Run Python framework (Exits after successfully running some tasks.).
  14. $ ./src/examples/python/test-framework 127.0.0.1:5050

注意:如果你要构建一个 frameworks 示例,需要确保你所构建的测试程序执行过 make check

本篇内容翻译自http://mesos.apache.org/gettingstarted/