Redhat(Linux)上的JBoss管理配置

简介:

 JBoss设置

1.1  JBoss安全设置

1.1.1               jmx-console安全设置

1.1.1.1          编辑jboss-web.xml文件

u   编辑jmx-console.war/WEB-INF/jboss-web.xml文件:
[jboss@node1 ~]$ cd JBOSS_HOME/server/default/deploy
[jboss@node1 deploy]$ vi jmx-console.war/WEB-INF/jboss-web.xml
<!--将--> 
< jboss-web > 
   <!--  Uncomment the security-domain to enable security. You will 
      need to edit the htmladaptor login configuration to setup the 
      login modules used to authentication users.  
      <security-domain>java:/jaas/jmx-console</security-domain> 
--> 
</ jboss-web > 
<!--修改为-->
< jboss-web > 
   <!--  Uncomment the security-domain to enable security. You will 
      need to edit the htmladaptor login configuration to setup the 
      login modules used to authentication users. 
--> 
       < security-domain >java:/jaas/jmx-console </ security-domain > 
</ jboss-web >

1.1.1.2          编辑web.xml文件

u   编辑jmx-console.war/WEB-INF/web.xml文件:
[jboss@node1 ~]$ cd JBOSS_HOME/server/default/deploy 
[jboss@node1 deploy]$ vi jmx-console.war/WEB-INF/web.xml
<!-- --> 
<? xml  version ="1.0" ?> 
<!DOCTYPE web-app PUBLIC 
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
   "http://java.sun.com/dtd/web-app_2_3.dtd"> 

< web-app > 
   ...... 
   <!--  A security constraint that restricts access to the HTML JMX console to users with the role JBossAdmin. Edit the roles to what you want and uncomment the WEB-INF/jboss-web.xml/security-domain element to enable secured access to the HTML JMX console. 
   <security-constraint> 
     <web-resource-collection> 
       <web-resource-name>HtmlAdaptor</web-resource-name> 
       <description>An example security config that only allows users with the role JBossAdmin to access the HTML JMX console web application </description> 
       <url-pattern>/*</url-pattern> 
       <http-method>GET</http-method> 
       <http-method>POST</http-method> 
     </web-resource-collection> 
     <auth-constraint> 
       <role-name>JBossAdmin</role-name> 
     </auth-constraint> 
   </security-constraint> 
   
--> 

    < login-config > 
       < auth-method >BASIC </ auth-method > 
       < realm-name >JBoss JMX Console </ realm-name > 
    </ login-config > 

    < security-role > 
       < role-name >JBossAdmin </ role-name > 
    </ security-role > 
</ web-app > 
<!-- 修改为--> 
<? xml  version ="1.0" ?> 
<!DOCTYPE web-app PUBLIC 
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
   "http://java.sun.com/dtd/web-app_2_3.dtd"> 

< web-app > 
   ...... 
   <!--  A security constraint that restricts access to the HTML JMX console to users with the role JBossAdmin. Edit the roles to what you want and uncomment the WEB-INF/jboss-web.xml/security-domain element to enable secured access to the HTML JMX console.--> 
    < security-constraint > 
      < web-resource-collection > 
        < web-resource-name >HtmlAdaptor </ web-resource-name > 
        < description >An example security config that only allows users with the role JBossAdmin to access the HTML JMX console web application  </ description > 
        < url-pattern >/* </ url-pattern > 
        < http-method >GET </ http-method > 
        < http-method >POST </ http-method > 
      </ web-resource-collection > 
      < auth-constraint > 
        < role-name >JBossAdmin </ role-name > 
      </ auth-constraint > 
    </ security-constraint > 
    

    < login-config > 
       < auth-method >BASIC </ auth-method > 
       < realm-name >JBoss JMX Console </ realm-name > 
    </ login-config > 

    < security-role > 
       < role-name >JBossAdmin </ role-name > 
    </ security-role > 
</ web-app >

1.1.2               web-console 安全设置

1.1.2.1          编辑jboss-web.xml文件

u   修改web-console.war/WEB-INF/jboss-web.xml文件:
[jboss@node1 ~]$ cd JBOSS_HOME/server/default/deploy/management/console-mgr.sar/web-console.war 
[jboss@node1 web-console.war]$ vi WEB-INF/jboss-web.xml
<!-- --> 
< jboss-web > 
   <!--  Uncomment the security-domain to enable security. You will need to edit the htmladaptor login nfiguration to setup thelogin modules used to authentication users. 
   <security-domain>java:/jaas/web-console</security-domain> 
   
--> 
  
   <!--  The war depends on the --> 
    < depends >jboss.admin:service=PluginManager </ depends > 
</ jboss-web > 
<!-- 修改为--> 
< jboss-web > 
   <!--  Uncomment the security-domain to enable security. You will need to edit the htmladaptor login configuration to setup the login modules used to authentication users. --> 
    < security-domain >java:/jaas/web-console </ security-domain > 

   <!--  The war depends on the --> 
    < depends >jboss.admin:service=PluginManager </ depends > 
</ jboss-web >
 

1.1.2.2          编辑web.xml文件

u   编辑web-console.war/WEB-INF/web.xml文件:
[jboss@node1 web-console.war]$ vi WEB-INF/jboss-web.xml
<!-- --> 
<? xml  version ="1.0" ?> 
<!DOCTYPE web-app PUBLIC 
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
   "http://java.sun.com/dtd/web-app_2_3.dtd"> 

< web-app > 
...... 
   <!--  A security constraint that restricts access to the HTML JMX console to users with the role JBossAdmin. Edit the roles to what you want and uncomment the WEB-INF/jboss-web.xml/security-domain element to enable secured access to the HTML JMX console. 

   <security-constraint> 
   <web-resource-collection> 
   <web-resource-name>HtmlAdaptor</web-resource-name> 
   <description>An example security config that only allows users with the 
   role JBossAdmin to access the HTML JMX console web application 
   </description> 
   <url-pattern>/*</url-pattern> 
   <http-method>GET</http-method> 
   <http-method>POST</http-method> 
   </web-resource-collection> 
   <auth-constraint> 
   <role-name>JBossAdmin</role-name> 
   </auth-constraint> 
   </security-constraint> 
   
--> 

    < login-config > 
       < auth-method >BASIC </ auth-method > 
       < realm-name >JBoss WEB Console </ realm-name > 
    </ login-config > 

    < security-role > 
       < role-name >JBossAdmin </ role-name > 
    </ security-role > 
</ web-app > 
<!-- 修改为--> 
<? xml  version ="1.0" ?> 
<!DOCTYPE web-app PUBLIC 
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
   "http://java.sun.com/dtd/web-app_2_3.dtd"> 

< web-app > 
   ...... 

   <!--  A security constraint that restricts access to the HTML JMX console to users with the role JBossAdmin. Edit the roles to what you want and uncomment the WEB-INF/jboss-web.xml/security-domain element to enable secured access to the HTML JMX console.--> 

    < security-constraint > 
    < web-resource-collection > 
    < web-resource-name >HtmlAdaptor </ web-resource-name > 
    < description >An example security config that only allows users with the 
   role JBossAdmin to access the HTML JMX console web application 
    </ description > 
    < url-pattern >/* </ url-pattern > 
    < http-method >GET </ http-method > 
    < http-method >POST </ http-method > 
    </ web-resource-collection > 
    < auth-constraint > 
    < role-name >JBossAdmin </ role-name > 
    </ auth-constraint > 
    </ security-constraint > 

    < login-config > 
       < auth-method >BASIC </ auth-method > 
       < realm-name >JBoss WEB Console </ realm-name > 
    </ login-config > 

    < security-role > 
       < role-name >JBossAdmin </ role-name > 
    </ security-role > 
</ web-app >

1.1.3               设置jmx-console帐户密码

1.1.3.1          增加账户

u  进入 JBOSS_HOME/server/default/conf/props文件夹
[jboss@node1 ~]$ cd JBOSS_HOME/server/default/conf/props
[jboss@node1 props]$ ls jmx*
jmx-console-roles.properties jmx-console-users.properties
        其中的jmx-console-roles.properties 是用户角色配置,而jmx-console-users.properties则是用户密码配置。
u  增加一个用户
[jboss@node1 props]$ vi jmx-console-roles.properties
#将
# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin,HttpInvoker
#修改为
admin=JBossAdmin,HttpInvoker
jboss=JBossAdmin,HttpInvoker
注意:配置文件里面左面的是用户,右面对应的是角色
u  为新增的用户设置密码
[jboss@node1 props]$ vi jmx-console-users.properties
#将
# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin
#修改为
admin=admin
jboss=jboss
注意:配置文件里面左面的是用户,右面对应的是密码

1.1.4               设置web-console帐户密码

    web-console的用户、角色、密码的设置与上面的jmx-console一致,只是配置文件web-console-roles.properties和web-console-users.properties的位置没有在上面的目录里,而是在JBOSS_HOME/server/default/deploy/management/
console-mgr.sar/web-console.war/WEB-INF/classes
的目录里。
    所以这里就不再重复上面的步骤,请读者自己进行操作。

1.2  JBoss其他重要的一些设置

1.2.1               JBoss集群名称修改

同一个网段内可能会有多个集群,所以要以集群的名字来区分它们。按照下面的方法修改 JBoss 集群的名字,使同一网段内的多个 JBoss 集群区分开来。
编辑 JBOSS_HOME/server/YOURCONDIF/deploy/cluster-service.xml 文件:
[jboss@node1 ~]$ vi JBOSS_HOME/server/YOURCONDIF
/deploy/cluster-service.xml
<!-- -->  
    
< mbean  code ="org.jboss.ha.framework.server.ClusterPartition" 
       name ="jboss:service=${jboss.partition.name:DefaultPartition}" > 
      <!--  Name of the partition being built --> 
< attribute  name ="PartitionName" > 
${jboss.partition.name:DefaultPartition} </ attribute > 
         ...... 
       < depends >jboss:service=Naming </ depends > 
    </ mbean > 
<!-- 修改为-->  

< mbean  code ="org.jboss.ha.framework.server.ClusterPartition" 
       name ="jboss:service=${jboss.partition.name:DefaultPartition}" > 
      <!--  Name of the partition being built --> 
           < attribute  name ="PartitionName" >你的集群的名字 </ attribute > 
         ...... 
       < depends >jboss:service=Naming </ depends > 
    </ mbean >

1.2.2               JBoss群集通讯协议

大型的 JBoss 集群使用 UDP 协议更好,可以减少网络流量。而对于小型的 JBoss 集群,使用 TCP 协议比较好,也比较安全。
编辑 JBOSS_HOME/server/YOURCONDIF/deploy/cluster-service.xml 文件:
[jboss@node1 ~]$ vi JBOSS_HOME/server/YOURCONDIF 
/deploy/cluster-service.xml
<!-- 查找--> 
< mbean  code ="org.jboss.ha.framework.server.ClusterPartition" 
       name ="jboss:service=${jboss.partition.name:DefaultPartition}" > 
......  
< Config > 
< UDP  mcast_addr ="${jboss.partition.udpGroup:228.1.2.3}"  mcast_port ="45566" 
ip_ttl ="${jgroups.mcast.ip_ttl:8}"  ip_mcast ="true" 
                mcast_recv_buf_size ="2000000"  mcast_send_buf_size ="640000" 
                ucast_recv_buf_size ="2000000"  ucast_send_buf_size ="640000" 
                loopback ="false" /> 
   ...... 
</ Config > 
</ mbean > 
<!-- 修改为--> 
< mbean  code ="org.jboss.ha.framework.server.ClusterPartition" 
       name ="jboss:service=${jboss.partition.name:DefaultPartition}" > 
  ...... 
<!--  
<Config> 
<UDP mcast_addr="${jboss.partition.udpGroup:228.1.2.3}" mcast_port="45566" 
ip_ttl="${jgroups.mcast.ip_ttl:8}" ip_mcast="true" 
               mcast_recv_buf_size="2000000" mcast_send_buf_size="640000" 
               ucast_recv_buf_size="2000000" ucast_send_buf_size="640000" 
               loopback="false"/> 
               ...... 
</Config> 
--> 
</ mbean > 
<!-- 查找--> 
< mbean  code ="org.jboss.ha.framework.server.ClusterPartition" 
       name ="jboss:service=${jboss.partition.name:DefaultPartition}" > 
  ...... 
<!--  
<Config> 
<TCP bind_addr="thishost" start_port="7800" loopback="true" 
                 recv_buf_size="2000000" send_buf_size="640000" 
                 tcp_nodelay="true" up_thread="false" down_thread="false"/> 
<TCPPING initial_hosts="thishost[7800],otherhost[7800]"  
port_range="3" timeout="3500"  num_initial_members="3" 
up_thread="false" down_thread="false"/> 
               ...... 
</Config> 
--> 
</ mbean > 
<!-- 修改为--> 
< mbean  code ="org.jboss.ha.framework.server.ClusterPartition" 
       name ="jboss:service=${jboss.partition.name:DefaultPartition}" > 
  ......
< Config > 
< TCP  bind_addr ="thishost"  start_port ="7800"  loopback ="true" 
                  recv_buf_size ="2000000"  send_buf_size ="640000" 
                  tcp_nodelay ="true"  up_thread ="false"  down_thread ="false" /> 
< TCPPING  initial_hosts ="thishost[7800],otherhost[7800]"  
port_range ="3"  timeout ="3500"   num_initial_members ="3" 
up_thread ="false"  down_thread ="false" /> 
               ...... 
</ Config > 
</ mbean >
同时,将“thishost”换成本机IP,“otherhost”换成另一台JBoss集群节点的IP。例如:
< Config > 
< TCP  bind_addr ="192.168.200.12"  start_port ="7800"  loopback ="true" 
                  recv_buf_size ="2000000"  send_buf_size ="640000" 
                  tcp_nodelay ="true"  up_thread ="false"  down_thread ="false" /> 
< TCPPING  initial_hosts ="192.168.200.12 [7800], 192.168.200.13 [7800]"  
port_range ="3"  timeout ="3500"   num_initial_members ="3" 
up_thread ="false"  down_thread ="false" /> 
               ......
</ Config >

1.2.3               JBoss字符集设置

JBoss 启动时默认使用的是系统字符集,而某些应用程序对于系统默认的字符集会出现不兼容的情况,如:打印出来的数据都是乱码。对于这种情况,可以在 JBoss 启动时定制应用程序使用自己的字符集。
u 使用vi命令编辑JBOSS_HOME/bin/run.conf文件:
[jboss@node1 ~]$ vi JBOSS_HOME/bin/run.conf
#在文件的上部加入字符集(红色字体部分)
## -*- shell-script -*- ###################################################### 
##                                                                          ## 
##  JBoss Bootstrap Script Configuration                                    ## 
##                                                                          ## 
############################################################################## 

### $Id: run.conf 62747 2007-05-02 17:43:36Z [email]dimitris@jboss.org[/email] $ 


# This file is optional; it may be removed if not needed. 



# Specify the maximum file descriptor limit, use "max" or "maximum" to use 
# the default, as queried by the system. 

# Defaults to "maximum" 

#MAX_FD="maximum" 
export LANG="zh_CN.GBK" 

# Specify the profiler configuration file to load. 

# Default is to not load profiler configuration file. 

#PROFILER=""
......
u   重新运行JBoss,乱码问题就可以解决了。
注意:上面的操作只是举个例子,字符集的修改需要根据实际情况而定。

本文转自xudayu 51CTO博客,原文链接:http://blog.51cto.com/xudayu/67210,如需转载请自行联系原作者

相关文章
|
5天前
|
存储 安全 Linux
问题记录:Redhat6.5 网卡配置变更后,Eth0变为Eth1
Red Hat Enterprise Linux 6.5(Redhat 6.5)尽管是一个较旧的操作系统版本,仍然在许多企业环境中发挥着重要作用。然而,老旧的系统并不免于技术挑战。例如,本文将探讨一个在修改网卡配置后遇到的一个奇怪问题:在网卡配置变更后,原本是eth0的网卡名称变更为了eth1。
问题记录:Redhat6.5 网卡配置变更后,Eth0变为Eth1
|
11天前
|
运维 监控 Ubuntu
怎样配置Linux分析工具:atop篇
在管理Linux系统时,了解系统级监控工具是至关重要的。其中,atop是一种功能强大的工具,它允许运维人员以实时的方式监控系统运行状态,包括进程活动、内存使用、磁盘I/O以及网络负载等。atop提供了一种简洁而全面的方式来追踪系统表现和资源消耗情况,使得性能分析变得简单而直观。
|
14天前
|
Ubuntu Linux Shell
Ubuntu/linux系统环境变量配置详解
理解和掌握如何配置环境变量对于使用和管理Ubuntu/Linux系统非常重要。
30 2
|
1月前
|
Linux Shell 持续交付
Linux下vim的配置
本文介绍了如何对vim进行基础配置,如行号显示、缩进设置等,并推荐了一种自动化部署方案,通过链接下载预配置的vim环境脚本,简化了配置过程,提升开发效率。
27 3
Linux下vim的配置
|
29天前
|
域名解析 网络协议 Linux
Linux系统下DNS配置指南
Linux系统下DNS配置指南
47 1
|
1月前
|
网络协议 Linux 网络安全
Linux配置SSH允许TCP转发
Linux配置SSH允许TCP转发
25 1
|
10天前
|
存储 运维 监控
怎样配置Linux分析工具:kdump篇
在运维的世界里,服务器的稳定运行是生命的灯塔,一旦遭遇异常重启,便是暴风雨来临的预兆。作为一名运维工程师,深知在这场与故障斗争的战役中,武器的锋利至关重要。今天,我要介绍的主角/工具——kdump,正是这样一款能在风雨来临之际,为我们捕获那一闪而过的真相的工具。
|
1月前
|
关系型数据库 MySQL Shell
【权限提升】Linux系统&环境变量&定时任务&权限配置不当&MDUT自动化
【权限提升】Linux系统&环境变量&定时任务&权限配置不当&MDUT自动化
|
1月前
|
Linux 数据处理 数据库
探索Linux的`infocmp`命令:终端配置的得力助手
`infocmp`是Linux下用于查看和比较`terminfo`数据库中终端类型描述的命令。它显示终端的控制序列、按键映射等信息,并能找出不同终端的配置差异。通过参数如`-c`(以termcap格式输出)、`-d`(比较差异)和`-1`(单列显示)等可定制输出。例如,`infocmp $TERM`显示当前终端配置,`infocmp xterm vt100`比较两者差异。了解终端类型和选择合适输出格式是有效使用的关键。
|
21天前
|
网络协议 Linux 开发工具
配置Linux固定IP地址,为什么要固定IP,因为他是通DHCP服务获取的,DHCP服务每次重启都会重新获取一次ip,VMware编辑中有一个虚拟网络编辑器
配置Linux固定IP地址,为什么要固定IP,因为他是通DHCP服务获取的,DHCP服务每次重启都会重新获取一次ip,VMware编辑中有一个虚拟网络编辑器