From 82ce942fa24c50d56665fbd81fdd5551bcb86858 Mon Sep 17 00:00:00 2001 From: KennyLee Date: Tue, 18 Jul 2017 16:41:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4zookeeper=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lts/README.md | 6 +- lts/lts-center/docker-compose.yml | 59 ++++++++++++++----- lts/lts-center/lts-admin/Dockerfile | 2 +- lts/lts-center/lts-admin/config/lts-admin.cfg | 4 +- .../lts-admin/config/lts-monitor.cfg | 6 +- .../lts-jobtracker/config/application.yml | 6 +- zookeeper/3.4.10/Dockerfile | 1 + 7 files changed, 60 insertions(+), 24 deletions(-) diff --git a/lts/README.md b/lts/README.md index 15e45fe..b4194db 100644 --- a/lts/README.md +++ b/lts/README.md @@ -51,7 +51,11 @@ 配置说明 * 基本配置信息参考 [LTS](http://git.oschina.net/hugui/light-task-scheduler),而配置文件都可以在宿主目录找到。 - * 由于在docker环境,而lts默认绑定的是容器内的ip,还好lts支持手动指定 `bind-ip` 。所以需要手动配置各自部署的服务器宿主的IP,影响的文件有 `lts-admin/config/lts-monitor.cfg`、`lts-jobtracker/config/application.yml `,以及**不在lts-center中,另外跑的tasktracker节点**。*(有空再找办法解决,至少让修改简单点,也许采取类似host的解决方案也可以)* + * docker的network配置为 `host` + + 由于 `jobtrack` 等应用在docker环境。而外部启动 `tasktrack` 可能不在docker的同一个network中,而lts默认绑定的是容器内的ip,还好lts支持手动指定 `bind-ip`,暂时使用host模式。 + + 故此,`admin`,`jobtrack`和`tasktrack`等节点需要配置各自部署的服务器宿主的IP,影响的文件有 `lts-admin/config/lts-monitor.cfg`、`lts-jobtracker/config/application.yml `,以及**不在lts-center中,另外跑的tasktracker节点**。*(有空再找办法解决,至少让修改简单点,也许采取类似host的解决方案也可以)* * [lts-tasktracker](./lts-tasktracker) diff --git a/lts/lts-center/docker-compose.yml b/lts/lts-center/docker-compose.yml index 69de982..d4a159c 100644 --- a/lts/lts-center/docker-compose.yml +++ b/lts/lts-center/docker-compose.yml @@ -1,43 +1,74 @@ -version: '2' +version: '3' + services: zoo1: - image: zookeeper:3.4.9 + image: registry.cn-hangzhou.aliyuncs.com/kennylee/zookeeper container_name: lts-zoo1 restart: unless-stopped ports: - - "5181:2181" + - "2181:2181" volumes: - ./data/zoo1/data/:/data/:z - ./data/zoo1/datalog/:/datalog/:z environment: - ZOO_MY_ID=1 - - TZ=Asia/Shanghai + logging: + driver: 'json-file' + options: + max-size: '30m' + max-file: '1' db: - image: registry.alauda.cn/kenny/mysql + image: registry.cn-hangzhou.aliyuncs.com/kennylee/mysql container_name: lts-mysql ports: - - "5306:3306" + - "3306:3306" restart: unless-stopped volumes: - ./data/mysql/:/var/lib/mysql/:rw - ./lts-mysql/database/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro environment: - - TZ=Asia/Shanghai - MYSQL_ROOT_PASSWORD=111111 + logging: + driver: 'json-file' + options: + max-size: '30m' + max-file: '1' admin: - extends: - file: ./lts-admin/docker-compose.yml - service: admin + build: ./lts-admin/ + container_name: lts-admin + network_mode: 'host' + volumes: + - ./lts-admin/config/lts-admin.cfg:/opt/tomcat/webapps/ROOT/WEB-INF/classes/lts-admin.cfg:ro + - ./lts-admin/config/lts-monitor.cfg:/opt/tomcat/webapps/ROOT/WEB-INF/classes/lts-monitor.cfg:ro + - ./lts-admin/config/server.xml:/opt/tomcat/conf/server.xml:ro restart: unless-stopped depends_on: - zoo1 - db + logging: + driver: 'json-file' + options: + max-size: '30m' + max-file: '1' jobtracker: - extends: - file: ./lts-jobtracker/docker-compose.yml - service: jobtracker + build: ./lts-jobtracker/ + container_name: lts-jobtracker + volumes: + - ./lts-jobtracker/config/application.yml:/data/application.yml:ro + network_mode: 'host' + entrypoint: + - java + - -jar + - /data/lts-jobtracker.jar + - --spring.config.location=/data/application.yml restart: unless-stopped + environment: + JAVA_OPTS: -server -Xms128m -Xmx512m depends_on: - zoo1 - db - + logging: + driver: 'json-file' + options: + max-size: '30m' + max-file: '1' diff --git a/lts/lts-center/lts-admin/Dockerfile b/lts/lts-center/lts-admin/Dockerfile index 22bea54..a783c15 100755 --- a/lts/lts-center/lts-admin/Dockerfile +++ b/lts/lts-center/lts-admin/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.cn-hangzhou.aliyuncs.com/kennylee/tomcat:tomcat8-jdk8 +FROM registry.cn-hangzhou.aliyuncs.com/kennylee/tomcat:tomcat8-jre8 MAINTAINER kennylee26 diff --git a/lts/lts-center/lts-admin/config/lts-admin.cfg b/lts/lts-center/lts-admin/config/lts-admin.cfg index e9cf40b..5824d2e 100644 --- a/lts/lts-center/lts-admin/config/lts-admin.cfg +++ b/lts/lts-center/lts-admin/config/lts-admin.cfg @@ -3,7 +3,7 @@ console.username=admin console.password=admin # 注册中心地址,可以是zk,也可以是redis -registryAddress=zookeeper://127.0.0.1:5181 +registryAddress=zookeeper://127.0.0.1:2181 # registryAddress=redis://127.0.0.1:6379 # 集群名称 @@ -14,7 +14,7 @@ bindIp=127.0.0.1 configs.zk.client=zkclient # ------ 这个是Admin存储数据的地方,也可以和JobQueue的地址一样 ------ -configs.jdbc.url=jdbc:mysql://127.0.0.1:5306/lts?useUnicode=true&characterEncoding=UTF-8 +configs.jdbc.url=jdbc:mysql://127.0.0.1:3306/lts?useUnicode=true&characterEncoding=UTF-8 configs.jdbc.username=root configs.jdbc.password=111111 diff --git a/lts/lts-center/lts-admin/config/lts-monitor.cfg b/lts/lts-center/lts-admin/config/lts-monitor.cfg index 8e20a38..a83d4d0 100644 --- a/lts/lts-center/lts-admin/config/lts-monitor.cfg +++ b/lts/lts-center/lts-admin/config/lts-monitor.cfg @@ -1,6 +1,6 @@ # 注册中心地址,可以是zk,也可以是redis -registryAddress=zookeeper://127.0.0.1:5181 +registryAddress=zookeeper://127.0.0.1:2181 # registryAddress=redis://127.0.0.1:6379 # 集群名称 @@ -17,7 +17,7 @@ configs.zk.client=zkclient configs.job.queue=mysql # ------ 1. 如果是mysql作为任务队列 ------ -configs.jdbc.url=jdbc:mysql://127.0.0.1:5306/lts?useUnicode=true&characterEncoding=UTF-8 +configs.jdbc.url=jdbc:mysql://127.0.0.1:3306/lts?useUnicode=true&characterEncoding=UTF-8 configs.jdbc.username=root configs.jdbc.password=111111 @@ -32,4 +32,4 @@ jdbc.datasource.provider=mysql # 使用 可选值 fastjson, jackson # configs.lts.json=fastjson -bindIp=192.168.3.232 +bindIp=192.168.0.117 diff --git a/lts/lts-center/lts-jobtracker/config/application.yml b/lts/lts-center/lts-jobtracker/config/application.yml index 8d8358c..d2d6b1e 100644 --- a/lts/lts-center/lts-jobtracker/config/application.yml +++ b/lts/lts-center/lts-jobtracker/config/application.yml @@ -2,13 +2,13 @@ lts: jobtracker: cluster-name: default_cluster listen-port: 35001 - registry-address: zookeeper://127.0.0.1:5181 + registry-address: zookeeper://127.0.0.1:2181 configs: job: logger: mysql queue: mysql jdbc: - url: jdbc:mysql://127.0.0.1:5306/lts?useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://127.0.0.1:3306/lts?useUnicode=true&characterEncoding=UTF-8 username: root password: 111111 - bind-ip: 192.168.3.232 + bind-ip: 192.168.0.117 diff --git a/zookeeper/3.4.10/Dockerfile b/zookeeper/3.4.10/Dockerfile index b16ddce..2ab243b 100644 --- a/zookeeper/3.4.10/Dockerfile +++ b/zookeeper/3.4.10/Dockerfile @@ -47,5 +47,6 @@ ENV PATH=$PATH:/$DISTRO_NAME/bin \ ZOOCFGDIR=$ZOO_CONF_DIR COPY docker-entrypoint.sh / +RUN chmod +x /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["zkServer.sh", "start-foreground"]