JBoss7配置指南(一)

来源:互联网 发布:广州多益网络 编辑:程序博客网 时间:2024/05/16 19:03

(整理翻译by Jim Ma)

1. 目标听众

    这篇文档是为需要安装配置JBoss Application Server(AS7)的人员编写

1.1 开始之前

你需要知道如何下载,安装和运行JBoss Application Server7. 如果你还不了解这些信息,请参考“入门指导"

1.2 手册中的示例

     手册种大部分的例子会使用部分XML配置文件或者是de-typed的管理模型进行表示

2. 客户端

      JBoss AS7提供三种不同的方式对服务器进行配置和管理: web,命令行和xml配置文件形式。无论你选择什么样的配置方式,配置信息都会被同步到各个方式的管理界面上,并且被存储到xml配置文件中。

2.1 web接口

     web管理客户端是一个GWT的应用,它通过HTPP管理接口来管理域(domain)或者是单独运行(standalone)的服务器

2.1.1 HTTP管理接入点

      基于HTTP协议的管理接入点负责接入 使用http协议与管理层进行交互 客户端。它负责接收使用JSON编解码的协议和de-typedRPC形式的的api来对可管理的域服务器或者单独运行服务器进行管理操作。web控制台就是通过它来实现的,但基于HTTP协议的管理接入点也可以与其他的管理终端进行集成,交互。
基于HTTP协议的管理点会运行在域控制器(domaincontroller)或者是单独运行服务器上,默认运行在9990端口上。

Xml代码 复制代码 收藏代码JBoss7配置指南(一)

  1. <management-interfaces>
  2. [...]  
  3. <http-interfaceinterface="management"port="9990"/>
  4. <management-interfaces>
<management-interfaces> [...] <http-interface interface="management" port="9990"/> <management-interfaces>

(参见 standalone/configuration/standalone.xml 或者domain/configuration/host.xml)

基于HTTP协议的管理接入点运行在两个不同的context下。一个用于运行管理的操作另外一个提供对web管理接口的访问。

  •     域API:http://<host>:9990/management
  •     Web控制台:http://<host>:9990/console

2.1.2访问管理控制台 :
     管理控制台和基于HTTP协议管理的API在统端口上运行,可以通过以下URL进行访问:

  •        http://<host>:9990/console

默认访问web管理页面的URL:http://localhost:9990/console.

2.1.3  对管理控制台进行加密

     web管理控制台通过HTTP管理接口来对服务器进行通信。对于如何机密HTTP管理接口以及如何启用默认的安全域,请参考一下本文中关于“加密管理接口"章节。

2.2 命令行接口

     命令行方式的管理工具(CLI)提供了对域和单独运行服务器的管理。用户可以使用命令行来连接域服务器或者单独运行服务器,通过传输de-typede的管理模型来执行管理操作。

2.2.1  Native管理接入点
     Native的管理接入点负责接入使用AS内部协议与管理层进行交互的客户端.它使用基于java对象来描述的管理操作、二进制协议和RPC形式的API来对域和单独运行服务器进行管理操作。命令行方式的管理工具使用它来实现对服务器的管理,单Native管理接入点也提供了极强的集成能力,可以和其他的客户端进行集成。

 Nativeg管理接入点运行在host控制器上或者是一个单独运行服务器上。如果使用命令行管理工具,Native管理接入点必须被启用.默认Native管理接入点运行在9999端口上:

<management-interfaces>
<native-interfaceinterface="management"port="9999"/>
[...]
<management-interfaces>

参见 standalone/configuration/standalone.xml 或者domain/configuration/host.xml)

2.2.2 运行命令行管理工具

根据操作系统,使用JBossAS7bin目录下的jboss-admin.sh或者jboss-admin.bat来启动命令行管理工具.关于AS7目录的详细信息,请参考"入门指南".
      命令行工具启动以后的第一件事情就是连接被管理的Jboss AS7实例。我们通过命令connect进行:

Java代码 复制代码 收藏代码JBoss7配置指南(一)

  1. ./bin/jboss-admin.sh  
  2. You are disconnected at the moment. Type 'connect' to connectto the server  
  3. or 'help' for the list of supportedcommands.  
  4. [disconnected /]  
  5. [disconnected /]connect  
  6. Connected to domain controller at localhost:9999
  7. [domain@localhost:9999 /]quit  
  8. Closed connection to localhost:9999
./bin/jboss-admin.sh You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands. [disconnected /] [disconnected /] connect Connected to domain controller at localhost:9999 [domain@localhost:9999 /] quit Closed connection to localhost:9999

localhost:9999是JBossAS7域控制器客户端连接的默认主机和端口名.主机名和端口都是可选的参数,可以被单独或者一起指定。想要退出对话,可以键入quit命令来结束。

Xml代码 复制代码 收藏代码JBoss7配置指南(一)

  1. jboss-admin脚本可以接收--cnnect参数: ./jboss-admin.sh--connenct 
jboss-admin脚本可以接收--cnnect参数: ./jboss-admin.sh --connenct

help命令用来显示参考帮助文档:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. [domain@localhost:9999 /]help  
  2. Supported commands:  
  3. cn (orcd)            - change the current node path to theargument;  
  4. connect               - connect to the specified host andport;  
  5. deploy                - deploy an application;  
  6. help (orh)           - print this message;  
  7. history               - print or disable/enable/clear the historyexpansion.  
  8. ls                    - list the contents of the nodepath;  
  9. pwn (orpwd)          - prints the current workingnode;  
  10. quit (orq)           - quit the command lineinterface;  
  11. undeploy              - undeploy an application;  
  12. version               - prints the version and environmentinformation.  
  13. add-jms-queue         - creates a new JMS queue  
  14. remove-jms-queue      - removes an existing JMSqueue  
  15. add-jms-topic         - creates a new JMS topic  
  16. remove-jms-topic      - removes an existing JMStopic  
  17. add-jms-cf            - creates a new JMS connectionfactory  
  18. remove-jms-cf         - removes an existing JMS connectionfactory  
  19. data-source           - allows to add new, modify and remove existing datasources  
  20. xa-data-source        - allows to add new, modify and remove existing XA datasources 
[domain@localhost:9999 /] help Supported commands: cn (or cd) - change the current node path to the argument; connect - connect to the specified host and port; deploy - deploy an application; help (or h) - print this message; history - print or disable/enable/clear the history expansion. ls - list the contents of the node path; pwn (or pwd) - prints the current working node; quit (or q) - quit the command line interface; undeploy - undeploy an application; version - prints the version and environment information. add-jms-queue - creates a new JMS queue remove-jms-queue - removes an existing JMS queue add-jms-topic - creates a new JMS topic remove-jms-topic - removes an existing JMS topic add-jms-cf - creates a new JMS connection factory remove-jms-cf - removes an existing JMS connection factory data-source - allows to add new, modify and remove existing data sources xa-data-source - allows to add new, modify and remove existing XA data sources

查看特定命令的详细帮助文档,需要在命令后加"--help"参数来获得。

2.2.3 管理请求

       管理请求允许与管理模型进行低级别的交互。它不同于高级别的命令(比如创建一个jms的queue命令:create-jms-queue),使用管理请求可以对服务器的配置像对直接对xml配置文件进行编辑而进行读和修改操作。整个配置用一个有地址的资源树进行表示,这个树上的每个节点提供一系列的操作供执行。
一个管理请求包含三个部分:地址,操作名和可选的操作参数
这是一个管理请求的规约:

规约代码 复制代码 收藏代码JBoss7配置指南(一)

  1. [/node-type=node-name (/node-type=node-name)*] : operation-name[( [parameter-name=parameter-value(,parameter-name=parameter-value)*] )] 
[/node-type=node-name (/node-type=node-name)*] : operation-name [( [parameter-name=parameter-value (,parameter-name=parameter-value)*] )]

举个例子:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. /profile=production/subsystem=threads/bounded-queue-thread-pool=pool1:write-core-threads(count=0, per-cpu=20) 
/profile=production/subsystem=threads/bounded-queue-thread-pool=pool1:write-core-threads (count=0, per-cpu=20)

Tab补全代码 复制代码 收藏代码JBoss7配置指南(一)

  1. Tab补全:  
  2. 所有的命令和参数都支持tab补全。比如结点的类型,名字,操作名和参数名。我们正考虑增加别名在tab补全时可以显示更少的选项,然后在后台翻译成相应的管理请求。 
Tab补全: 所有的命令和参数都支持tab补全。比如结点的类型,名字,操作名和参数名。我们正考虑增加别名在tab补全时可以显示更少的选项,然后在后台翻译成相应的管理请求。

    管理请求字符串之间的空格是不敏感的 。

2.2.3.1 管理资源的地址

  管理请求可以不含有地址信息和参数,比如::read-resource, 可以列出当前Node下的所有节点类型。

在管理命令中,为了消除歧义需要以下几个前缀:

  • "  :"   ---在当前节点上执行操作,比如:

  [subsystem=web]:read-resource(recursive="true")

  •   "./"  ---- 在当前节点的子节点上执行操作,如:

          [subsystem=web] ./connector=http:read-resource
  这个操作的全路径地址是: subsystem=web,connector=http.

  •    "/" --- 在根节点上执行操作,如:

    [subsystem=web] /:read-resource  或子节点: [subsystem=web] /subsystem=logging:read-resource

2.2.3.2 操作类型和操作描述列表

      操作的类型可以分为在任何节点上的通用操作和在特殊节点上的特殊操作(如:subsystem).通用的操作包括:

操作列表代码 复制代码 收藏代码JBoss7配置指南(一)

  1. add  
  2. remove  
  3. read-attribute  
  4. write-attribute  
  5. read-children-names  
  6. read-children-resources  
  7. read-children-types  
  8. read-operation-description  
  9. read-operation-names  
  10. read-resource  
  11. read-resource-description 
 add remove read-attribute write-attribute read-children-names read-children-resources read-children-types read-operation-description read-operation-names read-resource read-resource-description

      对于特殊操作列表(比如在logging子系统上可以进行的特殊操作),可以通过管理的节点进行查询。比如,查询一个单独运行服务器上logging子系统上所支持的操作:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. [[standalone@localhost:9999 /]/subsystem=logging:read-operation-names  
  2. {  
  3. "outcome" =>"success",  
  4. "result" =>[  
  5. "add",  
  6. "change-root-log-level",  
  7. "read-attribute",  
  8. "read-children-names",  
  9. "read-children-resources",  
  10. "read-children-types",  
  11. "read-operation-description",  
  12. "read-operation-names",  
  13. "read-resource",  
  14. "read-resource-description",  
  15. "remove-root-logger",  
  16. "set-root-logger",  
  17. "write-attribute"
  18.   ]  
[[standalone@localhost:9999 /] /subsystem=logging:read-operation-names { "outcome" => "success", "result" => [ "add", "change-root-log-level", "read-attribute", "read-children-names", "read-children-resources", "read-children-types", "read-operation-description", "read-operation-names", "read-resource", "read-resource-description", "remove-root-logger", "set-root-logger", "write-attribute" ] }

       可以看出,logging支持三个额外特殊的操作:change-root-log-level , set-root-logger andremove-root-logger.

进一步关于被管理节点描述或者被管理节点上操作的描述,可以通过一下命令查询:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. [standalone@localhost:9999 /]/subsystem=logging:read-operation-description(name=change-root-log-level)  
  2. {  
  3. "outcome" =>"success",  
  4. "result" =>{  
  5. "operation-name"=>"change-root-log-level",  
  6. "description"=> "Change the root loggerlevel.",  
  7. "request-properties"=> {"level"=> {  
  8. "type" =>STRING,  
  9. "description"=> "The log level specifying whichmessage levels will be logged by thislogger.  
  10.                            Message levels lower than this value will bediscarded.",  
  11. "required" =>true  
  12.       }}  
  13.   }  
[standalone@localhost:9999 /] /subsystem=logging:read-operation-description(name=change-root-log-level) { "outcome" => "success", "result" => { "operation-name" => "change-root-log-level", "description" => "Change the root logger level.", "request-properties" => {"level" => { "type" => STRING, "description" => "The log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded.", "required" => true }} } }

Java代码 复制代码 收藏代码JBoss7配置指南(一)

  1. <STRONG>递归模式查看全部信息输入::read-resource(recursive=true).</STRONG> 
递归模式查看全部信息输入::read-resource(recursive=true). 

2.2.4 命令行历史信息

      命令行(和操作请求)历史信息默认是开启的。历史信息在内存中和硬盘文件中都有保存,并且命令行历史信息在命令行对话之间保存。
      命令行历史信息文件信息保存在名为.jboss-cli-history的文件中,这个文件会在用户的home目录下自动创建。当启动命令行模式时,这个文件会被读入内存中来对初始化命令行历史信息。
   在命令行对话中,你可以使用上下键来向前和向后查阅命令行历史信息。

     命令行历史可以通过history命令进行操作。如果history命令执行时不带参数,它会将内存中所有的历史命令和操作打印出来(取决于历史信息的最大个数,默认500).history 命令支持3个可选的参数:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. disable-关闭历史记录功能(但不会清除已经记录的历史信息)  
  2. enable-开启历史记录功能(从上次关闭历史记录前的最后一条记录开始)  
  3. clear-清除内存种的历史记录(但不会清除文件中的信息)  
disable-关闭历史记录功能(但不会清除已经记录的历史信息) enable-开启历史记录功能(从上次关闭历史记录前的最后一条记录开始) clear-清除内存种的历史记录(但不会清除文件中的信息)

2.2.5 批处理

       批处理模式允许用户以将一组命令和操作按照原子的方式执行。如果一个命令或者操作失败,那么在批处理中成功执行的子命令将会被回滚。
       不是所有的命令都可以批处理种执行。比如: cd, ls, help等不能被转换成操作请求的就不可以在批处理种执行。只有可以转换成为操作请求的命令才可以在批处理种执行。批处理的命令实际上是
以组合操作请求的方式执行的。
执行batch命令进入批处理模式:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. [standalone@localhost:9999 /]batch  
  2. [standalone@localhost:9999 / #]/subsystem=datasources/data-source="java\:\/H2DS":enable  
  3. [standalone@localhost:9999 / #]/subsystem=messaging/jms-queue="newQueue":add 
[standalone@localhost:9999 /] batch [standalone@localhost:9999 / #] /subsystem=datasources/data-source="java\:\/H2DS":enable [standalone@localhost:9999 / #] /subsystem=messaging/jms-queue="newQueue":add

run-batch执行一个批处理:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. [standalone@localhost:9999 / #]run-batch  
  2. The batch executed successfully. 
[standalone@localhost:9999 / #] run-batch The batch executed successfully.

退出批处理编辑模式并且不丢失更改:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. [standalone@localhost:9999 / #]holdback-batch  
  2. [standalone@localhost:9999 /] 
[standalone@localhost:9999 / #] holdback-batch [standalone@localhost:9999 /]

稍后重新激活批处理:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. [standalone@localhost:9999 /]batch  
  2. Re-activated batch  
  3. #1/subsystem=datasources/data-source=java:/H2DS:\/H2DS:enable 
[standalone@localhost:9999 /] batch Re-activated batch #1 /subsystem=datasources/data-source=java:/H2DS:\/H2DS:enable

还有一些比较重要的批处理命令(使用tab补全来查看以下列表):

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. clear-batch  
  2. edit-batch-line (e.g. edit-batch line 3 create-jms-topicname=mytopic)  
  3. remove-batch-line (e.g. remove-batch-line3)  
  4. move-batch-line (e.g. move-batch-line 31)  
  5. discard-batch  
 clear-batch edit-batch-line (e.g. edit-batch line 3 create-jms-topic name=mytopic) remove-batch-line (e.g. remove-batch-line 3) move-batch-line (e.g. move-batch-line 3 1) discard-batch

2.3 配置文件

域管理和单服务器的xml配置可以在configuration子目录下找到:

Shell代码 复制代码 收藏代码JBoss7配置指南(一)

  1. domain/configuration/domain.xml  
  2. domain/configuration/host.xml  
  3. standalone/configuration/standalone.xml 
 domain/configuration/domain.xml domain/configuration/host.xml standalone/configuration/standalone.xml

      一个被管理的域有两种类型的配置:一种是对整个域的配置(domain.xml)另外一种是对每个加入到域里主机(host)的配置(host.xml).关于如何配置域拓详细信息请参考"域配置"章节。xml配置是核心可靠的配置源。任何通过web接口或者命令行方式对配置的更改都持久化到XML配置文件中.如果一个域或者单独服务器离线,xml配置文件也可以进行手动更改,任何更改都在下一次启动时生效。
       但是,我们鼓励用户使用web接口或者命令行方式更改配置文件,而不是采用离线编辑的方式对配置文件进行更改。对正在处理的配置文件进行的外部更改将不会被探测到,从而有可能会被覆盖。

原创粉丝点击