Docker集群、高级应用
     分类:虚拟化     有: 0 条评论

Docker集群、高级应用

     分类:虚拟化     有: 0 条评论

随着积累Docker越来越来的的知识,也想学习更高级的技术,所以给自己一个目标,慢慢有机会就去试验。

这是微信看到的一篇文章,关于美团的


美团

美团点评业务之技术解密,日均请求数十亿次的容器平台:https://mp.weixin.qq.com/s/mllStBPpMhGLETcplefx6w


Docker三剑客:compose、machine、swarm

https://mp.weixin.qq.com/s/5yGBnm-1JddBCH-ygNX53w
https://mp.weixin.qq.com/s/9twBOnUv4H0ZFb2lU-7Tjg


工具

五个Docker监控工具的对比:http://www.open-open.com/lib/view/open1433897177879.html


云平台

cSphere希云

安装参考:http://csphere.cn/hub/csphere

以下是适合Ubuntu的一键安装脚本

#!/bin/bash
# ENV : Ubuntu,Debian

# 网卡名称(ifconfig可以看到)
netcard=ens3

apt-get install docker.io
CSPHERE_IMAGE=csphere/csphere:0.13.0
DATA_DIR=/data/csphere

# 安装完成删除脚本,不想删除就注释掉rm这一行。
cleanup(){
#  rm ${BASH_SOURCE[0]}
  sed -i '/csphere-init/d' /etc/rc.local
}
trap cleanup EXIT

route=$(ip r|grep '172.16.0.0/12')
[ -n "$route" ] && ip r del $route
sed -i '/net 172.16.0.0 netmask/d' /etc/network/interfaces

initctl start docker || true

# Wait for docker daemon
docker_ok=false
for i in $(seq 1 120); do
  if docker version; then
    docker_ok=true
    break
  fi
  sleep 1
done

$docker_ok || {
  logger -p local3.error "Failed to start Docker daemon"
  exit 1
}

[ -d $DATA_DIR ] && rm -r $DATA_DIR
mkdir -p $DATA_DIR

AUTH_KEY=$(head -c 1000 /dev/urandom|tr -dc '0-9a-zA-Z'|tail -c 80|tee $DATA_DIR/auth-key)

# Wait for network to be ready
network_ok=false
for i in $(seq 1 360); do
  if curl --connect-timeout 1 -Ss -o /dev/null http://mirrors.aliyun.com/ubuntu; then
    network_ok=true
    break
  fi
  sleep 1
done

$network_ok || {
  logger -p local3.error "Network not ready."
  exit 1
}

docker run -itd --restart=always -e ROLE=controller -e AUTH_KEY=$AUTH_KEY\
  --name=csphere-controller -p 1016:80 -v $DATA_DIR:/data:rw $CSPHERE_IMAGE

ip=$(ip a show $netcard|grep -w inet|awk '{print $2}'|cut -d / -f 1)
# Wait for controller to start
controller_ok=false
for i in $(seq 1 120); do
  if curl --connect-timeout 1 -Ss -o /dev/null http://$ip:1016/; then
    controller_ok=true
    break
  fi
  sleep 1
done

$controller_ok || {
  logger -p local3.error "Couldn't start csphere-controller. "\
    "See docker logs or $DATA_DIR/logs/csphere.err"
  exit 1
}

docker run -itd --restart=always --name=csphere-agent -e ROLE=agent\
  -e CONTROLLER_ADDR=${ip}:1016 -e AUTH_KEY=$AUTH_KEY -v /data/csphere:/data:rw\
  -v /proc:/rootfs/proc:ro -v /sys:/rootfs/sys:ro -v /etc:/rootfs/etc:rw\
  -v /var/run/docker.sock:/var/run/docker.sock --net=host $CSPHERE_IMAGE

教程:http://csphere.cn/training

(●゚ω゚●)