一、基于数据库的session共享
1)、在mysql中创建session存储表
CREATE TABLE `persistent_session` (
`id` varchar(64) NOT NULL default '',
`data` mediumblob,
`access_time` int(11) default NULL,
`expire_interval` int(11) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM
2)、在resin.conf中添加session配置
<resin xmlns="http://caucho.com/ns/resin">
<server>
<http id='a' port='8080'/>
<http id='b' port='8080'/>
<cluster>
<srun id='a' host='host-a' port='6802'/>
<srun id='b' host='host-b' port='6802'/>
</cluster>
<database>
<jndi-name>jdbc/session</jndi-name>
<driver type="org.gjt.mm.mysql.Driver">
<url>jdbc:mysql://localhost:3306/session</url>
<user>xxxxx</user>
<password>xxxxx</password>
</driver>
<prepared-statement-cache-size>8</prepared-statement-cache-size>
<max-connections>20</max-connections>
<max-idle-time>30s</max-idle-time>
</database>
<persistent-store type="jdbc"> <init>
<data-source>jdbc/session<data-source>
</init>
</persistent-store>
...
<web-app-default>
<session-config>
<use-persistent-store>true</use-persistent-store>
<always-save-session>true</always-save-session>
</session-config>
</web-app-default>
二、基于集群的session共享(优点不依赖数据库)
在resin.conf中添加配置如下
<resin xmlns="http://caucho.com/ns/resin">
<server>
<http id='a' port='8080'/>
<http id='b' port='8080'/>
<cluster>
<srun id='a' host='host-a' port='6802'/>
<srun id='b' host='host-b' port='6802'/>
</cluster>
<persistent-store type="cluster">
<init path="cluster"/>
</persistent-store>
<host id=''>
<web-app id=''>
<session-config>
<use-persistent-store="true"/>
</session-config>
</web-app>
</host>
</server>
</resin>