jboss7.2版本如何配置redis的session共享
时间: 2023-11-01 09:08:11 浏览: 76
你好,关于jboss7.2版本如何配置redis的session共享,可以按照以下步骤进行:
1.将jboss7.2的modules下的org/jboss/as/web/main目录下的jboss-as-web-7.2.0.Final.jar解压缩至某个目录,比如/home/jboss/modules/org/jboss/as/web/main/
2.将redis的jar包,比如jedis-2.9.3.jar,放到前述目录下,此时该目录应该有如下三个文件:jboss-as-web-7.2.0.Final.jar、module.xml和jedis-2.9.3.jar
3.修改module.xml文件,添加如下content标签:
<content>
<exclude-set>
<path name="javax/el"/>
<path name="javax/servlet"/>
<path name="javax/servlet/jsp"/>
<path name="org/apache/ecj/**"/>
</exclude-set>
<archive path="jboss-as-web-7.2.0.Final.jar"/>
<archive path="jedis-2.9.3.jar"/>
</content>
4.在jboss-as-7.2.0.Final\standalone\configuration目录下,创建一个文件名为redis-session-config.xml的文件,内容如下:
<jboss-web>
<replication-config>
<replication-trigger>SET_AND_NON_PRIMITIVE_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
<replication-field-passivation>true</replication-field-passivation>
<replication-ttl>1800</replication-ttl>
<replication-passivation-dir>/usr/local/jboss/passivation</replication-passivation-dir>
<replication-passivation-info>session</replication-passivation-info>
<session-management>
<session-jdbc-attributes>
<attribute name="database">sessiondb</attribute>
<attribute name="user">username</attribute>
<attribute name="password">password</attribute>
</session-jdbc-attributes>
<replication-transport>
<socket>
<attribute name="type">Redis</attribute>
<attribute name="host">localhost</attribute>
<attribute name="port">6379</attribute>
</socket>
</replication-transport>
</session-management>
</replication-config>
</jboss-web>
5.在jboss-as-7.2.0.Final\standalone\configuration目录下,打开standalone.xml文件,找到以下内容:
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<virtual-server name="default-host" enable-welcome-root="true">
<alias name="localhost"/>
<alias name="example.com"/>
</virtual-server>
</subsystem>
将其修改为以下内容:
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<virtual-server name="default-host" enable-welcome-root="true">
<alias name="localhost"/>
<alias name="example.com"/>
<distributable/>
</virtual-server>
</subsystem>
6.然后,在jboss-as-7.2.0.Final\bin目录下打开运行jboss-cli.bat(Windows)或jboss-cli.sh(Linux),并输入以下命令:
/subsystem=web:write-attribute(name=replication-config,file={path-to}/redis-session-config.xml)
其中{path-to}替换成实际的redis-session-config.xml路径。
7.重启jboss7.2,完成redis的session共享配置。
希望以上步骤对你有所帮助。
阅读全文