In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to configure weblogic JDBC data source, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
one。 Overview
GridLink is a new feature of WebLogic 10.3.4, which introduces the Jdbc 11g version driver and fully supports the features of Oracle 11G RAC AWM, including the new SCAN features I wrote earlier.
After WebLogic was acquired by Oracle, the first version followed the database version. For example, 10.3.0 named 10g R2Mague 10.3.1 named 11g R1Magne WebLogic is becoming more and more close to the database. I think it is a company's thing to be highly cohesive, that is, to provide a complete set of solutions for enterprise applications. WebLogic is a J2EE enterprise application server, which is the link between J2EE applications and DB, thus providing a high availability link environment for both. Gridlink Data Source is more efficient than the previous Multi Data Source because it relies heavily on the capabilities of the database. It uses the features of Oracle's ONS (Oracle Notification Service).
II. What is the intention of Link?
The Link in the title means the way WebLogic connects DB. The connection here is naturally connected by JDBC Thin. WebLogic is the container of J2EE and is also written by Java language.
So far, WebLogic provides five configurations for Jdbc Thin to connect to Oracle RAC, as follows:
1.GridLink Data Sources
2.Configuring Connections to Services on Oracle RAC Nodes (XA)
3.Configuring Connections to Services on Oracle RAC Nodes (No-XA)
4.Multi Data Sources with Global Transactions
5.Multi Data Sources without Global Transactions
GridLink Data Sources supports the use of services to achieve Load Balancing (load balancing) and Failover (failover). Automatic Workload Management, namely database service, is introduced in Oracle Database 10g, which is different from traditional database service.
III. The true face of GridLink
WLS GridLink is a new type of Data Source introduced by WLS10.3.4, which provides the connection function between Oracle RAC database and WLS. GridLink uses the Oracle Notification Service (ONS) to obtain the state changes of the Oracle RAC instance. WLS can meet its needs through Oracle RAC's flexible database service design, or it can be expanded by the increase of database services without paying attention to the physical structure changes in the RAC cluster.
The schematic diagram of the connection is as follows:
GridLink provides the following features:
1. Simplifies and unifies the modules for configuring RAC connections.
two。 Fast Connection Filover (FCF) is supported.
3. Runtime Connection Load Balancing (RCLB) is supported.
4. Single Client Access Name (SCAN) is supported.
Normal handling of 5.Oracle RAC downtime.
This article is an overview, and this series of articles will provide an analysis and configuration wizard for the above features.
IV. Oracle ONS (Oracle NOtification Service) and FAN (Fast Application Notification)
The Oracle RAC Notification Service (ONS) is maintained by the cluster and is a nodeapps group. Such as:
View ons service status
$crsctl status resource ora.ons
AME=ora.ons
TYPE=ora.ons.type
TARGET=ONLINE, ONLINE
STATE=ONLINE on rac1, ONLINE on rac2
$srvctl status nodeapps
ONS daemon is running on node: gwrac1
ONS daemon is running on node: gwrac2
ONS services are maintained by srvctl tools, and onsctl tools can also be maintained and track ons information. The following is to view the ons configuration information:
$srvctl config nodeapps-s
ONS daemon exists. Local port 6100, remote port 6200
Oracle RAC FAN provides cluster status and node load for RAC applications and client, and publishes these events to the clients of Java client and Oracle through ONS to let them know the current RAC situation and deal with them accordingly, such as the distribution of client requests.
Based on the above features, Oracle calls it high availability, high reliability, and high scalability, which is too loud.
After Bea was acquired by Oracle, we can see a closer integration between WebLogic and Oracle databases.
In the version of 10gR3 (10.3.0) just released after the merger, the original Data Direct Driver used by Bea is abandoned, and the thin driver of Oracle is officially recommended:
Note: The WebLogic Type 4 JDBC Oracle driver described in this document has been deprecated as of release 10.3 of WebLogic Server. It will be removed in the next release of WebLogic Server. Instead of this deprecated driver, use the Oracle Thin Driver that is also provided with WebLogic Server.
Now in WebLogic 10.3.4, to enhance support for RAC, Oracle has introduced Gridlink Data Source to replace the original Multi Data Source:
Http://download.oracle.com/docs/cd/E17904_01/web.1111/e13737/jdbc_intro.htm#BHCBACAG
Enhanced Oracle RAC Support
This release provides a new data source type, a GridLink Data Source, to provide enhanced support for Oracle RAC.
Multi Data Source
The original Multi Data Source works by configuring a Datasource for each RAC node, and then aggregating all these Datasource to configure a Multi Data Source. Although Multi Data Source also provides Failover (fault tolerance) and Load Balancing (load balancing), the function is relatively limited.
1) the configuration is complicated.
You need to manually configure a Data Source for each RAC node, and you need to add and delete nodes manually by the WebLogic administrator.
2) Failover is data source-level, not connection-level
Multi Data Source needs to enable the Test Reserved Connections (TestConnectionsOnReserve) function. When this feature is enabled, when the application applies for a Connection from a Data Source, the WebLogic server needs to test the Connection before returning it. If this test fails, WebLogic rebuilds a connection. If the rebuild fails again, the Data Source is identified as dead, and the WebLogic automatically Failover to the Data Source in the next Multi Data Source. When a Data Source is identified as dead, WebLogic will actively query the database node at regular intervals (the default is 120 seconds). If the test is successful, the Data Source will be re-enabled.
Failover cannot be implemented for a connection,WebLogic that has been acquired and is in use.
3) Load Balancing is just a simple round robin
If an application has multiple Connection enabled, then according to the principle of round robin, the multiple Connection may come from multiple different database nodes. This actually has a performance impact.
Gridlink Data Source
The new Gridlink Data Source is relatively more efficient because it relies heavily on the capabilities of the database. It uses the ONS (Oracle Notification Service) features of Oracle. Look at the following picture:
The ONS service on the RAC side of the database collects the running data of the RAC node. This data is passed to Gridlink Data Source's ONS snooping client. The UCP-RAC module analyzes the data and gives recommendations that Gridlink Data Source uses to implement Failover,Load Balancing and other features of connection pooling.
Let's take a look at some improvements to Gridlink Data Source:
1) first of all, the configuration becomes simple
You only need to configure a Gridlink Data Source, and it will handle communication with the background RAC database. The workload is much less than that of Multi Data Source,WebLogic administrators.
It's even easier if you configure Oracle's SCAN service. RAC nodes are added and deleted automatically, because for Gridlink Data Source, it only knows a SCAN address. Just like a domain name, you don't need to know how much IP is used to implement it.
2) faster and more efficient Failover
The information on the RAC side can be captured in real time by using ONS,Gridlink Data Source. If a node goes wrong, Gridlink Data Source will soon mark its corresponding Connection as unavailable. This avoids the need to constantly proactively test the overhead brought about by Connection in Multi Data Source.
3) Real-time Load Balancing
Also because of the ONS data, Gridlink Data Source can know which RAC nodes are busy and which are idle, so it can effectively allocate which Connection from idle RAC to application requests to achieve real-time Load Balancing.
4) calmly deal with the shutdown of RAC nodes
If it is a planned shutdown, Gridlink Data Source will wait until the end of the current Active transaction before shutting down Connection. New Connection requests will be sent to other RAC nodes.
If it is a sudden RAC node shutdown, Gridlink Data Source will calmly rollback the current transaction and then send the new Connection request to other RAC nodes.
5) the Connectoin of the global transaction will be on one RAC node as far as possible.
As mentioned earlier, Multi Data Source's Round Robin strategy causes multiple Connection of the same transaction to be sent to different RAC nodes.
Gridlink Data Source sends all subsequent Connection requests for a transaction to the same RAC node after the first Connection of the transaction is created. This can reduce the background synchronization processing and improve the running efficiency of global transactions.
Create Gridlink Data Source
The process of creation is not complicated, just like a normal Data Source. It all starts here:
1. For configurations such as names, note that the database type is Oracle. Hehe, of course, RAC is Oracle:
The configuration page of 2.XA skims to the page where you enter the RAC address
3. In fact, the two choices are the same. One is to add server one by one, and then the JDBC URL is generated by WebLogic:
One is to enter JDBC URL yourself:
There is no difference. If you are afraid of writing mistakes, let WebLogic be generated and skim the test page. The next step is the key ONS client configuration:
If you use SCAN, you can enter the address of SCAN here.
Wallet can be used to encrypt ONS communications, not shown here.
Skim the test page and just target it.
The JNDI here is the same as the node value of the corresponding res-ref-name in web.xml.
It is necessary to talk about what JNDI is.
JNDI is the Java naming and Directory Interface (Java Naming and Directory Interface), which is one of the important specifications in the J2EE specification. Many experts believe that without a thorough understanding of the meaning and function of JNDI, there is no real knowledge of J2EE, especially EJB.
So what exactly is the role of JNDI?
To understand the role of JNDI, we can start from "what do we do if we don't use JNDI? what will we do with JNDI?" To explore this issue.
There is no JNDI practice:
When the programmer develops, knowing that he is going to develop an application that accesses the MySQL database, he encodes a reference to the MySQL JDBC driver class and connects to the database by using the appropriate JDBC URL.
It looks like this code:
Connection conn=null
Try {
Class.forName ("com.mysql.jdbc.Driver"
True, Thread.currentThread (). GetContextClassLoader ()
Conn=DriverManager.getConnection ("jdbc:mysql://MyDBServer?user=qingfeng&password=mingyue")
/ * use conn and perform SQL operations * /
.
Conn.close ()
}
Catch (Exception e) {
E.printStackTrace ()
}
Finally {
If (connexual null) {
Try {
Conn.close ()
} catch (SQLException e) {}
}
} this is a traditional practice, and it is also a common practice for non-Java programmers (such as Delphi, VB, etc.). This practice generally does not cause problems in the process of small-scale development, as long as programmers are familiar with the Java language, JDBC technology and MySQL, they can quickly develop corresponding applications.
The problem with the approach without JNDI:
1. The database server name MyDBServer, user name and password may need to be changed, which leads to the need to modify JDBC URL.
2. The database may be changed to other products, such as DB2 or Oracle, causing the JDBC driver package and class name to be modified.
3. With the increase of actual use of terminals, the originally configured connection pool parameters may need to be adjusted.
4 、.
Solution:
Programmers should not need to care about "what is the specific database background? what is the JDBC driver? what is the JDBC URL format? what is the user name and password to access the database?" And so on, programmers should write programs with no references to JDBC drivers, no server names, no user names or passwords-- not even database pools or connection management. Instead, these issues are left to the J2EE container to configure and manage, and programmers only need to reference these configurations and management.
From this, there is JNDI.
What you do after using JNDI:
First, configure the JNDI parameter in the J2EE container, define a data source, that is, the JDBC reference parameter, and set a name for the data source; then, in the program, access the background database by referencing the data source through the data source name.
The specific operations are as follows (take JBoss as an example):
1. Configure the data source
Under the D:/jboss420GA/docs/examples/jca folder in JBoss, there are many data source definition templates referenced by different databases. Copy the mysql-ds.xml file to the server you are using, such as D:/jboss420GA/server/default/deploy.
Modify the contents of the mysql-ds.xml file so that it can access your MySQL database correctly through JDBC, as follows:
MySqlDS
Jdbc:mysql://localhost:3306/lw
Com.mysql.jdbc.Driver
Root
Rootpassword
Org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
MySQL
Here, a data source named MySqlDS is defined, and its parameters include JDBC's URL, driver class name, user name and password, and so on.
2. Reference the data source in the program:
Connection conn=null;try {Context ctx=new InitialContext (); Object datasourceRef=ctx.lookup ("java:MySqlDS"); / / reference data source DataSource ds= (Datasource) datasourceRef; conn=ds.getConnection (); / * use conn for database SQL operations * /. C.close ();} catch (Exception e) {e.printStackTrace ();} finally {if (connexual null) {try {conn.close ();} catch (SQLException e) {}
The amount of programming code that uses JDBC directly or references a data source through JNDI is about the same, but today's programs don't have to worry about specific JDBC parameters.
After the system deployment, if the relevant parameters of the database change, only need to reconfigure mysql-ds.xml to modify the JDBC parameters, as long as the name of the data source remains unchanged, then the program source code does not need to be modified.
Thus it can be seen that JNDI avoids the tight coupling between the program and the database and makes the application easier to configure and deploy.
Extensions to JNDI:
JNDI not only meets the requirements of data source configuration, but also further expands its role: all references to resources outside the system can be defined and referenced through JNDI.
Therefore, in the J2EE specification, resources in J2EE are not limited to JDBC data sources. There are many types of references, including resource references (which have been discussed), environmental entities, and EJB references. In particular, the EJB reference exposes another key role of JNDI in J2EE: finding other application components.
The JNDI reference to EJB is very similar to the reference to JDBC resources. This is an effective approach in an environment where services tend to be transformed. This type of configuration management can be performed on all the components obtained in the application architecture, from EJB components to JMS queues and topics, to simple configuration strings or other objects, which can reduce maintenance costs caused by service changes over time, while simplifying deployment and reducing integration efforts. External resources ".
Summary:
The J2EE specification requires that all J2EE containers provide an implementation of the JNDI specification. The role of JNDI in J2EE is the "switch"-- a common mechanism for J2EE components to find other components, resources, or services indirectly at run time. In most cases, the container that provides the JNDI provider can act as a limited data store so that the administrator can set the application's execution properties and have other applications reference these properties (Java Management extensions (Java Management Extensions,JMX) can also be used for this purpose). The primary role of JNDI in J2EE applications is to provide an indirection layer so that components can discover the resources they need without knowing the indirectness.
In J2EE, JNDI is the glue that holds J2EE applications together, and the indirect addressing provided by JNDI allows scalable, powerful, and flexible applications to be delivered across enterprises. This is the promise of J2EE, and after some planning and pre-consideration, this commitment is fully achievable.
Differences between oracle drivers
Oracle's driver thin
Oracle's driver thin XA
Oracle's (OCI XA)
Oracle's (OCI)
Weblogic's Oracle (Type 2 XA)
Weblogic's Oracle (Type 2)
DataDirect's Oracle Driver (Type 4 XA)
DataDirect's Oracle Driver (Type 4)
The difference between these four categories is that they use different drivers.
The first is the thin driver.
The second is the ordinary driver, which is provided by Oracle itself.
The third is the driver provided by weblogic.
The fourth is a third-party driver, provided by DataDirect
Each driver can be configured with two data sources.
Those without XA are ordinary data sources.
There are XA data sources that support JTA transactions.
When creating a connection pool, developers without transactions can choose both drivers; developers with transactions must choose a database driver of XA type
Jdbc:oracle:thin:@192.168.6.100:1521:TestDB12
The JDBC here is correctly deployed to the cluster, not to the proxy server. The elder brother in the group said, when deploying the proxy application, deploy to the proxy node, deploy the production application to other nodes, (my experimental project is deployed to the agent), and then the data source target is all the nodes in the cluster.
Sqlplus@hostname is the session logged in by sqlplus, and after scott logs in with sqlplus for two sessions, it becomes as follows.
Is plsqldev.exe logged in by plsql developer, or is it anyone who logs in to username?
These are all the contents of the article "how weblogic configures JDBC data sources". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.