docker启动jira,连不上数据库,heidisql可以正常连接,麻烦看下


jira的日志报错:

2022-04-29 03:23:02,838 http-nio-8080-exec-2 ERROR anonymous 203x18x1 qlj9om 172.17.0.1 /secure/SetupDatabase!connectionCheck.jspa [c.a.config.bootstrap.DefaultAtlassianBootstrapManager] Could not successfully test your database:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:339)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2286)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:795)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44)
… 3 filtered
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)

你docker搭建的命令是什么呀?

我按照课程的PPT操作的:
部署数据库
docker run -d -p 3306:3306 --name mysql_jira --restart always --privileged=true -u root -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7

配置mysql数据库

连接数据库

docker run -it --link mysql_jira:mysql --rm mysql sh -c ‘exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"’

创建数据库

create database jira default character set utf8 collate utf8_bin;

创建用户

create user jira@% identified by ‘jira’;grant all on . to jira@% with grant option;

添加用户

alter user ‘jira’@’%’ identified with mysql_native_password by ‘jira’;

修改mysql事物隔离级别

set global transaction isolation level read committed;
set session transaction isolation level read committed;

启动jira实例
docker run -d -p 8082:8080 --name jira --restart always --privileged=true -u root cptactionhank/atlassian-jira-software:7.11.1

docker 搭建jira时 启动的数据库是不能被其他应用使用的,必须要是干净未使用过的,建议重新删掉jira容器和mysql容器,然后重新启动一个mysql容器,启动后 紧跟着就启动 jira容器,不要用navicat或者heidisql去连接,这样会污染这个干净的新数据库

我重新删掉了jira和mysql容器,重新试了一次,还是相同的报错

2022-04-29 08:44:26,555 http-nio-8080-exec-24 ERROR anonymous 524x16x1 1t6rfjk 172.17.0.1 /secure/SetupDatabase!connectionCheck.jspa [c.a.config.bootstrap.DefaultAtlassianBootstrapManager] Could not successfully test your database:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:339)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2286)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:795)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44)
… 3 filtered

先用jira内置的数据库吧,这个方法

关闭