问题
I have been trying to access a mysql in a jboss eap application from a wordpress application in Openshift environment. I followed this blog post on this subject and prepared a php file on the wordpress server with $dbhost, $dbuser, $password point to the database in my jbosseap app. Unfortunately, it did not work. Each time I got a "no route to host" error. However, if I point the database to that in the wordpress app, i.e. local database, it worked perfectly.
I am wondering if there must be additional step(s) to execute when the php script and the database are in different Openshift applications?
回答1:
I've ha same problem following this guide https://blog.openshift.com/sharing-database-across-applications/,
the solution is writen even there:
Step 1: Create an application with a database
We will create a scalable PHP application using a MySQL database cartridge. 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.
Here http://www.hfaber.com/post/135256827109/openshift-sharing-database-across-applications
回答2:
After talking to some people in Redhat, I concluded that it is not possible to share database accesses between different applications in Openshift environment. You may see some technical documents which show how to do it, but that is for Openshift/Redhat internet environments, not for regular customers of Openshift. At the end, I used webservices to provide sharing of DB accesses between applications.
The investigation was in August 2015. Hope it will or has changed
来源:https://stackoverflow.com/questions/31813140/in-openshift-environment-how-to-access-a-database-in-a-different-application