Build Mesos platform on Centos6
Recently, public clouds are quite popular. Companies are also trying to use multiple public clouds, and IDCs are still in use, which brings a lot of trouble to O & M. I want to manage IDC and public cloud resources in a unified manner and find Mesos is suitable for doing this. First, let's figure out what it can do.
I have prepared three nodes to build a MINI platform. The OS is Centos6.6 and the Planning Architecture is as follows:
Node1: mesos-master, marathon, zookeeper
Node2: mesos-slave, docker
Node3: haproxy
Step 1: Install mesos on node1 and node2
1. Install the mesos support environment
Plan to install mesos-0.22.1, mesos 0.21.0 and later versions require C ++ 11, GCC version must be greater than 4.8, need to install devtoolset-2.
# Download the devtoolset-2 repo File
$ Sudo wget-O/etc/yum. repos. d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
# Import cern gpg key.
$ Sudo rpm -- import http://linuxsoft.cern.ch/cern/centos/7/ OS /x86_64/RPM-GPG-KEY-cern
# Download Apache Maven repo file.
$ Sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo-O/etc/yum. repos. d/epel-apache-maven.repo
# 'Mesos> 0.21.0 'requires 'subversion> 100' devel package, add the WANdisco SVN repo file "/etc/yum. repos. d/wandisco-svn.repo", and write the following content.
[WANdiscoSVN]
Name = WANdisco SVN Repo 1.8
Enabled = 1
Baseurl = http://opensource.wandisco.com/centos/6/svn-1.8/rpms/?basearch/
Gpgcheck = 1
Gpgkey = http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
# Install the development kit.
$ Sudo yum groupinstall-y "Development Tools"
If the following error occurs during installation, it indicates a package conflict.
# Error: Package: rpm-build-4.8.0-37.el6.x86_64 (c6-media)
# Requires: rpm = 4.8.0-37. el6
# Installed: rpm-4.8.0-38.el6_6.x86_64 (@ Updates/$ releasever)
# Rpm = 4.8.0-38. el6_6
# Available: rpm-4.8.0-37.el6.x86_64 (c6-media)
# Rpm = 4.8.0-37. el6
Download the required RPM package and install it :)
$ Wget ftp://rpmfind.net/linux/centos/6.6/updates/x86_64/Packages/rpm-build-4.8.0-38.el6_6.x86_64.rpm
$ Sudo yum localinstall-y rpm-build-4.8.0-38.el6_6.x86_64.rpm
# Install 'devtoolset-2-toolchain'. This package includes GCC 4.8.2 and related software packages.
$ Sudo yum install-y devtoolset-2-toolchain
You may encounter the following error message, which is also a packet conflict problem.
#### Error: Package: policycoreutils-python-2.0.83-19.47.el6.x86_64 (c6-media)
# Requires: policycoreutils = 2.0.83-19.47.el6
# Installed: policycoreutils-2.0.83-19.47.el6_6.1.x86_64 (@ Updates/$ releasever)
# Policycoreutils = 2.0.83-19.47.el6 _ 6.1
# Available: policycoreutils-2.0.83-19.47.el6.x86_64 (c6-media)
# Policycoreutils = 2.0.83-19.47.el6
This time we should be familiar with it. Just download it and install it.
$ Wget ftp://rpmfind.net/linux/centos/6.6/updates/x86_64/Packages/policycoreutils-python-2.0.83-19.47.el6_6.1.x86_64.rpm
$ Sudo yum localinstall-y policycoreutils-python-2.0.83-19.47.el6_6.1.x86_64.rpm
These packages are also required by mesos.
$ 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
Unfortunately, I have encountered a package conflict and solved it in the same way.
#### Error: Protected multilib versions: nss-util-3.16.1-3.el6.i686! = Nss-util-3.16.2.3-2.el6_6.x86_64
#### Error: Protected multilib versions: nss-3.16.1-14.el6.i686! = Nss-3.16.2.3-3.el6_6.x86_64
#### Error: Protected multilib versions: libcurl-7.19.7-37.el6_5.3.i686! = Libcurl-7.19.7-40.el6_6.3.x86_64
#### Error: Protected multilib versions: nss-softokn-freebl-3.14.3-17.el6.i686! = Nss-softokn-freebl-3.14.3-18.el6_6.x86_64
#### Error: Protected multilib versions: openssl-1.0.1e-30.el6.i686! = Openssl-1.0.1e-30.el6_6.4.x86_64
#### Error: Protected multilib versions: nss-softokn-3.14.3-17.el6.i686! = Nss-softokn-3.14.3-18.el6_6.x86_64
Download and install the conflict package.
$ Wget ftp: // 195.220.108.108/linux/centos/6.6/updates/x86_64/Packages/libcurl-devel-7.19.7-40.el6_6.3.x86_64.rpm
$ Sudo yum localinstall-y libcurl-devel-7.19.7-40.el6_6.3.x86_64.rpm
$ Wget ftp: // 195.220.108.108/linux/centos/6.6/updates/x86_64/Packages/openssl-devel-1.0.1e-30.el6_6.4.x86_64.rpm
$ Sudo yum localinstall-y openssl-devel-1.0.1e-30.el6_6.4.x86_64.rpm
To some of the installed are installed, and the last step is to activate the devtoolset-2 in shell.
$ Scl enable devtoolset-2 bash
$ G ++ -- version
If the GCC version is later than 4.8, congratulations, mesos running environment !!
2. Install mesos
Download the mesos-0.22.1 from the APACHE website and unzip it.
$ Wget http://www.apache.org/dist/mesos/0.22.1/mesos-0.22.1.tar.gz
$ Tar-zxf mesos-0.22.1.tar.gz
Compile and install
$ Mkdir build
$ Cd build
$ ../Configure -- prefix =/usr/local/mesos
$ Make
$ Make install
The following error is reported during the installation process because code.google.com is blocked by tianchao.
#### Download error on http://code.google.com/p/google-apputils-python: [Errno 101] Network is unreachable
There are other websites for download.
$ Wget https://pypi.python.org/packages/source/p/python-gflags/python-gflags-2.0.tar.gz
$ Python setup. py install
$ Wget https://pypi.python.org/packages/source/g/google-apputils/google-apputils-0.4.0.tar.gz
$ Python setup. py install
Make install again after installation.
Step 2: Install Zookeeper on node1
Download the zookeeper package and start the service.
$ Wget http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
$ Tar xzf zookeeper-3.4.6.tar.gz
$ Zookeeper-3.4.6 cd
$ Cp conf/zoo_sample.cfg conf/zoo. cfg
$ Bin/zkServer. sh start
Step 3: Start mesos master on node1
$ Mesos-master -- ip = master-ip -- work_dir =/var/lib/mesos -- zk = zk: // master-ip: 2181/mesos -- quorum = 1>/dev/null 2> & 1 &
In the browser, enter URL http: // master-ip: 5050 to access the master Management page.
Step 4: Install marathon on node1.
Download the marathon package from the mesosphere website and start the marathon service. Note that if the hostname cannot be resolved by dns, add it to/etc/hosts.
$ Wget http://downloads.mesosphere.com/marathon/v0.9.0/marathon-0.9.0.tgz
$ Tar xzf marathon-0.9.0.tgz
$ MESOS_NATIVE_JAVA_LIBRARY =/usr/local/mesos/lib/libmesos. so. /bin/start -- master zk: // master-ip: 2181/mesos -- zk: // master-ip: 2181/marathon>/dev/null 2> & 1 &
Enter URL http: // master-ip: 8080 in the browser to access the marathon Management page.
Step 5 install docker on node2 and start the docker service $ yum-y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ Yum install-y docker-io
$ Service docker start
$ Chkconfig docker on
Step 6: Start the mesos slave service $ mesos-slave -- master = zk: // master-ip: 2181/mesos -- ip = slave-ip -- containerizers = docker on node2, mesos -- executor_registration_timeout = 5 mins>/dev/null 2> & 1 &
Step 7: Use marathon to allocate computing resources
You can call the rest api of marathon to create a docker container. First use a json file to describe the application of the computing resource mara-nginx.json content is as follows:
{
"Id": "run-a-nginx-cluster-v111 ",
"Cpus": 0.3,
"Mem": 128.0,
"Instances": 2,
"Container ":{
"Type": "DOCKER ",
"Docker ":{
"Image": "nginx ",
"Parameters ":[
{"Key": "detach", "value": "true"}],
"Network": "BRIDGE ",
"PortMappings ":[
{"ContainerPort": 80, "servicePort": 80, "protocol": "tcp"}]
},
"HealthChecks ":[
{
"Protocol": "HTTP ",
"PortIndex": 0,
"Path ":"/",
"GracePeriodSeconds": 5,
"IntervalSeconds": 20,
"MaxConsecutiveFailures": 3
}
]
}
}
Using curl to directly call rest api. mesos will start the docker container on the slave machine to run the nginx service. If you want to adjust the computing resources and change the number of instances, you only need to modify them in the json file and call the put api.
$ Curl-x post-H "Content-Type: application/json"-d@mara-nginx.json http: // master-ip: 8080/v2/apps
Step 8: Install haproxy on node3
Haproxy helps us release services externally and install them using YUM
$ Yum install-y haproxy
Generate the haproxy. conf file using the marathon script
$ Marathon/bin/haproxy-marathon-bridge http: // master-ip: 8080>/etc/haproxy. conf
Start the haproxy Service
$ Service haproxy start