【发布时间】:2017-10-31 04:06:58
【问题描述】:
我在 Windows 10 上使用 Docker 创建一个 pentaho 和 mysql 映像,该映像将作为容器在我使用 docker network create 定义的网络上运行。
目的是(作为第一步)我将运行一个带有 pan.sh 的 .KTR 文件,该文件将从 .csv 文件中读取数据库连接参数并将它们放入环境中;
Get the DB connection parameters
接下来,.KTR 使用上述环境参数检查数据库是否存在;
问题是当我使用 docker-compose “启动”我的项目时,第二步失败并出现未找到驱动程序的问题。我已将所需的驱动程序放在 pentaho 容器的 lib 目录中,但我猜这不正确?
最终,目的是进行转换,从 OpenEdge 数据库读取的数据通过 pentaho 中的一系列步骤处理并写入 mysql 数据库。
这是支持文件; Dockerfile;
FROM java:8-jre
MAINTAINER M Beynon
# Set required environment vars
ENV PDI_RELEASE=7.1 \
PDI_VERSION=7.1.0.0-12 \
CARTE_PORT=8181 \
PENTAHO_JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 \
PENTAHO_HOME=/home/pentaho
# Create user
RUN mkdir ${PENTAHO_HOME} && \
groupadd -r pentaho && \
useradd -s /bin/bash -d ${PENTAHO_HOME} -r -g pentaho pentaho && \
chown pentaho:pentaho ${PENTAHO_HOME}
# Add files
RUN mkdir $PENTAHO_HOME/docker-entrypoint.d
COPY docker-entrypoint.sh $PENTAHO_HOME/scripts/
RUN chown -R pentaho:pentaho $PENTAHO_HOME
RUN apt-get update && apt-get install -y libwebkitgtk-1.0-0
RUN apt-get update && apt-get install -y dos2unix
RUN dos2unix $PENTAHO_HOME/scripts/docker-entrypoint.sh && apt-get --purge remove -y dos2unix && rm -rf /var/lib/apt/lists/*
# Switch to the pentaho user
USER pentaho
# Download PDI
RUN /usr/bin/wget \
--progress=dot:giga \
http://downloads.sourceforge.net/project/pentaho/Data%20Integration/${PDI_RELEASE}/pdi-ce-${PDI_VERSION}.zip \
-O /tmp/pdi-ce-${PDI_VERSION}.zip && \
/usr/bin/unzip -q /tmp/pdi-ce-${PDI_VERSION}.zip -d $PENTAHO_HOME && \
rm /tmp/pdi-ce-${PDI_VERSION}.zip
ENV KETTLE_HOME=$PENTAHO_HOME/data-integration \
PATH=$KETTLE_HOME:$PATH
WORKDIR $KETTLE_HOME
ENTRYPOINT ["../scripts/docker-entrypoint.sh"]
入口点;
#!/bin/bash
# based on https://github.com/aloysius-lim/docker-pentaho-di/blob/master/docker/Dockerfile
#exit script if any command fails (non-zero value)
set -e
cd resources
cp mysql-connector-java-5.1.42-bin.jar ../lib/
cp PROGRESS_DATADIRECT_JDBC_OE_ALL.jar ../lib
cd ../
echo 'Drivers copied!'
echo ''
echo 'Running transformation!'
#run a transformation (get db credentials)
./pan.sh -file=resources/Read-DBs.ktr
#run a transformation (does the db exist)
./pan.sh -file=resources/GoldBi-Exists.ktr
#redirect input variables
exec "$@"
Docker 组合文件;
version: "2"
services:
db:
image: mysql:latest
networks:
- my-pdi-network
environment:
- MYSQL_ROOT_PASSWORD=tbitter
- MYSQL_DATABASE=mysql-db
ports:
- "3307:3306"
volumes:
- ./goldbi:/var/lib/mysql
pdi:
image: my-pdi-image:latest
networks:
- my-pdi-network
volumes:
- C:\Docker-Pentaho\resource:/home/pentaho/data-integration/resources
networks:
my-pdi-network:
The error coming from pentaho;
2017/05/30 15:28:56 - Table exists.0 - Error occurred while trying to connect to the database
2017/05/30 15:28:56 - Table exists.0 -
2017/05/30 15:28:56 - Table exists.0 - Error connecting to database: (using class org.gjt.mm.mysql.Driver)
2017/05/30 15:28:56 - Table exists.0 - Communications link failure
2017/05/30 15:28:56 - Table exists.0 -
2017/05/30 15:28:56 - Table exists.0 - The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
非常感谢。
附:有谁知道如何防止 build 重新构建所有内容,即使它只是对 dockerfile 或入口点文件的微小更改?
【问题讨论】:
-
尝试将您的资源 (C:\Docker-Pentaho\resource) 移动到您的 Windows 用户主目录 (C:/Users...),因为可能存在有关挂载的问题。另外,你的 mysql 默认监听 3306 端口,只在 docker-compose 中改变它,没有意义(它仍然会监听 3306)
-
感谢您抽出宝贵时间回答我的问题,但我想我现在有了答案。
标签: mysql docker jdbc pentaho drivers