如何在docker环境中使用Mysql启动Aerogear统一推送服务器

时间:2015-07-14 20:53:12

标签: hibernate jdbc docker wildfly aerogear

我正在努力在具有mysql数据库的docker环境中启动aerogear统一推送服务器。我正在关注Aerogear documentation here

所以我已经启动了一个mysql docker容器

docker run --name aerogearsql -e MYSQL_ROOT_PASSWORD=sqlpwd -d mysql

我已经应用了aerogear文档中的内容

docker exec -ti aerogearsql -u root -p
mysql> create database unifiedpush default character set = "UTF8" default collate = "utf8_general_ci";
mysql> create user 'unifiedpush'@'localhost' identified by 'unifiedpush';
mysql> GRANT SELECT,INSERT,UPDATE,ALTER,DELETE,CREATE,DROP ON unifiedpush.* TO 'unifiedpush'@'localhost';

然后我使用以下docker文件准备了一个docker镜像,应用了aerogear文档中的内容。这是docker文件

FROM jboss/wildfly
MAINTAINER yves.nicolas@dynamease.com


ENV AEROGEAR_VERSION 1.0.3
ENV AEROGEAR_FILES /usr/local/share/aerogear
ENV AEROGEAR_DIR $AEROGEAR_FILES/aerogear-unifiedpush-server-$AEROGEAR_VERSION
ENV JBOSS_HOME /opt/jboss/wildfly


# Run everything below as root user
USER root

# Set the Java environment variable
ENV JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk

RUN mkdir -p $AEROGEAR_FILES && chmod -R ugo+rwx $AEROGEAR_FILES

# Install Maven it will be needed for my SQL
RUN curl -L -o /etc/yum.repos.d/epel-apache-maven.repo http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo \
    && yum -y install apache-maven && yum clean all

# Switch back to jboss user
USER jboss


# Get Aerogear version
WORKDIR $AEROGEAR_FILES

RUN curl -L -o aerogear-unifiedpush-server-$AEROGEAR_VERSION-dist.tar.gz https://github.com/aerogear/aerogear-unifiedpush-server/releases/download/$AEROGEAR_VERSION/aerogear-unifiedpush-server
-$AEROGEAR_VERSION-dist.tar.gz \
    && tar -xvf aerogear-unifiedpush-server-$AEROGEAR_VERSION-dist.tar.gz  \
    && cp -r aerogear-unifiedpush-server-$AEROGEAR_VERSION/databases/src/main/resources/modules/com $JBOSS_HOME/modules/


# Do Sql Dependency maven
RUN mvn dependency:copy -Dartifact=mysql:mysql-connector-java:5.1.18 -DoutputDirectory=$JBOSS_HOME/modules/com/mysql/jdbc/main/

# can remove maven at this stage
USER root
RUN yum -y erase apache-maven && yum clean all

# Switch back to jboss user
USER jboss


WORKDIR $JBOSS_HOME

VOLUME $JBOSS_HOME

EXPOSE 8443

CMD ["/opt/jboss/wildfly/bin/standalone.sh","-b","0.0.0.0"]

从这张图片中,我已经启动了一个链接到mysql的容器

docker run  --name essaipush --link aerogearsql:mysql -v /home/yves:/host -p 8443:8443 yvnicolas/aerogear

Wildfly服务器启动良好,尚未部署任何内容 使用docker exec,然后我应用了mysql cli脚本

$ ./path/to/SERVER_HOME/bin/jboss-cli.sh --file=/path/to/mysql-database-config-wildfly.cli

我更新了mysql-database-config-wildfly.cli后,使用mysql而不是localhost作为数据库访问主机。

仍在使用docker exec,我最终将2个war文件移动到独立/部署目录中,但这并不好,因为它似乎找不到数据库。

以下是引发的异常的一些副本。由于我不熟悉Hibernate和Jboss,我无法判断根本原因是来自hibernate.dialect未设置还是来自2个容器之间的通信问题。

20:07:47,524 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "unifiedpush-server-wildfly.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"unifiedpush-server-wildfly.war#unifiedpush-default\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"unifiedpush-server-wildfly.war#unifiedpush-default\": org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
    Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set"}}

aused by: java.sql.SQLException: Access denied for user 'unifiedpush'@'172.17.0.33' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)
    at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4113)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1308)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2336)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:312)

0 个答案:

没有答案