JBOSS data source configuration and using Jndi calls

Source: Internet
Author: User
Tags in domain jboss

Scenario Analysis:

A day of the system's database maintenance party requirements for DG storage capacity disaster drill, to the production of RAC Library to simulate the outage and transfer to the DG Standby, because it is failover and not switchover walkthrough, so the period is not open to Apache access, demand service startup time is tighter .

The database switchover resulted in IP changes, which resulted in the system running on the AP having to reconfigure the database connection, based on the current mechanism required to perform the following steps:

a). Stop the Service group

b). Remove the Service pack

c). Source Service Pack Replacement configuration file (This also requires that the current version of the service pack is backed up intact)

d). Re-upload the service pack

e). Distribute to groups and finally launch groups

f). When the source library is back to normal, it comes back again T t

This process is obviously more expensive than the DG library to IP, although the DG to change the corresponding monitoring and other operations, but it is understood that the command line is the batch process to reduce the workload each time.

Thus, the problem of how to recover the service quickly in the event of DB exception is extended.

Analysis:

1. Time spent is mainly used in the Redeployment Service pack, how to omit this step, simply want to have two scenarios

a). Overriding scenarios for initializing connection pooling using a data source

b). Using a container-managed data source, the service pack requests through Jndi

Where a scheme is rejected, one is not universal, the second rewrite the words behind the problem and rewrite the person responsible = =

Therefore, use the container to host the schema of the data source.

Environment:

JBOSS EAP 6 Domain cluster

Services using Spring Management

Database Oracle 11g

Solution:

1. Tentative use of OJDBC as a driver, so the first to have a Ojdbc6.jar, legend that other versions may have some problems, such as 14 incompatible JDK1.6,_GZ does not support 11g, etc.

2. Let JBoss load the driver:

Build the directory structure as shown:

The contents of Module.xml are as follows:

XML code

    1. <?xml version= "1.0" encoding= "UTF-8"?>
    2. <module xmlns= "urn:jboss:module:1.0" name= "Com.oracle" >
    3. <resources>
    4. <!--Insert Resources here--
    5. <resource-root path= "Ojdbc6.jar"/>
    6. </resources>
    7. <dependencies>
    8. <module name= "Javax.api"/>
    9. <module name= "Javax.transaction.api"/>
    10. </dependencies>
    11. </module>

(RIP: Because JBOSS6 uses the structured management of class Maven, that is, not to 4, the jar is basically in a Lib directory, but is introduced through the concept of module, and the module allows for the provision of dependencies and exclusions, You can also globally configure the priority of the jar in the module ingestion and service pack, and of course the most troublesome is hibernate conflict, because it is stoned to its own feet.

3. Place this directory at the node end $JBOSS _home/modules;

Note that it is all node-side, not on the control end, although the specific configuration file [Domain.xml] is configured on the control side, or when the service is started, the registration datasource will fail:

[Org.jboss.as.controller.management-operation] (Serverservice Thread Pool--) JBAS014613: Operation ("Add") failed--Address: ([

("Subsystem" = "datasources"),

("Jdbc-driver" = "Xxx.war")

4. Start the JBoss control and configure it in its console:

[1]. Enter the Profiles option

[2]. Select the corresponding configuration file, here the profile and your corresponding group of profiles specified corresponds, here is the domain under the full-ha mode, there is no attempt to full-ha engineering Jndi point to the full configuration of DataSource, This is why you often encounter many of the same configurations when changing domain.xml, which is actually a different configuration domain for JBoss:


[3]. DataSources tab

[4].add button Popup New page (here is advised not to delete the default example configuration--)

5. Configure Data source aliases and Jndi

6.Detected driver is read-only, it's for you to see


Specify driver when I add the error:

Internal Server Error

{

"Outcome" = "Failed",

"Result" = Undefined,

"Failure-description" = "JBAS010839: Operation failed or rolled back on all servers." ",

"Rolled-back" = True,

"Server-groups" + + {"Main-server-group" + + {"Host" + = {"Slave1" + = "Main-server33" + + {"Response" + = {

"Outcome" = "Failed",

"Result" = Undefined,

"Failure-description" + = "JBAS014771: Service with Lost/unavailable Dependencies" = ["jboss.driver-demander.java:jboss/datasources/ OracleRacDS1 missing [Jboss.jdbc-driver.xxxds] "},

"Rolled-back" = True

}}}}}}

}

This seems to specify the prefix of Jboss.jdbc-driver., where the designation is not yet known;

7. Configure Database Links:


8. After the completion of the default is the disable state, the specific configuration can be adjusted in the property box below, where xxx is the alias of driver, in the specific XML will point to a specific class

More specific properties are configured in the pool tag by key-value pairs

9. <subsystem xmlns= "urn:jboss:domain:datasources:1.1" > tags under profile name= "Full-ha" can be found in domain.xml after saving

The following configuration is more

XML code

  1. <datasource jta= "true" Jndi-name= "Java:jboss/datasources/oracleracds" pool-name= "Oracleracds" enabled= "false" Use-ccm= "false" use-java-context= "true" >
  2. <CONNECTION-URL>[JDBC Connection]</connection-url>
  3. <driver-class>com.oracle.jdbc.driver.OracleDriver</driver-class>
  4. <datasource-class>com.oracle</datasource-class>
  5. <driver>[alias A]</driver>
  6. <pool>
  7. <min-pool-size>10</min-pool-size>
  8. <max-pool-size>30</max-pool-size>
  9. </pool>
  10. <security>
  11. <user-name>[User name]</user-name>
  12. <password>[Password]</password>
  13. </security>
  14. <validation>
  15. <validate-on-match>false</validate-on-match>
  16. <background-validation>false</background-validation>
  17. </validation>
  18. <timeout>
  19. <idle-timeout-minutes>60</idle-timeout-minutes>
  20. </timeout>
  21. <statement>
  22. <share-prepared-statements>false</share-prepared-statements>
  23. </statement>
  24. </datasource>
  25. <drivers>
  26. <driver Name= "[Alias A]" module= "com.oracle" >
  27. <xa-datasource-class>oracle.jdbc.xa.OracleXADataSource</xa-datasource-class>
  28. </driver>
  29. </drivers>
  30. </datasources>

It is still necessary to modify the Xa-datasource-class as the upper red part.

10. Finally restart the control side JBoss to enable the data source to take effect (the server can not restart).

11. The DataSource configuration in the service pack changes to a Jndi call:

XML code

    1. <bean id= "DataSource" class= "Org.springframework.jndi.JndiObjectFactoryBean" >
    2. <property name= "Jndiname" >
    3. <value>java:jboss/datasources/oracleRacDS</value>
    4. </property>
    5. </bean>

12. Redeploy the service pack, and when you start the group, you will see the following information in the log of the node segment stating that the registration was successful

[Org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-18) JBAS010400: Binding data source [java:jboss/datasources/ ORACLERACDS]

Practice:

After the group starts, the server can read the data from the database.

This is the datasource that modifies the positive enable state to have the following error:

Description cannot be modified.

At this point, if you change datasource disable off

The following exception will appear in the server log:

Javax.resource.ResourceException:IJ000451:The Connection Manager is Shutdown:java:jboss/datasources/oracleracds

The connection cannot be re-connected at this time;

Conclusion:

By using Jndi to point to the JBoss data source, you can reduce the adjustments made to the service segment during database tuning to the following steps:

a). Stop the Service group

b). Remove the Service pack

c). Source Service Pack Replacement configuration file (This also requires that the current version of the service pack is backed up intact)

d). Re-upload the service pack

e). Distribute to groups and finally launch groups

f). When the source library is back to normal, it comes back again T t

b). Disable data source

c). Modify the data source configuration save and enable

d). Start a service group

e). After the source library is restored, ibid.

But time saved, cumbersome replacement file steps saved, error rate decreased.

--from Sleest (thanks to YANGJJ ^_^)

JBOSS data source configuration and using Jndi calls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.