问题
How can I to set enabled = "true" on datasource of standalone.xml
of Openshift v3 Wildfly container like below.
<datasource jndi-name="java:jboss/datasources/MySQLDS" enabled="true" use-java-context="true" pool-name="MySQLDS" use-ccm="true">
I put the OPENSHIFT_MYSQL_ENABLED
environment variable to "true" but nothing happended.
The answer reference site is the below URL:
https://developer.jboss.org/wiki/DataserviceBuilderOnOpenShiftV3Online
回答1:
I was dealing with the same problem: the environment variable OPENSHIFT_MYSQL_ENABLED
is being ignored by variable substitution process, so I had to activate the data source with my bare hands, and that's what I did:
(I'm going to assume you have the OC tools installed on your system)
- log into OC:
oc login
- list all pods and find the WildFly instance:
oc get pods
- enter the container's SSH console:
oc rsh <<pod-name>>
- edit the
standalone.xml
filevi /wildfly/standalone/configuration/standalone.xml
- search for the word "datasource" by typing
/datasource
on vi editor then press enter - find the attribute "enabled" of your data source and update its value from
false
totrue
(to do so, pressi
to go to vi insert mode) - save the file by pressing
esc
then:x
I'm using OpenShift community edition, so to restart the container is always a hassle: it takes a very long time to find resources available (like memory and CPU) and start the server again, however, you won't have your data source enabled unless you restart the server. In this regard, to do so, you don't need to restart the container, just reload WildFly by using jboss-cli.sh
command line tools. (I didn't try to kill the process and start it again, so if you did try, please comment if it worked).
The following steps should be executed on container's terminal using oc rsh <<podname>>
or using the terminal on web console.
- Enter jboss-cli using the command
/wildfly/bin/jboss-cli.sh
- Type
connect
to log into the WildFly console, you'll be prompted for user and password. If you do not have credentials, exit this console and create a management user by executing the script/wildfly/bin/add-user.sh
- Check your data source properties by typing
data-source read-resource --name=<<YOUR_DATASOURCE_NAME>> --include-runtime=true --recursive=true
and follow up on the "enabled" property. - If your data source is disabled, you should enable it by entering the command
data-source enable --name=<<YOUR_DATASOURCE_NAME>>
- reload WildFly by entering the
reload
command. Once WildFly reboots you'll need to access jboss-cli.sh and log into the console again. - test your data source connection using the command
data-source test-connection-in-pool --name=<<YOUR_DATASOURCE_NAME>>
. If the command output wastrue
your data source is up and running.
Openshift v3 is based on docker containers, therefore I'm afraid if you do restart the container, this configuration will probably be lost. The most appropriated solution would be to include this actions on docker's script, which I don't know yet how it works along with Openshift platform.
Hope it helps!
来源:https://stackoverflow.com/questions/43912409/what-is-openshift-mysql-enabled-environment-variable-in-openshift-v3