Right way to export\transfer WildFly 9 server options to other PC

99封情书 提交于 2019-12-06 07:21:47

问题


I need to export\transfer options (such as DataSource to MySQL) to other PC\server. How to do it correctly?

I had tried to copy and rename standalone.xml and run it on other PC by following command:

./standalone.sh --server-config=standalone-(full)-myProject.xml

Is it right way?

And next problem - how export installed module (in WildFly) for MySQL correctly? I installed it like this (as module) at my machine http://hpehl.info/jdbc-driver-setup.html


回答1:


I would strongly encourage you to use the jboss-cli to run this instead. Copying the files will work but I would argue that it's better to have a repeatable process.

To add a datasource, you'd run the following. Since you're using WildFly 9, it can be a bit simpler. Put the following commands in a file - for example, db_setup.txt. Then run $WILDFLY_HOME/bin/jboss-cli.sh --file=db_setup.txt. The file will contain something like the following:

embed-server --std-out=echo --server-config=standalone.xml

batch

module add --name=com.mysql.driver --resources=/path/to/mysql-connector-java-5.1.33.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=mysql:add(driver-name="mysql",driver-module-name="com.mysql.driver",driver-class-name=com.mysql.jdbc.Driver)
/subsystem=datasources/data-source=myPool/:add(connection-url=jdbc:mysql://127.0.0.1:3306/dbName,driver-name=mysql,jndi-name=java:/jdbc/dbName,password=password,user-name=user)

WARNING - I have not fully tested these commands so they may require a bit of tweaking. But the concepts are there.

The one issue you'll have is that, during testing, the jboss-cli.sh command will just exit if there is an error. You may want a file to remove these too:

/subsystem=datasources/data-source=myPool/:remove
/subsystem=datasources/jdbc-driver=my:remove
module remove --name=com.mysql.driver


来源:https://stackoverflow.com/questions/37459066/right-way-to-export-transfer-wildfly-9-server-options-to-other-pc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!