1. Configuration Preparation
1) to configure JDBC to copy the session, mainly for the following three steps
(1) Create a table in the database
(2) Create a connection pool with read/write permissions to the database
(3) in Weblogic.xml Configuring session persistence in the deployment descriptor
2) An example of the persistence of a configuration session is as follows:
<session-descriptor> <persistent-store-type>jdbc</persistent-store-type> <persistent-st Ore-pool>mysql</persistent-store-pool> <persistent-store-table>wl_servlet_sessions</ Persistent-store-table></session-descriptor>
The optional parameters are as follows.
①memory--disables persistent session storage.
The ②replicated--is the same as memory, but session data is replicated between the cluster servers.
③replicated_if_clustered--if the Web application is deployed on a clustered server, copy it as a valid persistentstore-type, otherwise press the default value memory copy.
④sync-replication-across-cluster--replication will occur synchronously within the cluster.
⑤async-replication-across-cluster--replication will occur asynchronously within the cluster.
3) the JDBC Persistence table configuration must have a database table named Wl_servlet_sessions with read/write access, as shown in the following table.
Column headings |
Column data type |
wl_id |
variable width, up to - of characters |
Wl_context_path |
|
Wl_is_new |
Numeric , - bit |
|
|
|
Wl_create_time |
Numeric , - bit |
In the database mapped to the session persistence connection pool, you need to configure a table named Wl_servlet_ sessions that will contain the values of all active session objects. Specifies that users who have access to this table need read/write/insert/delete access to the table to effectively manage objects. The table needs to have the following 8 columns of content.
wl_id--session ID, used with Wl_context_path as the database primary key. Variable-width alphanumeric data type with a maximum of 100 characters.
wl_context_path--context, this column is used with the WL_ID key. Variable-width alphanumeric data type with a maximum of 100 characters.
wl_is_new--This value is true as long as the servlet engine classifies the session as a "new" state. A column that contains one character.
wl_create_time--when the session was originally created. Numeric data Type column, 20 bits.
The value is true when the Wl_is_valid--servlet can access the session. For concurrent access. A column that contains one character.
wl_session_values--actual session data. BLOB column.
wl_access_time--the last time the session was accessed. Numeric data type column, 20 bits.
wl_max_inactive_interval--the time (in seconds) between the request from the client to the session invalidation. A negative time value indicates that the session never expires. The Integer data type column.
2. Create a database and data table that holds the session
Here we choose to use MySQL database
Create a WebLogic database and create a wl_servlet_sessions table under WebLogic
create database weblogic; set foreign_key_checks=0; --closing foreign KEY constraints -- ------------------------------ table structure for ' wl_servlet_sessions '-- ----------------------------drop table if EXISTS ' wl_servlet_sessions '; create table ' wl_servlet_sessions ' ( ' wl_id ' varchar (+) not null DEFAULT ', ' Wl_context_path ' varchar (+) NOT NULL DEFAULT ', ' Wl_is_new ' varchar (2) DEFAULT NULL, ' Wl_create_time ' bigint (20) DEFAULT NULL, ' Wl_is_valid ' varchar (2) DEFAULT NULL, ' Wl_ Session_values ' blob, ' wl_access_time ' bigint ( DEFAULT NULL, ' Wl_ Max_inactive_interval ' bigint DEFAULT NULL, PRIMARY KEY (' wl_id ', ' Wl_ Context_path ')) engine=innodb default charset=uTf8;
3. Create a database Connection account
Create a WebLogic user and give all the permissions to all tables in the WebLogic database, the account password is WebLogic, and the account can connect to the server from any host
Grant all on weblogic.* to ' weblogic ' @ '% ' of ' identified by ' WebLogic ';
4. Configuring the WebLogic Cluster Server
For example, the managed server App1 and app2, which belong to a cluster, can refer to the previous article for a load-balanced cluster configuration.
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/86/86/wKioL1fCpiGTH5adAADhn8xWebo426.png "title=" Picture 2.png "alt=" Wkiol1fcpigth5adaadhn8xwebo426.png "width=" 735 "height=" 342 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:735px;height:342px; "/>
5. Configure the JDBC data source
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/86/86/wKioL1fCpgXAgTLGAAClaY1tRAI010.png "style=" width : 735px;height:267px; "title=" Picture 3.png "alt=" Wkiol1fcpgxagtlgaaclay1trai010.png "width=" 735 "height=" 267 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/86/87/wKiom1fCpgbBKsLbAADC-jP7QZc972.png "style=" width : 735px;height:359px; "title=" Picture 4.png "alt=" Wkiom1fcpgbbkslbaadc-jp7qzc972.png "width=" 735 "height=" 359 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/86/86/wKioL1fCpgbjokH-AACgGlS81Nc232.png "style=" width : 735px;height:228px; "title=" Picture 5.png "alt=" Wkiol1fcpgbjokh-aacggls81nc232.png "width=" 735 "height=" 228 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/86/87/wKiom1fCpgehi9W5AADT7eUseWU760.png "style=" width : 735px;height:314px; "title=" Picture 6.png "alt=" Wkiom1fcpgehi9w5aadt7eusewu760.png "width=" 735 "height=" 314 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/86/87/wKiom1fCpgfzqpIQAADSI829cX8993.png "style=" width : 735px;height:393px; "title=" Picture 7.png "alt=" Wkiom1fcpgfzqpiqaadsi829cx8993.png "width=" 735 "height=" 393 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/86/86/wKioL1fCpgjBmU-nAAD_XsQmncg791.png "style=" width : 735px;height:477px; "title=" Picture 8.png "alt=" Wkiol1fcpgjbmu-naad_xsqmncg791.png "width=" 735 "height=" 477 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/86/87/wKiom1fCpgjQUd9XAAAdcMKJ_Bc497.png "style=" width : 735px;height:211px; "title=" Picture 9.png "alt=" Wkiom1fcpgjqud9xaaadcmkj_bc497.png "width=" 735 "height=" 211 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/86/86/wKioL1fCpgnzkCUhAADrGRlrvLA684.png "style=" width : 735px;height:397px; "title=" Picture 10.png "alt=" Wkiol1fcpgnzkcuhaadrgrlrvla684.png "width=" 735 "height=" 397 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/86/86/wKioL1fCpgqzuU5KAAC3GeRZrok130.png "style=" width : 735px;height:311px; "title=" Picture 11.png "alt=" Wkiol1fcpgqzuu5kaac3gerzrok130.png "width=" 735 "height=" 311 "border=" 0 " Hspace= "0" vspace= "0"/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/86/87/wKiom1fCpgqAZq7hAAC-VHaqNuE697.png "style=" width : 735px;height:302px; "title=" Picture 12.png "alt=" Wkiom1fcpgqazq7haac-vhaqnue697.png "width=" 735 "height=" 302 "border=" 0 " Hspace= "0" vspace= "0"/>
6. Configure the Web project's Weblogic.xml file
<! doctype weblogic-web-app public "-//bea systems, inc.//dtd web application 8.1//en " " HTTP://WWW.BEA.COM/SERVERS/WLS810/DTD/WEBLOGIC810-WEB-JAR.DTD "><weblogic-web-app > <session-descriptor> <persistent-store-type>jdbc</ persistent-store-type> <persistent-store-pool>MYSQL</persistent-store-pool> <persistent-store-table>wl_servlet_ Sessions</persistent-store-table> </session-descriptor ></weblogic-web-app>
7. After the deployment project is started, Access
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/86/87/wKiom1fCpmWhofzKAAGJy2NQcog348.png "title=" Picture 14.png "alt=" Wkiom1fcpmwhofzkaagjy2nqcog348.png "width=" 735 "height=" 212 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:735px;height:212px; "/>
8. Review the database for validation
Let's look at the database and write the session information to the database so that we can share the session.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/86/87/wKiom1fCpnbSgYeEAAB89uJz9Ao079.png "title=" Picture 15.png "alt=" Wkiom1fcpnbsgyeeaab89ujz9ao079.png "width=" 735 "height=" 227 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:735px;height:227px; "/>
This article from the "11528244" blog, reproduced please contact the author!
WebLogic the configuration of session sharing by means of a database