Tomcat 5.5-Manager App HOW-TO(翻译了部份,努力中...)

偶也是学习,不过,觉得每次都是读英文,麻烦,就希望把它翻译成中文,为自己,也为其它想学习的朋友,呵呵.
不过,由于内容比较多,可能翻译的时间要多一点,如果有兴趣合作的朋友,可以回复BLOG,留言您想翻译那一段.
让我们一起完成该内容.
不过,为了增加文档的可阅读性,把阅读当成一种享受,请在翻译的时候遵守以下几点:
1).翻译的字体一律用绿色.保证阅读不那么伤眼睛.
2).重点标题用红色标明,重点内容用蓝色标注.
3).原始地址:http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html

The Apache Jakarta Tomcat 5.5 Servlet/JSP Container

Manager App HOW-TO/管理应用程序文档



Table of Contents/内容列表
 

Introduction/介绍
Configuring Manager Application Access/配置管理应用程序权限
Supported Manager Commands/支持的管理命令

Deploy A New Application Remotely/远程打包应用程序
Deploy A New Application from a Local Path/从本地路径打包应用程序
List Currently Deployed Applications/列表最近打包的应用程序
Reload An Existing Application/重载已经存在的应用程序
List OS and JVM Properties/操作系统与JAVA虚拟机属性列表
List Available Global JNDI Resources/全局JNDI资源变量列表
List Available Security Roles/安全角色变量列表
Session Statistics/Session统计
Start an Existing Application/启动存在的应用程序
Stop an Existing Application/停止应用程序
Undeploy an Existing Application/应用程序解包
Executing Manager Commands With Ant/用Ant执行管理命令
Using the JMX Proxy Servlet/使用JMX代理Servlet
What is JMX Proxy Servlet?/什么是JMX代理Servlet?
Query command/查询命令
Set command/命令设置




Introduction/介绍


 

In many production environments, it is very useful to have the capability to deploy a new web application, or undeploy an existing one, without having to shut down and restart the entire container. In addition, you can request an existing application to reload itself, even if you have not declared it to be reloadable in the Tomcat 5 server configuration file.

在许多产品环境中,拥用打包一个新的网络应用程序或者是解包一个已经存在网络应用程序的能力,而不是关闭后再重新启动整个容器,这往往是非常有用的。另个,你可以请求一个存在的应用程序自动重新加载,即使你没有在Tomcat 5中定义可重新加载。

To support these capabilities, Tomcat 5 includes a web application (installed by default on context path /manager) that supports the following functions:

为了使这些得到支持,Tomcat 5中包括了支持一个以下功能的网络应用程序(安装在默认的路径/manager):

  • Deploy a new web application, on a specified context path, from the uploaded contents of a WAR file.
  • 从指定路径上传的WAR文件打包新的WEB应用程序.
  • Deploy a new web application, on a specified context path, from the server file system.
  • 从指定路径服务器文件系统打包新的WEB应用程序.
  • List the currently deployed web applications, as well as the sessions that are currently active for those web apps.
  • 列表当前打包的WEB应用程序,包括当前为这些应用程序处于活动的SESSION.
  • Reload an existing web application, to reflect changes in the contents of /WEB-INF/classes or /WEB-INF/lib.
  • 重载一个已经存在的应用程序,以使用/WEB-INF/classes or /WEB-INF/lib下的内容更改生效.
  • List the OS and JVM property values.
  • 操作系统与JAVA虚拟机属性列表.
  • List the available global JNDI resources, for use in deployment tools that are preparing <ResourceLink> elements nested in a <Context> deployment description.
  • 全局JNDI资源变量列表,这是为了使用在打包工具中用上他们.
  • List the available security roles defined in the user database.
  • 列表在用户数据库中定的可用的安全角色.
  • Start a stopped application (thus making it available again).
  • 启动一个停止的应用程序(使它再次成为可用).
  • Stop an existing application (so that it becomes unavailable), but do not undeploy it.
  • 停止应用程序(使用成为不可用),但去不解包.
  • Undeploy a deployed web application and delete its document base directory (unless it was deployed from file system).
  • 解包应有程序并且删除它的文档基目录(除非它是从文件系统打包的).

There are two ways to configure the Manager web application Context:

这里有两种方式配置管理应用程序环境:

  • Install the manager.xml context configuration file in the $CATALINA_HOME/conf/[enginename]/[hostname] folder.
  • 安装环境配置文件manager.xml 在文件夹$CATALINA_HOME/conf/[enginename]/[hostname]中.
  • Configure the Manager Context within the Host configuration in your Tomcat server.xml configuration. Here is an example:

    在你的Tomcat server.xml 配置中的主机配置下配置管理环境.下面是一个例子:

    <Context path="/manager" debug="0" privileged="true"
             docBase="/usr/local/kinetic/tomcat5/server/webapps/manager">
    </Context>
    

If you have Tomcat configured to support multiple virtual hosts (websites) you would need to configure a Manager for each.

如果你已经将Tomcat配置成支持多个虚拟主机(网站),你就需要分别为其配置一个管理器.

There are three ways to use the Manager web application.

有三种方式可以应用网络应用程序管理器.

  • As an application with a user interface you use in your browser. Here is an example URL where you can replace localhost with your website host name: http://localhost/manager/html/ .
  • 在你的浏览器中成为一个具有用户接口的应用程序.这里有一个示例URL,在这里你可以用你的网站主机名取代localhost.
  • A minimal version using HTTP requests only which is suitable for use by scripts setup by system administrators. Commands are given as part of the request URI, and responses are in the form of simple text that can be easily parsed and processed. See Supported Manager Commands for more information.
  • 一个仅仅使用HTTP请求基本版本,该版本适用于系统管理员用脚本进行的配置.命令作为请求URL的一部份,并且回应是以简单的文本的形式,这些文本可以很方便的被语法分析及处理.查看支持管理命令了解更详细的信息.
  • A convenient set of task definitions for the Ant (version 1.4 or later) build tool. See Executing Manager Commands With Ant for more information.
  • 为Ant(1.4或者是更高版本)编译工具的一种方便的任务定义设置.查看用Ant执行管理命令了解更多信息.

Future versions of Tomcat 5 will include administrative functionality that is presented in (at least) the following forms:

Tomcat 5 后面的版本包括了以下形式的管理功能:

  • As web services, so that Tomcat administration can be easily integrated into remote and/or non-Java management environments.
  • 作为网络服务器.这样Tomcat管理就可以很容易的集成到远程以及/或者是非JAVA管理环境中.
  • As a web application with a nice user interface (built on top of the web services processing layer) for easy Tomcat administration via a web browser.
  • 为简化通过网络浏览器对Tomcat管理,成为具有好的用户接口的网络应用程序(基于网络服务处理层顶层).




Configuring Manager Application Access/配置管理应用权限


 

The description below uses the variable name $CATALINA_HOME to refer to the directory into which you have installed Tomcat 5, and is the base directory against which most relative paths are resolved. However, if you have configured Tomcat 5 for multiple instances by setting a CATALINA_BASE directory, you should use $CATALINA_BASE instead of $CATALINA_HOME for each of these references.

下面的描述使用了变量$CATALINA_HOME来表示你的Tomcat 5的安装目录,and is the base directory against which most relative paths are resolved.然而,如果你通过设置CATALINA_BASE目录将Tomcat 5 配置成多个实例,那么你不得不为每个实例使用$CATALINA_BASE而不是$CATALINA_HOME.

It would be quite unsafe to ship Tomcat with default settings that allowed anyone on the Internet to execute the Manager application on your server. Therefore, the Manager application is shipped with the requirement that anyone who attempts to use it must authenticate themselves, using a username and password that have the role manager associated with them. Further, there is no username in the default users file (<conf></conf>$CATALINA_HOME/conf/tomcat-users.xml) that is assigned this role. Therefore, access to the Manager application is completely disabled by default.

让Tomcat运行在默认可以使任何网络用户都能够在你的服务器上执行管理应用,那将是非常危险的.因此,管理应用运行在具有用户名和密码认证并且分配了管理员权限的用户操作下.以后,在默认的用户文件中(<conf></conf>$CATALINA_HOME/conf/tomcat-users.xml)将不会分配该角色.因此,存取管理应用就完全取消了默认的操作.

To enable access to the Manager web application, you must either create a new username/password combination and associate the role name manager with it, or add the manager role to some existing username/password combination. Exactly where this is done depends on which Realm implementation you are using:

为了能够使存取管理网络应用成为活动,你要么要建立一个用户名和密码组合并赋予其管理员权限,或者把管理员权限加到一些已经存在用户/密码组合中.而要使之成立,还要最终取于你使用的域引用:

  • MemoryRealm - If you have not customized your $CATALINA_HOME/conf/server.xml to select a different one, Tomcat 5 defaults to an XML-format file stored at $CATALINA_HOME/conf/tomcat-users.xml, which can be edited with any text editor. This file contains an XML <user> for each individual user, which might look something like this:
    <user name="craigmcc" password="secret" roles="standard,manager" />
    
    which defines the username and password used by this individual to log on, and the role names he or she is associated with. You can add the manager role to the comma-delimited roles attribute for one or more existing users, and/or create new users with that assigned role.

    内存域-如果你使用的是默认的配置文件$CATALINA_HOME/conf/server.xml,该配置文件可以被任意文本编辑器编辑.该文件为每个独立用户包含了一个XML<用户>,该配置看起来如下:

    <user name="craigmcc" password="secret" roles="standard,manager" />
    
    该文件定义了用于个人登陆使用的用户名和密码以及他或她被分配置的权限.你可以在逗号后为一个或者是多个用户增加管理员角色,并且/或者创建新用户并带分配好的角色.
  • JDBCRealm - Your user and role information is stored in a database accessed via JDBC. Add the manager role to one or more existing users, and/or create one or more new users with this role assigned, following the standard procedures for your environment.
  • JDBC域-你的用户名存储在数据库中,该数据库通过JDBC访问。将管理员角色加到一个或者是多个已经存在用户上,并且/或者是创建一个或者是多个分配该角色的用户,这依据你环境中标准过程。
  • JNDIRealm - Your user and role information is stored in a directory server accessed via LDAP. Add the manager role to one or more existing users, and/or create one or more new users with this role assigned, following the standard procedures for your environment.
  • JNDI(Java Name and Directory Interface:Java命名及目录接口)域-你的用户名及密码存储于一个目录服务中,该用户名及密码通过LDAP(Lightweight Directory Access Protocol:轻量级目录存取协议)存取。为一个或者是多个用户增加管理员角色,并且/或者创建一个或者多个已分配该角色的用户,这依据你环境中标准过程。

The first time you attempt to issue one of the Manager commands described in the next section, you will be challenged to log on using BASIC authentication. The username and password you enter do not matter, as long as they identify a valid user in the users database who possesses the role manager.

在你第一次尝试使用会在下一节中谈到的管理命令时,你会被要求基本的认证。输入的用户名及密码无所谓,只要在用户数据库的被认为是合法的管理员角色。

In addition to the password restrictions the manager web application could be restricted by the remote IP address or host by adding a RemoteAddrValve or RemoteHostValve. Here is an example of restricting access to the localhost by IP address:

为了密码限制,管理应用程序能够通过增加RemoteAddrValve或者是RemoteHostValve来限制远程IP地址或者是主机.下面是一个示例,该示例通过IP地址来限制存取权限:

<Context path="/manager" debug="0" privileged="true"
         docBase="/usr/local/kinetic/tomcat5/server/webapps/manager">
         <Valve className="org.apache.catalina.valves.RemoteAddrValve"
                allow="127.0.0.1"/>
</Context>
Supported Manager Commands/支持的管理命令

All commands that the Manager application knows how to process are specified in a single request URI like this:

管理程序程序怎么样处理的所有命令,都被指定为像下面这样一个独立的URL一样:

http://{host}:{port}/manager/{command}?{parameters}

where {host} and {port} represent the hostname and port number on which Tomcat is running, {command} represents the Manager command you wish to execute, and {parameters} represents the query parameters that are specific to that command. In the illustrations below, customize the host and port appropriately for your installation.

{主机}与{端口}表示的是运行Tomcat服务器的主机与端口,{命令}代表是是你希望执行的命令,{参数}是指你为命令指定的查询参数.在下面的演示中,为你的主机自定义合适的主机与端口.

Most commands accept one or more of the following query parameters:

大多数的命令都接受一个或者是多个像下面这样的参数:

  • path - The context path (including the leading slash) of the web application you are dealing with. To select the ROOT web application, specify "/". NOTE - It is not possible to perform administrative commands on the Manager application itself.
  • 路径 - 当前处理的网站应用程序的路径(包括最前面的"/").指定"/"选择根下网站应用程序.: - 不能够在管理应用程序自身执行管理员命令.
  • war - URL of a web application archive (WAR) file, pathname of a directory which contains the web application, or a Context configuration ".xml" file. You can use URLs in any of the following formats:

    网站应用程序压缩文件 - 一个网站应用程序压缩文件的URL,包括该网站应用程序的目录路径名,或者是一个环境配置的".XML"文件.你可以使用像下面的任何一种URL格式:

    • file:/absolute/path/to/a/directory - The absolute path of a directory that contains the unpacked version of a web application. This directory will be attached to the context path you specify without any changes.
    • file:/absolute/path/to/a/directory - 包括未解包的网站应用程序的绝对路径.该目录将会在不改变的情况下被指定到环境路径中.
    • file:/absolute/path/to/a/webapp.war - The absolute path of a web application archive (WAR) file. This is valid only for the /deploy command, and is the only acceptable format to that command.
    • file:/absolute/path/to/a/webapp.war - 网站应用程序压缩文件的绝对路径.这只对根下的打包命令(/deploy)有效,并且是打包命令唯一能够接受的格式.
    • jar:file:/absolute/path/to/a/warfile.war!/ - The URL to a local web application archive (WAR) file. You can use any syntax that is valid for the JarURLConnection class for reference to an entire JAR file.
    • jar:file:/absolute/path/to/a/warfile.war!/ - 本地网站应用程序压缩文件的URL.为了引用整个(JAR)文件,你可以使用任何一种JarURLConnection类接受的语法格式
    • file:/absolute/path/to/a/context.xml - The absolute path of a web application Context configuration ".xml" file which contains the Context configuration element.
    • file:/absolute/path/to/a/context.xml - 网站环境配置文件".XML"的绝对路径,该文件包括环境配置元素.
    • directory - The directory name for the web applciation context in the Host's application base directory.
    • directory - 位于主机应用程序基本目录中,网站应用程序环境中的目录名.
    • webapp.war - The name of a web application war file located in the Host's application base directory.
    • webapp.war - 位于主机应用程序基本目录中的网站应用程序的war文件名

Each command will return a response in text/plain format (i.e. plain ASCII with no HTML markup), making it easy for both humans and programs to read). The first line of the response wil begin with either OK or FAIL, indicating whether the requested command was successful or not. In the case of failure, the rest of the first line will contain a description of the problem that was encountered. Some commands include additional lines of information as described below.

每个命令都会以纯文件的形式返回响应结果(在IE中,不带HTML的纯ASCII),这样不仅方便人进行阅读,也文件程序解释.响应结果的第一行是以成功或者是失败为开头,表明请求命令是否执行成功.在失败的情况下,后面的行就会描述该所遇到的问题.有一些命令还会包含一些如下的信息行:

Internationalization Note - The Manager application looks up its message strings in resource bundles, so it is possible that the strings have been translated for your platform. The examples below show the English version of the messages.

国际化提示:管理应用程序在它的资源绑定中查询消息字符串,因些有可能就是那些字符串已经被转换为适合于你当前使用平台的字符串.下面的例子显示了英语版的消息:

WARNING: the legacy commands /install and /remove are deprecated. They are presently equivalent to /deploy and /undeploy, but could be removed in a future release.

警告:原来的/安装与/移除命令已经不再使用.他们的等价命令是/打包与/解包,但可能还会将来的版本被移除.

Deploy A New Application Remotely/远程打包新的应用程序
http://localhost:8080/manager/deploy?path=/foo

Upload the web application archive (WAR) file that is specified as the request data in this HTTP PUT request, install it into the appBase directory of our corresponding virtual host, and start it on the context path specified by the path request parameter. If no path is specified the directory name or the war file name without the .war extension is used as the path. The application can later be undeployed (and the corresponding application directory removed) by use of the /undeploy.

根据请求数据的HTTP PUT请求,上传网站应用程序压缩文件,将其安装在与我们虚拟机相同的appBase目录,通过环境路径中指定的路径参数启动它.如果没有在目录名中指定路径,或者是在路径中使用的文件名没有.war扩展名.应用程序可以通过/undeploy命令来解包(并且相关的应用程序目录将会被移除).

The .WAR file may include Tomcat specific deployment configuration, by including a Context configuration XML file in /META-INF/context.xml.

通过在包括在/META-INF/context.xml的配置文件,WAR文件可能包括了Tomcat指定的解包配置.

URL parameters include:

包括的URL参数:

  • update: When set to true, any existing update will be undeployed first. The default value is set to false.
  • 更新:当设置成真的时候,任何存在的更新都首先会解包.默认的值是假.
  • tag: Specifying a tag name, this allows associating the deployed webapp with a version number. The application version can be later redeployed when needed using only the tag.
  • 标记:指定一个标记名.这就允许用一个版本号与打包的webapp进行关联.当只需要标签时,应用程序版本可以后面被解包.

NOTE - This command is the logical opposite of the /undeploy command.

注:这个命令在逻辑上是与/undeploy相对的.

If installation and startup is successful, you will receive a response like this:

如果安装及启动都成功,你就会得到像下面的一条响应:

OK - Deployed application at context path /foo

Otherwise, the response will start with FAIL and include an error message. Possible causes for problems include:

否则,响应开头就会包括包括FAIL并且包括错误信息.可能造成错误的原因有:

  • Application already exists at path /foo 应用程序已经存在于/foo

    The context paths for all currently running web applications must be unique. Therefore, you must undeploy the existing web application using this context path, or choose a different context path for the new one. The update parameter may be specified as a parameter on the URL, with a value of true to avoid this error. In that case, an undeploy will be performed on an existing application before performing the deployment.

    当前运行的网站应用程序的环境配置路径必须是唯一的.因此,你必须使用环境路径解包存在的网站应用程序,或者为新的应用程序选择一个不同的环境路径.更新的参数可以URL参数的形式指定,带上真值就可以避免该错误.在那种情况下,对于已经丰在的应用程序,解包命令undeploy就会先于打包命令deploy而执行.

  • Encountered exception 遇到异常

    An exception was encountered trying to start the new web application. Check the Tomcat 5 logs for the details, but likely explanations include problems parsing your /WEB-INF/web.xml file, or missing classes encountered when initializing application event listeners and filters.

    当试着启动应用程序的时候遇到了异常.检查Tomcat 5的日志文件可以查看详细信息,但可能发生的异常包括解析你的/WEB-INF/web.xml文件,或者在初使化应用程序事件监听器及过滤器的时候丢失了类.

  • Invalid context path was specified 指定的非法的环境路径

    The context path must start with a slash character. To reference the ROOT web application use "/".

    环境路径必须以/符号开始.使用/符号表示的就是网站应用程序的根目录.

  • No context path was specified 没有指定环境路径
    The path parameter is required.

    要求路径参数.

你可能感兴趣的:(tomcat,应用服务器,Web,网络应用,配置管理)