mesos + marathon + docker部署
mesos + marathon + docker部署
张富贵 发表于2年前
mesos + marathon + docker部署
  • 发表于 2年前
  • 阅读 1148
  • 收藏 14
  • 点赞 0
  • 评论 0
摘要: mesos + marathon + docker部署

#mesos + marathon + docker部署

##架构设计 mesos + marathon均部署在CentOS7上,角色分配如下:

NameAddressOSRole
docker110.10.10.11CentOS7zookeeper、marathon、mesos-master、mesos-slave、docker server
docker210.10.10.12CentOS7zookeeper、mesos-slave、docker server

##环境准备 ###修改hosts 将下列内容添加到两台服务器的/etc/hosts/文件中

10.10.10.11 docker1
10.10.10.12 docker2

###安装依赖

wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel java-1.8.0-openjdk-headless
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
yum groupinstall -y "Development Tools"

##zookeeper部署 ###zookeeper配置 一般情况下,建议zookeeper服务器数量为奇数,这里由于资源有限,用两台做演示。

在两台服务器上分别安装zookeeper在/usr/local/zookeeper-3.4.6目录下。

编辑配置文件/usr/local/zookeeper-3.4.6/conf/zoo.cfg,内容如下:

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper-3.4.6/data
clientPort=2181
server.1=docker1:2888:3888
server.2=docker2:2888:3888

docker1上执行:

echo 1 > /usr/local/zookeeper-3.4.6/data/myid

docker2上执行:

echo 2 > /usr/local/zookeeper-3.4.6/data/myid

###启动zookeeper 在两台服务器上执行:

sh /usr/local/zookeeper-3.4.6/bin/zkServer.sh start

检查服务运行状态

/usr/local/zookeeper-3.4.6/bin/zkServer.sh status

##mesos部署 ###下载mesos

wget http://www.apache.org/dist/mesos/0.25.0/mesos-0.25.0.tar.gz
#解压:
tar -zxf mesos-0.25.0.tar.gz

###安装

cd /usr/local/mesos-0.25.0/
# Bootstrap
./bootstrap

# Configure and build.
mkdir build
cd build
../configure --with-webui --with-included-zookeeper
make
make install

###启动脚本

vim /usr/local/mesos-0.25.0/build/mesos.sh

添加下列内容:

#!/bin/bash
cd $(dirname $0)

lan_ip=输入本机IP地址

log_dir="/apps/mesos/logs"
work_dir="/apps/mesos/master"
master_log="/apps/mesos/mesos-master.log"
slave_log="/apps/mesos/mesos-slave.log"
if [ $# -eq 0 ];then
    echo 'Usage: mesos.sh {start-master|stop-master|restart-master|start-slave|stop-slave|restart-slave}'
    exit 110
fi
case $1 in
    start-master)
        ./bin/mesos-master.sh  --ip=$lan_ip --zk=zk://docker1:2181,docker2:2181/mesos   --work_dir=$work_dir  --log_dir=$log_dir --quorum=1  > $master_log 2>&1 &
        master_pid=`ps aux | grep mesos-master | grep -v grep | awk '{print $2}'`
        echo "masos-master is running, pid is $master_pid "
        ;;
    stop-master)
        master_pid=`ps aux | grep mesos-master | grep -v grep | awk '{print $2}'`
        kill $master_pid
        echo "masos-master is down"
        ;;
    restart-master)
        master_pid=`ps aux | grep mesos-master | grep -v grep | awk '{print $2}'`
        kill $master_pid
        echo "masos-master is stopping"
        sleep 2
        ./bin/mesos-master.sh  --ip=$lan_ip --zk=zk://docker1:2181,docker2:2181/mesos   --work_dir=$work_dir  --log_dir=$log_dir --quorum=1  > $master_log 2>&1 &
        master_pid=`ps aux | grep mesos-master | grep -v grep | awk '{print $2}'`
        echo "masos-master is running, pid is $master_pid "
        ;;
    start-slave)
        ./bin/mesos-slave.sh --ip=$lan_ip --containerizers=mesos,docker --master=zk://docker1:2181,docker2:2181/mesos  --log_dir=$log_dir > $slave_log 2>&1 &
        slave_pid=`ps aux | grep mesos-slave | grep -v grep | awk '{print $2}'`
        echo "masos-slave is running, pid is $slave_pid "
        ;;
    stop-slave)
        slave_pid=`ps aux | grep mesos-slave | grep -v grep | awk '{print $2}'`
        kill $slave_pid
        echo "masos-slave is down"
        ;;
    restart-slave)
        slave_pid=`ps aux | grep mesos-slave | grep -v grep | awk '{print $2}'`
        kill $slave_pid
        echo "masos-slave is stopping"
        sleep 2
        ./bin/mesos-slave.sh --ip=$lan_ip --containerizers=mesos,docker --master=zk://docker1:2181,docker2:2181/mesos  --log_dir=$log_dir > $slave_log 2>&1 &
        slave_pid=`ps aux | grep mesos-slave | grep -v grep | awk '{print $2}'`
        echo "masos-slave is running, pid is $slave_pid "
        ;;
    *)
        echo 'Usage: mesos.sh {start-master|stop-master|restart-master|start-slave|stop-slave|restart-slave}'
        exit 110
esac

###启动mesos 在docker1上执行:

sh /usr/local/mesos-0.25.0/build/mesos.sh start-master
sh /usr/local/mesos-0.25.0/build/mesos.sh start-slave

docker2上执行:

sh /usr/local/mesos-0.25.0/build/mesos.sh start-slave

###检测mesos启动状态 在浏览器打开:http://10.10.10.11:5050,查看服务运行是否正常

##marathon部署 ###下载marathon 下载地址:https://mesosphere.github.io/marathon/ 总提供的URL下载最新版本的marathon到/usr/local/目录下,并解压。 ###启动脚本

vim /usr/local/marathon-0.11.1/marathon.sh
#!/bin/bash
cd $(dirname $0)
if [ $# -eq 0 ];then
    echo 'Usage: marathon.sh {start|stop|restart}'
    exit 110
fi
PID=/apps/marathon/marathon.pid
case $1 in
    start)
        MESOS_NATIVE_JAVA_LIBRARY=/usr/local/mesos-0.25.0/build/src/.libs/libmesos-0.25.0.so   ./bin/start --master zk://docker1:2181,docker2:2181/mesos --zk zk://docker1:2181,docker2:2181/marathon > /niub/marathon/marathon.log 2>&1 &
        echo $! > $PID
        echo "marathon is running,pid is $!"
        ;;
    stop)
        kill `cat $PID`
        if [ $? -eq 0 ];then
            echo "marathon is stopped"
        else
            echo "error,marathon is not stopped"
        fi
        ;;
    restart)
        kill `cat $PID`
        if [ $? -eq 0 ];then
            echo "marathon is stopped"
        else
            echo "error,marathon is not stopped"
        fi
        sleep 3
        MESOS_NATIVE_JAVA_LIBRARY=/usr/local/mesos-0.21/lib/libmesos-0.21.0.so   ./bin/start --master zk://docker1:2181,docker2:2181/mesos --zk zk://docker1:2181,docker2:2181/marathon > /niub/marathon/marathon.log 2>&1 &
        echo $! > marathon.pid
        echo "marathon is running,pid is $!"
        ;;
    *)
        echo 'Usage: marathon.sh {start|stop|restart}'
        exit 110
esac

###启动marathon

sh /usr/local/marathon-0.11.1/marathon.sh start

###检测服务运行状态: URL: http://10.10.10.11:8080

##docker部署 略

共有 人打赏支持
粉丝 15
博文 16
码字总数 10690
×
张富贵
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: