Practice background: Develop distributed services based on Wildfly, including Web services, DBA (data access) services, and other business services, all in a distributed way for development and deployment.
Practice 1: Distributed Services (server-side role) configuration
- This practice uses two machine deployment services, one deployment Web service (client role), one for other services such as DBA (server side role), TCP service, etc.
- Both machines use Wildfly9 as a service container.
- Web server: 192.168.50.253 (Eclipse development environment on this machine), DBA server 192.168.50.123
- Run Add-user.sh/add-user.bat on the 50.123 machine, and the role is Application-realm, here the user is Ejbuser, the password is 123, the purpose of setting this account is when the remote client ( The wildefly that the web is in) needs to provide the connection's account and password when accessing the service, and without the use of distributed services, all services will not be added to a single machine.
- Configuration database, this example installs the MySQL service on 50.123 machines, and adds a test database and a data table to the database, the database used in this example:
- Configure the Standalone.xml of the 50.123 machine to increase the MySQL database driver and data source:
-
- Under the <datasources> node in <subsystem xmlns= "urn:jboss:domain:datasources:3.0" >, add the following configuration:
<DataSourceJTA= "true"Jndi-name= "Java:/xbomdtds"Pool-name= "Xbomdtds"enabled= "true"USE-CCM= "true"> <Connection-url>Jdbc:mysql://192.168.50.123:3306/xbomdt</Connection-url> <Driver-class>Com.mysql.jdbc.Driver</Driver-class> <Driver>Mysql</Driver> <Pool> <min-pool-size>5</min-pool-size> <initial-pool-size>5</initial-pool-size> <max-pool-size>10</max-pool-size> </Pool> <Security> <User-name>Mysql</User-name> <Password>Mysql</Password> </Security> <Validation> <Valid-connection-checkerClass-name= "Org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/> <background-validation>True</background-validation> <Exception-sorterClass-name= "Org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/> </Validation> </DataSource>
- Add the following configuration under the <drivers> node in <subsystem xmlns= "urn:jboss:domain:datasources:3.0" >:
< driver name Span style= "COLOR: #0000ff" >= "MySQL" module = "Jdbc.mysql" > < xa-datasource-class > Com.mysql.jdbc.jdbc2.optional.MysqlXADatasource </ xa-datasource-class > </ driver >
- See if the wildfly on machine 50.123 has a MySQL JDBC module, and the directory address is: Wildfly9\modules\system\layers\base\jdbc\mysql\main
- If you have this directory and you have Module.xml and Mysql-connector*.jar in the directory, pass this step.
- If there are no related directories and files, create this directory and add Module.xml to this directory with the following content:
<?XML version= "1.0" encoding= "UTF-8"?><Modulexmlns= "urn:jboss:module:1.3"name= "Jdbc.mysql"> <Resources> <Resource-rootPath= "Mysql-connector-java-5.1.38.jar"/> </Resources> <Dependencies> <Modulename= "Javax.api"/> <Modulename= "Javax.transaction.api"/> </Dependencies></Module>
- Note that resource-root path in the above configuration is the Mysql-connector*.jar file name in the main directory, and here I am
Mysql-connector-java-5.1.38.jar.
- Modify the <interfaces> node, configured as follows:
<interfaces> <interface name= "Management" > <inet-address value= "${ jboss.bind.address.management:0.0.0.0} "/> </interface> <interface name=" public "> <inet-address value= "${jboss.bind.address:0.0.0.0}"/> </interface> <interface name= " Unsecure "> <inet-address value=" ${jboss.bind.address.unsecure:0.0.0.0} "/> </interface> </interfaces>
Note: This configuration is intended to use IP addresses to access the service, which can only be accessed using localhost or 127.0.0.1 before configuration.
- Run the standalone.bat/standalone.sh in the wildfly/bin/directory to see if there is an error output, there is no exception in this example, and the last four rows output as:
2016-12-13 14:43:06,894 INFO [Org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) wflyds0013:started FileS Ystemdeploymentservice fordirectory/home/pacs/wildfly/standalone/deployments2016-12-13 14:43:07,133 INFO [org.jboss.as] (ControllerBootThread) Wflysrv0060:http Management interface Listening onhttp://0.0.0.0:9990/Management2016-12-13 14:43:07,134 INFO [org.jboss.as] (ControllerBootThread) Wflysrv0051:admin Console Listening onHttp://0.0.0.0:9990 2016 -12-13 14:43:07,134 INFO [org.jboss.as] (ControllerBootThread) Wflysrv0025:wildfly full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 4207ms-started 209 of 385 Services ( The services are lazy, passive or on-demand)
- At this point, the server configuration on the 50.123 machine is complete.
Wildfly Practice 1--Distributed service configuration (service side corner)