简体   繁体   English

尝试将NodeJS中的1个openshift应用程序与另一个openshift应用程序的MySQL连接时出现错误EHOSTUNREACH

[英]I get an error EHOSTUNREACH when trying to connect 1 openshift application in NodeJS with MySQL of another openshift application

I have 2 applications on OpenShift: 1 with MySQL, and 1 with NodeJS that is going to connect to MySQL of the other app. 我在OpenShift上有2个应用程序:1个使用MySQL,1个使用NodeJS,它将连接到另一个应用程序的MySQL。

I've seen examples but none of them seem to work, these are the steps I'm taking: 我看过示例,但似乎都没有用,这些是我正在采取的步骤:

rhc ssh -a mydbappname rhc ssh -a mydbappname

then i get the enviroment variables with env | 然后我得到env的环境变量| grep MYSQL grep MYSQL

I get something like: 我得到类似的东西:

OPENSHIFT_MYSQL_DB_HOST=127.XX.XXX.X OPENSHIFT_MYSQL_DB_HOST = 127.XX.XXX.X

OPENSHIFT_MYSQL_DB_PORT=3306 OPENSHIFT_MYSQL_DB_PORT = 3306

After that i try to use those on the other app, but it always throws EHOSTUNREACH, no matter if i create the OPENSHIFT_MYSQL_DB env variables on the Node app and use them, or if i put it directly on the code. 之后,无论我是否在Node应用程序上创建OPENSHIFT_MYSQL_DB env变量并使用它们,或者是否将其直接放在代码上,我都会尝试在其他应用程序上使用它们,但它始终抛出EHOSTUNREACH。

I have seen in other parts that the OPENSHIFT_MYSQL_DB_HOST is something like 54d10be2503e36378e0002db-mydbappname.apps.rhcloud.com. 我在其他部分看到OPENSHIFT_MYSQL_DB_HOST类似于54d10be2503e36378e0002db-mydbappname.apps.rhcloud.com。

If I use the port-forward and use 127.0.0.1 with the local port selected for mysql, and start the NodeJS application locally it works, only when i upload the changes to Openshift it fails 如果我使用port-forward并使用为MySQL选择的本地端口使用127.0.0.1,并在本地启动NodeJS应用程序,则它只能在我将更改上传到Openshift时起作用

In this article: 在这篇文章中:
https://blog.openshift.com/sharing-database-across-applications/ https://blog.openshift.com/sharing-database-across-applications/
You can read: 你可以阅读:
"Step 1: “第1步:
Create an application with a database 使用数据库创建应用程序
We will create a scalable PHP application using a MySQL database cartridge. 我们将使用MySQL数据库盒创建可扩展的PHP应用程序。 In non-scalable applications, the database will be installed in the same gear as the application. 在不可伸缩的应用程序中,数据库将以与应用程序相同的方式安装。 In this case we want the database to be accessible from other gears. 在这种情况下,我们希望可以从其他设备访问数据库。 So creating a scalable application ensures that the database runs in its own gear that can be accessed from other gears." 因此,创建可扩展的应用程序可确保数据库以自己的方式运行,并且可以从其他方式进行访问。”

So maybe this is the problem, check if this application you created is scalable. 因此,也许这就是问题所在,请检查您创建的该应用程序是否可扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM