2017-05-30 78 views
1

我在Windows 10上使用Docker创建pentaho和mysql映像,该映像将作为我使用docker网络创建定义的网络上的容器运行。我的意图是(作为第一步),我将运行一个带有pan.sh的.KTR文件,它将从一个.csv文件读取数据库连接参数,并将它们放入环境中;docker pentaho mysql驱动程序问题

Get the DB connection parameters

接下来的第二.KTR检查,看是否存在DB使用上述环境PARAMS;

Check DB exists

问题是,当我为“正旋”我和泊坞窗,撰写项目,第二步失败,并没有发现问题的驱动器。我在pentaho容器的lib目录中放置了我需要的驱动程序,但我猜这是不正确的?

最终,其目的在于进行转换,其中通过pentaho中的一系列步骤处理从OpenEdge DB读取的数据,并将其写入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 "[email protected]" 

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. 

非常感谢。

P.S.有谁知道如何防止重建所有内容,即使它只是对dockerfile或入口点文件的小改动?

+0

尝试将您的资源(C:\ Docker-Pentaho \ resource)移动到您的Windows用户主目录(C:/ Users ...),因为有关可能的挂载问题。另外,你的mysql默认侦听3306端口,只在docker-compose中改变它,没有任何意义(它仍然会听取3306) – Robert

+1

感谢您花时间回复我的问题,但我想我有答案现在。 –

回答

0

我似乎找到了解决办法; 有两个问题。第一个似乎是在第一个转换中设置的ENV变量没有在第二个转换中使用。第二个是在第二个转换中主机名是错误的(DB-Exists)。它应该是'db',它是在docker-compose文件中为容器指定的名称。由于包含的内容都是在我指定的自定义网络上运行的,因此它们可以通过服务名称自动'对话'...反向DNS?