为什么同一 CATALINA_HOME 的多个 tomcat 实例需要单独的库?
我正在阅读 Tomcat:权威指南,了解如何从同一安装中部署多个 tomcat 实例。它们描述了您需要如何分离出特定于实例的文件夹,从而使核心 CATALINA_HOME 内容保持干净;这种分离还为 tomcat 版本之间的干净升级提供了基础。
他们建议将许多内容放入实例特定目录中,例如conf和webapps——这些文件夹包含明显的应用程序特定数据。但是,还建议拉出包含运行时类的 jar 的所有文件夹。直接引用他们的书:
此外,可能需要从共享、服务器和公共目录树加载一些 jar 文件和类文件。这意味着要使多个实例正常工作,每个 Tomcat 实例都必须拥有自己的一组目录;它们不能由两个不同配置的 Tomcat JVM 实例共享。
为什么不同的实例需要它们自己的 jar 文件?是否不可能将两个同时执行的 jvm 指向同一组 jar 文件?
注意:这是关于tomcat 5.5和6.0
I'm reading Tomcat: The Definitive Guide to learn how to deploy multiple instances of tomcat from the same installation. They describe how you need to separate out the folders that are instance specific, thus leaving the core CATALINA_HOME stuff clean; this separation also provides the basis for clean upgrades between versions of tomcat as well.
A lot of the stuff they recommend pulling out into instance specific directories make sense, such as conf and webapps -- those folders contain the obvious application specific data. However, the also recommend pulling out all of the folders that contain the jars that hold runtime classes. To quote directly from their book:
Also, some jar files and class files may need to be loaded from the shared, server, and common directory trees. This means that for multiple instances to work, each Tomcat instance has to have its own set of these directories; they cannot be shared by two differently configured Tomcat JVM instances.
Why would separate instances require their own jar files? Is it not possible to point two concurrently executing jvm's at the same set of jar files?
Note: this is about tomcat 5.5 and 6.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,我正在回答我自己的问题。首先,需要注意的是,您需要拥有特定于实例的 lib 目录副本的原因与 jvm 对一组 jar 文件的并发访问无关。
您必须将这些库文件复制到实例特定的目录结构(也称为 CATALINA_BASE)的原因是,在 tomcat 5.5 和早期 6.0 版本中,tomcat 只能使用单个文件夹作为共享、服务器中找到的库的类路径源和常见的。这意味着,如果给定的 tomcat 实例需要添加或修改这些文件夹中的库,则您必须制作整个新实例的共享、公共和服务器特定版本,或者库的修改(如果在 CATALINA_HOME 中完成)影响从该 CATALINA_HOME 运行的所有实例。
从 TOMCAT 6.0.24(左右)开始,能够从 CATALINA_BASE 和 CATALINA_HOME 中的共享、公共和服务器库文件夹加载类,提供更精细的控制粒度,以便您的修改可以放在 BASE 中,其中他们将根据需要覆盖 HOME。这意味着你只需要把具体的修改放在你的BASE中即可;无需复制整个内容。事实上,这些较新版本的 tomcat 中提供了相当多的配置,涉及这些库及其对每个 tomcat 实例的类路径的分层影响。
Note, I'm answering my own question. First of all, it's important to note that the reason you need to have your instance specific copies of the lib directories has nothing to do with concurrent jvm access to a single set of jar files.
The reason that you must copy these library files into your instance specific directory structures, also know as CATALINA_BASE's, is that in tomcat 5.5 and early 6.0 versions, tomcat could only use a single folder as the classpath source for the libraries found in shared, server and common. This means that if a given tomcat instance requires additions or modifications of the libraries in these folders, you either must make entire new instance specific versions of shared, common, and server, or the modifications of the libraries, if done in CATALINA_HOME, will then affect ALL instances running off of that CATALINA_HOME.
Starting with TOMCAT 6.0.24 ( or so . . . ) the ability to load classes from shared, common and server library folders both in CATALINA_BASE and CATALINA_HOME, gives the finer granularity of control so that your modifications can be put in the BASE, where they will override the HOME as necessary. This means that you only need to put the specific modifications in your BASE; there's no need to copy over the whole thing. And in fact there is quite a bit of configuration offered up in these newer versions of tomcat with respect to these libraries and their layered impact on the classpath of each tomcat instance.