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
- <?xml version= "1.0" encoding= "UTF-8"?>
- <module xmlns= "urn:jboss:module:1.0" name= "Com.oracle" >
- <resources>
- <!--Insert Resources here--
- <resource-root path= "Ojdbc6.jar"/>
- </resources>
- <dependencies>
- <module name= "Javax.api"/>
- <module name= "Javax.transaction.api"/>
- </dependencies>
- </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
- <datasource jta= "true" Jndi-name= "Java:jboss/datasources/oracleracds" pool-name= "Oracleracds" enabled= "false" Use-ccm= "false" use-java-context= "true" >
- <CONNECTION-URL>[JDBC Connection]</connection-url>
- <driver-class>com.oracle.jdbc.driver.OracleDriver</driver-class>
- <datasource-class>com.oracle</datasource-class>
- <driver>[alias A]</driver>
- <pool>
- <min-pool-size>10</min-pool-size>
- <max-pool-size>30</max-pool-size>
- </pool>
- <security>
- <user-name>[User name]</user-name>
- <password>[Password]</password>
- </security>
- <validation>
- <validate-on-match>false</validate-on-match>
- <background-validation>false</background-validation>
- </validation>
- <timeout>
- <idle-timeout-minutes>60</idle-timeout-minutes>
- </timeout>
- <statement>
- <share-prepared-statements>false</share-prepared-statements>
- </statement>
- </datasource>
- <drivers>
- <driver Name= "[Alias A]" module= "com.oracle" >
- <xa-datasource-class>oracle.jdbc.xa.OracleXADataSource</xa-datasource-class>
- </driver>
- </drivers>
- </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
- <bean id= "DataSource" class= "Org.springframework.jndi.JndiObjectFactoryBean" >
- <property name= "Jndiname" >
- <value>java:jboss/datasources/oracleRacDS</value>
- </property>
- </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