devops之 gitlab-ci + mesos + docker + marathon 持续发布①mesos集群环境的搭建
devops之 gitlab-ci + mesos + docker + marathon 持续发布①mesos集群环境的搭建
公司内部搭建gitlab,安装gitlab-runner持续集成服务,通过修改 .gitlab-ci.yml 文件触发本地docker镜像打包推送到外网镜像仓库,然后通过marathon的管理界面或者api基于mesos集群管理docker镜像的发布
要部署mesos需要安装jdk1.8,zookeeper集群,maven(编译mesos需要安装依赖)
环境
1.安装jdk
# vim /etc/profile export JAVA_HOME=/usr/local/jdk1.8.0_261 export PATH=$JAVA_HOME/bin:$PATH
2.安装zookeeper
# wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz # tar xf zookeeper-3.4.10.tar.gz -C /usr/local/ # cd /usr/local/ # ln -s zookeeper-3.4.10 zookeeper
# 创建数据和日志目录
mkdir -p /data/zookeeper/data
mkdir -p /data/zookeeper/logs
分别在server1,server2,server3中执行一下语句
echo '1'> /data/zookeeper/data/myid echo '2'> /data/zookeeper/data/myid echo '3'> /data/zookeeper/data/myid
修改 zoo.cfg 配置
tickTime=2000 initLimit=10 syncLimit=5 dataDir=/data/zookeeper/data dataLogDir=/data/zookeeper/logs clientPort=2181 server.1= 192.168.254.161:2888:3888 server.2= 192.168.254.162:2888:3888 server.3= 192.168.254.185:2888:3888
3.下载安装maven
下载apache-maven的yum源
yum install wget tar git
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
准备svn的yum源
bash -c 'cat > /etc/yum.repos.d/wandisco-svn.repo <<EOF [WANdiscoSVN] name=WANdisco SVN Repo 1.9 enabled=1 baseurl=http://opensource.wandisco.com/centos/7/svn-1.9/RPMS/\$basearch/ gpgcheck=1 gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco EOF'
配置maven的环境
# vim /etc/profile export MAVEN_HOME=/usr/local/maven export PATH=$MAVEN_HOME/bin/:$PATH
4.安装docker
yum install -y yum-utils yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum install -y docker-ce
配置docker
# vim /etc/docker/daemon.json { "data-root": "/data/docker", "log-driver": "json-file", "log-opts": {"max-size": "100m", "max-file": "3"} }
更新系统源,安装Development tools
yum update systemd -y yum groupinstall Development tools -y yum install -y apache-maven python-devel python-six python-virtualenv java-1.8.0-openjdk-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-util-devel
5.下载并编译mesos1.4.1
# wget http://archive.apache.org/dist/mesos/1.4.1/mesos-1.4.1.tar.gz # tar xf mesos-1.4.1.tar.gz cd mesos-1.4.1 mkdir build cd build ../configure make -j 4 && make install
启动mesos
[root@ws-yt-server01-standby:/usr/local/mesos/build]# bin/mesos-master.sh --zk=zk://192.168.254.161:2181,192.168.254.168:2181,192.168.254.185:2181/mesos --port=5050 --log_dir=/var/log/mesos --cluster=test-cluster --quorum=1 --work_dir=/var/lib/mesos
从节点启动
bin/mesos-agent.sh --work_dir=/var/lib/mesos/agent --master=zk://192.168.254.161:2181,192.168.254.168:2181,192.168.254.185:2181/mesos --log_dir=/var/log/mesos/agent --logging_level=ERROR --containerizers=docker,mesos bin/mesos-agent.sh --work_dir=/var/lib/mesos/agent --master=zk://192.168.254.161:2181,192.168.254.168:2181,192.168.254.185:2181/mesos --log_dir=/var/log/mesos/agent --logging_level=ERROR --containerizers=docker,mesos
–zk :指定zk集群的地址
–log_dir : 保存log路径
–quorum:使用基于replicated-Log的注册表时复制的个数,改值需要为master总数量的一半以上,我的master为1个节点,所以我设置为1(如果设置错误会无法启动)
–work_dir:工作目录
# 编译编译出错,maven下载不到依赖,需要对maven设置代理
经过测试,发现mesos编译的似乎需要大量的cpu和内存资源,虚拟机2核2G内存无法编译通过,于是使用线上环境进行验证8核16G服务器