gpt4 book ai didi

mysql - 尝试将 Jira(docker)连接到 Mysql(非 docker)5.6.44 但连接被拒绝

转载 作者:行者123 更新时间:2023-11-29 05:01:52 27 4
gpt4 key购买 nike

我正在尝试在 CentOS 7 虚拟机上配置 jira。我使用 docker-compose 成功地启动了 Jira 的 docker 镜像:

 jira:
image: 'cptactionhank/atlassian-jira-software:latest'
container_name: jira
restart: unless-stopped
healthcheck:
disable: true
volumes:
- '/var/atlassian/jira:/var/atlassian/jira'

我还在我的虚拟机上安装了 mySQL(不使用 docker),同时遵循此处描述的安装过程: https://confluence.atlassian.com/adminjiraserver/connecting-jira-applications-to-mysql-5-6-938846854.html

包括:

CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'jiradbuser'@'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON jiradb.* TO 'jiradbuser'@'%' IDENTIFIED BY 'secret';
flush privileges;

MySQL 可以在我的本地主机端口 3306 上访问(命令 telnet 0.0.0.0 3306 很好地回答了我)

我还从 MySQL 下载了 5.1.38 connector-j,因为我的/var/atlassian/jira 中没有 lib 文件夹,所以我使用 mkdir 创建了它,并将 jar 解压到其中。

我重新启动 Jira:

docker-compose stop jira
docker-compose rm jira
docker-compose start jira

现在,我在浏览器上转到 jira 软件地址,在数据库设置时,我输入了以下信息:

Database Connection: My Own Database 
Database Type: MySQL 5.6
Hostname: localhost
Port: 3306
Database: jiradb
Username: jiradbuser
Password: secret

当我点击“测试连接”时,它不起作用。答案是:

Error connecting to database

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.

Connection refused (Connection refused)

点击“测试连接”时jira的日志如下:

==> atlassian-jira.log <==
2019-07-19 14:42:37,906 http-nio-8080-exec-21 ERROR anonymous 882x13x1 b45eq1 10.107.135.18,172.18.0.3 /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.<init>(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.<init>(ConnectionImpl.java:795)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
... 3 filtered
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.getTestDatabaseConnection(DefaultAtlassianBootstrapManager.java:347)
at com.atlassian.jira.config.database.JdbcDatasource.getConnection(JdbcDatasource.java:211)
at com.atlassian.jira.config.database.DatabaseConfig.testConnection(DatabaseConfig.java:88)
at com.atlassian.jira.web.action.setup.SetupDatabase.testConnection(SetupDatabase.java:230)
at com.atlassian.jira.web.action.setup.SetupDatabase.doValidation(SetupDatabase.java:194)
at com.atlassian.jira.web.action.setup.SetupDatabase.doConnectionCheck(SetupDatabase.java:126)
... 3 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:70)
at webwork.util.InjectionUtils.invoke(InjectionUtils.java:56)
... 2 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
... 49 filtered
at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
... 1 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
... 31 filtered
at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
... 24 filtered
at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
... 25 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:298)
... 175 more

有什么我做的不对吗?

提前谢谢你。

雨果

最佳答案

Mysql 数据库在主机(非 docker)的 3306 端口上运行。

当 Jira 在容器内运行时。默认容器在 bridge 中运行网络模式,其中容器网络不同于主机网络。因此,容器内的本地主机与主机上的本地主机不同。

在这里你可以做两件事:

  • 在您的 Jira 容器中使用 private/public-ip:3306 引用 mysql 数据库

  • host 中运行 Jira docker 容器网络模式,使容器内的本地主机与主机上的本地主机相同。因为在这种模式下容器使用主机的网络。
 jira:
image: 'cptactionhank/atlassian-jira-software:latest'
container_name: jira
restart: unless-stopped
healthcheck:
disable: true
volumes:
- '/var/atlassian/jira:/var/atlassian/jira'
network_mode: "host"

注意 network_mode: "host" 选项将告诉 docker 容器使用 host网络模式。

关于mysql - 尝试将 Jira(docker)连接到 Mysql(非 docker)5.6.44 但连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57115226/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com