参考网址:http://mesos.apache.org/gettingstarted/
实验环境:mesos版本:0.21.0、操作系统:Red Hat 6
为了了解Spark的三种部署standalone、mesos和YARN。所以想尝试部署下mesos集群。我根据自己的需求,参考了官方文档的如下步骤:
There are different ways you can get Mesos:
Download the latest stable release from Apache (Recommended)
$ wget http://www.apache.org/dist/mesos/0.22.1/mesos-0.22.1.tar.gz
$ tar -zxf mesos-0.22.1.tar.gz
Following are the instructions for stock CentOS 6.5. If you are using a different OS, please install the packages accordingly.
Mesos 0.21.0+ requires subversion 1.8+ devel package which is not available by default by yum.
Add one of the repo that has subversion-devel 1.8 available, i.e:
Add new repo /etc/yum.repos.d/wandisco-svn.repo, with:
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0
$ sudo yum groupinstall -y "Development Tools"
$ sudo yum install -y 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
# Install maven.
$ wget http://mirror.nexcess.net/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
$ sudo tar -zxf apache-maven-3.0.5-bin.tar.gz -C /opt/
$ sudo ln -s /opt/apache-maven-3.0.5/bin/mvn /usr/bin/mvn
# Change working directory.
$ cd mesos
# Bootstrap (***Skip this if you are not building from git repo***).
$ ./bootstrap
# Configure and build.
$ mkdir build
$ cd build
$ ../configure
$ make
# Run test suite.
$ make check
# Install (***Optional***).
$ make install
Mesos comes bundled with example frameworks written in C++
, Java
and Python
.
# Change into build directory.
$ cd build
# Start mesos master (***Ensure work directory exists and has proper permissions***).
$ ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos
# Start mesos slave.
$ ./bin/mesos-slave.sh --master=127.0.0.1:5050
# Visit the mesos web page.
$ http://127.0.0.1:5050
# Run C++ framework (***Exits after successfully running some tasks.***).
$ ./src/test-framework --master=127.0.0.1:5050
# Run Java framework (***Exits after successfully running some tasks.***).
$ ./src/examples/java/test-framework 127.0.0.1:5050
# Run Python framework (***Exits after successfully running some tasks.***).
$ ./src/examples/python/test-framework 127.0.0.1:5050
NOTE: To build the example frameworks, make sure you build the test suite by doingmake check
.
但是mesos的构建远比我想象的要难一些。它花了我大概一天半的时间对它进行下载、准备安装环境以及简单的测试。其中几乎每一个步骤都会遇到问题,所以特意记录下来,方便将来参考:
$ wget http://www.apache.org/dist/mesos/0.21.0/mesos-0.21.0.tar.gz
$ tar -zxf mesos-0.21.0.tar.gz
$ git clone https://git-wip-us.apache.org/repos/asf/mesos.git
然后执行:
yum clean all && yum clean metadata && yum clean dbcache && yum makecache && yum update
2、Mesos 0.21.0 + 需要subversion 1.8+ deve这个包,它在默认的yum是获取不到的。可以加入一个新的repo,/etc/yum.repos.d/wandisco-svn.repo它的内容是:
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0
我不确定/etc/yum.repos.d/wandisco-svn.repo这个文件是否起到了作用,将wandisco-svn.repo这个文件添加到/etc/yum.repos.d。
3、执行sudo yum groupinstall -y "Development Tools",遇到如下问题:
public key for systemtap-client-2.5-5.el6.x86_64.rpm is not installed
原因是缺少systemtap-client-2.5-5.el6.x86_64.rpm。只要下载了这个rpm后执行rpm -ihv systemtap-client-2.5-5.el6.x86_64.rpm 安装即可,如果缺少其他依赖,就先安装其他依赖。
4、执行sudo yum install -y 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
5、安装maven
构建Mesos:
# Change working directory.
$ cd mesos
# Configure and build.
$ mkdir build
$ cd build
$ ../configure
在执行到../configure时遇到了如下问题:
1) configure:error:cannot find libz. libz is required for mesos to build.
原因是缺少zlib-devel-1.2.3-25.el6.x86_64
需要下载相应的rpm,并安装:
rpm -ihv zlib-devel-1.2.3-25.el6.x86_64.rpm
2) configure:error:cannot find libcurl. libcurl is required for mesos to build.
原因是缺少libcurl-devel-7.19.7-16.el6.x86_64
需要下载相应的rpm,并安装:
rpm -ihv libidn-devel-1.18-2.el6.x86_64.rpm
rpm -ihv libcurl-devel-7.19.7-16.el6.x86_64.rpm
3) configure:error:cannot find libapr-1. libapr-1 is required for mesos to build.
原因是缺少apr-devel-1.3.9-3.el6.x86_64
需要下载相应的rpm,并安装:
rpm -ihv apr-1.3.9-3.el6.x86_64.rpm
rpm -ihv apr-devel-1.3.9-3.el6.x86_64.rpm
rpm -ihv apr-util-1.3.9-3.el6.x86_64.rpm
4) configure:error:cannot find libsvn_subr-1 headers. libsubversion-1 is required for mesos to build.
从http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/找到下面的包,并安装:
rpm -ihv serf-1.2.0-1.x86_64.rpm
rpm -ihv subversion-debuginfo-1.8.0-1.x86_64.rpm
rpm -ihv subversion-1.8.0-1.x86_64.rpm
rpm -ihv subversion-javahl-1.8.0-1.x86_64.rpm
rpm -ihv subversion-devel-1.8.0-1.x86_64.rpm
5) configure:error:cannot find libsasl2. We need libsasl2 for authentication!
安装 rpm -ihv cyrus-sasl-devel-2.1.23-8.el6.x86_64.rpm
6) 如下图的错误:
解决方法:rpm -ihv python-devel-2.6.5-3.el6.x86_64.rpm
$ make
遇到如下问题:
为了解决上面的问题,需要安装下列包:
rpm -ihv apr-util-1.3.9-3.el6.x86_64.rpm
rpm -ihv apr-util-ldap-1.3.9-3.el6.x86_64.rpm
rpm -ihv db4-cxx-4.7.25-16.el6.x86_64.rpm
rpm -ihv db4-devel-4.7.25-16.el6.x86_64.rpm
rpm -ihv expat-devel-2.0.1-9.1.el6.x86_64.rpm
rpm -ihv openldap-devel-2.4.19-15.el6.x86_64.rpm
rpm -ihv apr-util-devel-1.3.9-3.el6.x86_64.rpm
# Run test suite.
$ make check
遇到如下问题:
意思是Linux的内核太旧了,这个错误我没鸟它,直接跳到下一步了。
# Install (***Optional***).
$ make install
测试:
# Change into build directory.
$ cd build
# Start mesos master (***Ensure work directory exists and has proper permissions***).
$ ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos
# Start mesos slave.
$ ./bin/mesos-slave.sh --master=127.0.0.1:5050 (可以在最后加个&)
# Visit the mesos web page.
$ http://127.0.0.1:5050
# Run Java framework (***Exits after successfully running some tasks.***).
$ ./src/examples/java/test-framework 127.0.0.1:5050
测试步骤没什么大问题,可以访问页面,需要注意的是,使用jps并不能查到mesos的进程.