通过Hibernate

时间:2017-02-23 10:42:11

标签: mysql tomcat docker web-applications

我试图使用Docker将使用Hibernate,XAMPP for Apache tomcat和mysql服务器的Windows应用程序移植到Linux上。

在我完成以下步骤后,我的web.app的第一个功能是登录/注册表单:在Windows上一切正常,但是容器有几十分钟的延迟..有时候有还有500个http错误!!

  1. docker run -d --name mysql-phpmyadmin -p 127.0.0.1:8686:80 -p 127.0.0.1:3306:3306 grzesiekb/mysql-phpmyadmin

  2. docker run -d -p 8484:8080 -p 8007:8009 --name tomcat8-linked --link mysql-phpmyadmin:mysqlphp tomcat:8.0-jre8然后在webapps /文件夹下部署我的warfile

  3. 在我的hibernate.cfg.xml中,您可以看到它here(我有问题以可查看的方式粘贴它):)

  4. 在我的mysql容器my.cnf中有:

  5.   

    [客户]       port = 3306       socket = /var/run/mysqld/mysqld.sock

    # Here is entries for some specific programs
    # The following values assume you have at least 32M ram
    
    # This was formally known as [safe_mysqld]. Both versions are currently parsed.
    [mysqld_safe]
    socket          = /var/run/mysqld/mysqld.sock
    nice            = 0
    
    [mysqld]
    #
    # * Basic Settings
    #
    user            = mysql
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    port            = 3306
    basedir         = /usr
    datadir         = /var/lib/mysql
    tmpdir          = /tmp
    lc-messages-dir = /usr/share/mysql
    skip-external-locking
    #
    # Instead of skip-networking the default is now to listen only on
    # localhost which is more compatible and is not less secure.
    bind-address = 0.0.0.0
    #
    # * Fine Tuning
    #
    key_buffer              = 16M
    max_allowed_packet      = 16M
    thread_stack            = 192K
    thread_cache_size       = 8
    # This replaces the startup script and checks MyISAM tables if needed
    # the first time they are touched
    myisam-recover         = BACKUP
    #max_connections        = 100
    #table_cache            = 64
    #thread_concurrency     = 10
    #
    # * Query Cache Configuration
    #
    query_cache_limit       = 1M
    query_cache_size        = 16M
    #
    # * Logging and Replication
    #
    # Both location gets rotated by the cronjob.
    # Be aware that this log type is a performance killer.
    # As of 5.1 you can enable the log at runtime!
    general_log_file        = /var/log/mysql/mysql.log
    general_log             = 1
    #
    # Error log - should be very few entries.
    #
    log_error = /var/log/mysql/error.log
    #
    # Here you can see queries with especially long duration
    #slow_query_log_file = /var/log/mysql/mysql-slow.log
    #slow_query_log      = 1
    #long_query_time = 2
    #log_queries_not_using_indexes
    #
    # The following can be used as easy to replay backup logs or for replication.
    # note: if you are setting up a replication slave, see README.Debian about
    #       other settings you may need to change.
    #server-id              = 1
    #log_bin                        = /var/log/mysql/mysql-bin.log
    expire_logs_days        = 10
    max_binlog_size         = 100M
    #binlog_do_db           = include_database_name
    #binlog_ignore_db       = include_database_name
    
    # * InnoDB
    #
    # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
    # Read the manual for more InnoDB related options. There are many!
    #
    # * Security Features
    #
    # Read the manual, too, if you want chroot!
    # chroot = /var/lib/mysql/
    #
    # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
    #
    # ssl-ca=/etc/mysql/cacert.pem
    # ssl-cert=/etc/mysql/server-cert.pem
    # ssl-key=/etc/mysql/server-key.pem
    
    
    [mysqldump]
    quick
    quote-names
    max_allowed_packet      = 16M
    
    [mysql]
    #no-auto-rehash # faster start of mysql but no tab completition
    
    [isamchk]
    key_buffer              = 16M
    
    #
    # * IMPORTANT: Additional settings that can override those from this file!
    #   The files must end with '.cnf', otherwise they'll be ignored.
    #
    !includedir /etc/mysql/conf.d/
    
    1. 默认情况下,这个mysql容器只允许来自localhost的连接:为了允许来自任何地方的连接,我已经完成了:

      上授予所有权限。以及' root' @'%'通过'密码识别' WITH GRANT OPTION;  FLUSH PRIVILEGES;

    2. 然后我通过phpmyadmin

      导入了我的dql转储

      描述您收到的结果:

      巨大的延迟,与我不知道哪个问题有关,并且以随机的方式无法连接到mysql。没有日志。我的老师说这可能是与Docker网络相关的DNS问题。

      描述您期望的结果:

      立即连接到数据库,就像使用XAMPP的Windows

      一样

1 个答案:

答案 0 :(得分:1)

您应该尽量使您的设置成为标准,以避免因非标准做法而导致的错误。