8.Humpback部署

准备

准备三台安装过Docker服务器

192.168.215.81
192.168.215.82
192.168.215.83

三台设备均安装JDK

https://www.cnblogs.com/ff111/p/11868976.html

部署过程参考

https://humpback.github.io/humpback/#/zh-cn/run-humpback-components

 

1.Zookeeper 集群部署

三台同时操作如下


cd /opt

mkdir app #创建一个app目录
cd /opt/app    #跳转到app目录
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
#从网络获得zookeeper 也可以通过网址离线下载http://mirror.bit.edu.cn/apache/zookeeper/

tar -xzvf zookeeper-3.4.14.tar.gz #解压
mv zookeeper
-3.4.14 zookeeper #移动解压目录

cd zookeeper

修改配置文件

cp conf/zoo_sample.cfg conf/zoo.cfg
vi conf/zoo.cfg

修改如下

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/app/zookeeper/zkdata
dataLogDir=/opt/app/zookeeper/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=192.168.215.81:2888:3888
server.2=192.168.215.82:2888:3888
server.3=192.168.215.83:2888:3888

创建数据目录

mkdir -p /opt/app/zookeeper/zkdata
mkdir -p /opt/app/zookeeper/logs

 

以上安装流程三台服务器都照执行,接下来开始创建 zookeeper 集群并启动。

 

建立 Zookeeper 节点标识文件 myid

192.168.215.81

echo "1" > /opt/app/zookeeper/zkdata/myid

 

192.168.215.81

echo "1" > /opt/app/zookeeper/zkdata/myid

 

 

192.168.215.82

echo "2" > /opt/app/zookeeper/zkdata/myid

 

 

192.168.215.83

echo "3" > /opt/app/zookeeper/zkdata/myid

 

分别启动zookeeper

192.168.215.81

192.168.215.82

192.168.215.83

/opt/app/zookeeper/bin/zkServer.sh start

查看状态

 

/opt/app/zookeeper/bin/zkServer.sh status

 

 

 

关机后需要手动重启

 

2.部署私有仓库

 选用 192.168.2.80 作为 Humpback 私有仓库服务器

mkdir -p /var/lib/registry
docker pull registry:2.5.1

 

 

启动仓库

 请将配置文件拷贝到 /etc/docker/registry/config.yml

docker cp registry:/etc/docker/registry/config.yml /etc/docker/registry/config.yml

http:
  addr: :5000
  secret: abcdfg
  headers:
    X-Content-Type-Options: [nosniff]
    Access-Control-Allow-Headers: ['Origin,Accept,Content-Type,Authorization']
    Access-Control-Allow-Origin: ['*']
    Access-Control-Allow-Methods: ['GET,POST,PUT,DELETE']

 

 

docker run -d -p 5000:5000 --restart=always -v /var/lib/registry/:/var/lib/registry/ -v /etc/docker/registry/config.yml:/etc/docker/registry/config.yml --name registry registry:2.5.1

 

 

 访问

curl http://192.168.215.81:5000/v2/_catalog

 

 

参考:https://blog.csdn.net/twingao/article/details/81042563

 

3.部署 Humpback 站点

以 192.168.215.81 作为 Humpback Web 站点服务器启动,设置端口:8012。
站点默认访问端口为:80,如果要自定义端口,请在容器创建时指定 -e HUMPBACK_LISTEN_PORT=XXXX 即可。
/opt/app/humpback-web/dbFiles 文件为 Humpback 系统持久化数据文件,会存储站点管理和分组信息,启动后请妥善保存。

mkdir -p /opt/app/humpback-web
docker run -d --net=host --restart=always -e HUMPBACK_LISTEN_PORT=8012 -v /opt/app/humpback-web/dbFiles:/humpback-web/dbFiles --name humpback-web humpbacks/humpback-web:latest


访问站点,打开浏览器输入:http://192.168.215.81:8012
默认账户:admin 密码:123456

 

 4.部署 Humpback Agent

 三台服务器:192.168.215.81, 192.168.215.82, 192.168.215.83 都需要部署 Humpback Agent 用于实现本地镜像、容器管理。

查看版本号

docker version

首先检查 Docker API

 

 

 

启动 Humpback Agent


docker run -d -ti --net=host --restart=always --name=humpback-agent -e DOCKER_API_VERSION=v1.32 -e DOCKER_AGENT_IPADDR=0.0.0.0 -e DOCKER_CLUSTER_ENABLED=true -e DOCKER_CLUSTER_URIS=zk://192.168.215.81:2181,192.168.215.82:2181,192.168.215.83:2181 -e DOCKER_CLUSTER_NAME=humpback/center -v /var/run/:/var/run/:rw humpbacks/humpback-agent:latest

docker ps -a

 

 创建分组,注册服务器

http://192.168.215.81:8012/

 

 

 

 

5.部署 Humpback Center

Humpback Center 主要为 Humpback 平台提供集群容器调度服务,以集群中心角色实现各个 Group 的容器分配管理。
需要集群调度的 Group 要在设置中将 Cluster Mode 开关打开即可

启动 Humpback Center

docker pull humpbacks/humpback-center:latest
docker run -d -ti --net=host --restart=always --name=humpback-center -e HUMPBACK_SITEAPI=http://192.168.215.81:8012/api -e CENTER_LISTEN_PORT=:8589 -e CENTER_API_ENABLECORS=true -e DOCKER_CLUSTER_URIS=zk://192.168.215.81:2181,192.168.215.82:2181,192.168.215.83:2181 -e DOCKER_CLUSTER_NAME=humpback/center -v /opt/app/humpback-center/cache:/opt/humpback-center/cache -v /opt/app/humpback-center/logs:/opt/humpback-center/logs -v /opt/app/humpback-center/data:/opt/humpback-center/data humpbacks/humpback-center:latest
docker ps -a

 

附:

Get https://192.168.215.81:5000/v2/: http: server gave HTTP response to HTTPS client

提示如上错误解决方案

 

 

服务器创建这个文件

 

 

{ "insecure-registries":["192.168.215.81:5000"] }

  注意: 该配置是配置在docker客户端,让docker客户端以不安全的http请求访问docker registry,ip以及端口填写的是提供服务容器的ip以及端口。

重启docker服务器

systemctl daemon-reload 
systemctl restart docker.service
systemctl enable docker.service

 

防火墙

#开启防火墙 
ufw enable

#关闭防火墙 
ufw disable

#查看防火墙状态 
ufw status

 

内存和CPU查看

#查看内存使用情况
free -m
#查看CPU
top
#查看线程
top -H -p pid

 

开关交换区(docker必修关闭交换区)

#swap分区的关闭
sudo swapoff -a
#swap分区的开启
sudo swapon -a

 

posted @ 2019-11-19 15:16  疯癫大圣  阅读(399)  评论(0编辑  收藏  举报