`
Mysun
  • 浏览: 270548 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

JBOSS共享安装

阅读更多
本文内容适合于Jboss 4.x系列应用服务器。

在项目中,我们可能会碰到有多个开发人员共用一个服务器,每个人都需要有单独的开发环境来运行项目程序。如果每个人都安装一个自己的Jboss,这样会浪费很多磁盘空间。另外,还有可能需要在一个服务器上运行多个不同的Jboss项目,或者我们对远程机器上的Jboss目录没有写权限,因此就没有办法把我们的项目放到远程服务器上。为了解决这个问题,Jboss提供的共享安装机制。本文描述了这种机制。
Why use a Shared JBoss Installation Directory?
    Development teams typically have a development lab consisting of shared hardware for testing deployments in a more 'production-like' way. The shared hardware usually has multiple instances of the application deployed on it (a few instances per developer), and one installation of the application server software. For example, on a Linux system it would be common for applications such as JBoss to be installed in the /usr/local directory, and the individual developer instances of the application to be deployed in each user's home directory, or perhaps some other part of the filesystem set up explicitly for deployments. So, you may need a shared installation directory for a number of reasons.

  1. You want to have a directory for each instance of JBoss somewhere other than in the JBoss installation 'server' directory.
  2. There is a shared (Linux or Unix) deployment box where each user refers to the JBoss installation directory which is read only for their account. (Of course, you could have each user have their own copy of JBoss, but that isn't a very good use of disk space)
  3. The JBoss installation is on a network drive and read only.


Default directory setup
    After installation, the JBoss home directory will have a server directory under it which will contain a directory for each 'configuration' or 'server name'. Each of these will have a 'deploy' directory underneath it. For example:
JBOSS_HOME
   \- server
      +- default
      \- minimal

    For a shared installation, it might not work to have the subdirectories of 'server' for each configuration, or user. So that leaves two problems that must be solved:
  1. How do we tell JBoss to use some directory other than $JBOSS_HOME/server for deployments / configurations?
  2. How do we run multiple instances of JBoss on the same server?


JBoss System Properties
Jboss共享安装的重点在于修改Jboss启动是的系统参数,下面列出了Jboss 4.x系列应用服务器的系统参数。关于Jboss系统参数的详细介绍,可以看下Jboss官方网站的Wiki。
http://www.jboss.org/community/wiki/JBossProperties
    Fortunately, it is quite simple to start JBoss so that it will use a shared installation. The key is to understand how to use the JBoss system properties. These properties depend on each other, care must be taken to set them properly.

Where are the ports defined?
为了在一台机器上同时启动多个Jboss,每个Jboss的端口都不能重复,关于Jboss的端口及其修改请看本Blog的另外一篇文章:Jboss端口及其修改。

Examples of setting jboss.server.home
Jboss共享安装的重点在于修改jboss.server.home.dir和jboss.server.home.url这两个启动时的系统参数。下面是Linux和Windows下的两个例子。

Example 1 - Linux
    Suppose JBoss is installed in /usr/local/jboss and there is an application deployment in /home/jdavis/myapp. Before starting up JBoss we will need to set some environment variables. We can make a shell script to do this:
#!/bin/bash
# start-env.sh - starts a new shell with instance variables set
export JBOSS_HOME=/usr/local/jboss 
JAVA_HOME=/usr/java/jdk1.5.0_04
export PATH=$JAVA_HOME/bin:$JBOSS_HOME/bin:$PATH
echo "Runtime shell..."
$SHELL

    ~~Note that this script will start a new shell~~, so you can simply exit the shell at any time to go back to the environment variables you had before.

    Now, we need to get a sample deployment. For this example, we can copy the 'default' configuration in the JBoss server directory.

$ ./start-env.sh
#$ cp -r $JBOSS_HOME/server/default /home/jdavis/myapp
#原文中是将default拷贝到/home/jdavis/myapp下,但个人觉得应该是拷贝到/home/jdavis目录下面。其实问题也不是很大
$ cp -r $JBOSS_HOME/server/default /home/jdavis


We can now start the 'myapp' server like this:
$ run.sh -Djboss.server.base.dir=/home/jdavis \
    -Djboss.server.base.url=file:///home/jdavis -c myapp


除了修改jboss.server.base.dir和jboss.server.base.url这两个属性来启动Jboss之外,我们还可以修改jboss.server.home.dir和jboss.server.home.url这两个属性来启动Jboss,效果是一样的,启动脚本如下。
$ run.sh -Djboss.server.home.dir=/home/jdavis/default \
    -Djboss.server.home.url=file:///home/jdavis/default
#使用jboss.server.home.dir和jboss.server.home.url系统属性时,需要将目录指向default
#目录,而不是default的上级目录。-c参数去掉,将你的项目直接放到default/deploy下面。

    In this example we've set the server base directory to the directory above the application deployment and used the -c option to specify the sub-directory, which is the default behavior. Also note that the prefix for the URL form of the base directory is file://. The third forward slash is for the filesystem root directory.

Example 2 - Windows Command Shell
This is the equivalent of the previous example.

   1. Java is installed in D:/java/jdk1.5.0_09
   2. JBoss in installed in D:/java/jboss-4.0.5.GA
   3. The local deployment is in D:/jdavis/myapp

Here is the CMD script to start JBoss on the local deployment:
set JBOSS_HOME=D:/java/jboss-4.0.5.GA
set JAVA_HOME=D:/java/jdk1.5.0_09
call %JBOSS_HOME%/bin/run.bat -Djboss.server.base.dir=D:/jdavis   \
     -Djboss.server.base.url=file:/D:/jdavis -c myapp

    In this example, we've set the server base directory to the directory above the application deployment and used the -c option to specify the sub-directory, which is the default behavior.

原文出处:http://shrubbery.mynetgear.net/wiki/Shared_JBoss_Installation_Directory
分享到:
评论

相关推荐

    jboss——suse安装手册

    现在很多公司都用novell的suselinux来做服务器的操作系统,在安装网页服务器的时候经常会遇到许多问题。这里我拿一个我们公司安装jboss的手册来供大家共享。

    Nginx 1.2.1 + JBOSS AS 7 负载配置及Session处理

    Nginx 1.2.1 + JBOSS AS 7 负载配置及Session处理

    jboss配置指南

    lib 一些 JAR , JBoss 启动时加载,且被所有 JBoss 配置共享。(不要把你的库放在这里) server 各种 JBoss 配置。每个配置必须放在不同的子目录。子目录的名字表示配置的名字。 JBoss 包含 3 个默认的配置: ...

    Jboss

    NULL 博文链接:https://yy-danvip.iteye.com/blog/366446

    JBOSS 架构分析

    JBOSS架构分析, 介绍JOBSS架构文章,想了解请下载,资源共享!

    jboss-5.1.0.GA下载(共享份)

    单个只能60所以分了三块

    jboss-eap-5.2.0.zip

    jboss-eap-5.0.2.zip,来自于官网,因为改动代码需要用到比较老的jboss-eap包,所以自己找到了这个资源,免费共享给大家,适用于JDK1.6

    jboss源代码 java源代码 j2se服务器源码

    经常需要用到的jboss的源码,但是想用时却总是找不到,这回放上来给大家共享,免得用时到处找

    JBoss管理与开发

    JBoss管理与开发 JBoss JMX实现架构 一个很专业的jboss教程 给大家共享一下

    jboss 4.2.3

    一些很老的资源,太难找了,共享共享。 一些很老的资源,太难找了,共享共享。

    Apache+Jboss(Tomcat)集群配置

    公司需要做 Apache Tomcat集群,研究了数日,终配置成功,把研究结果共享一下。 最下面的红色字体[在一台机器上启动两个JBoss服务器],不同机器端口和路径不同,可根据自己情况适当修改。

    jboss-dmr-1.0.0.Final.zip

    jcors.zip,Java的跨源资源共享用于在Java Web应用程序上启用跨源资源共享(CORS)的简单筛选器

    jboss-eap-7.4.0.zip

    JBoss EAP (Enterprise Application Platform) 7.4.0是一个Java应用服务器,提供了一套完整的开发、部署和管理企业级应用程序的解决方案。下面是对其解锁内容概要以及适合人群、使用场景和目标的简要说明: 解锁...

    jboss7+EJB3环境搭建

    jboss7与ejb3的环境搭建 刚刚开始学习ejb3 由于jboss7的改动使得网上很多的方法都行不通 再此找到一篇能够搭建成功的文档 共享一下

    JBoss4.x企业级应用服务平台群集指南

    此文档从新浪下载,个人觉得不错,共享出来给正在学习JBoss集群的人以参考。

    JBOSS_5.0.0GA的集群搭建

    最近看了一下JBOSS-5.0.0GA的集群搭建的文档,于是把自己的理解发上来和大家共享一下。不过还是有好多问题需要和大家,共同讨论一下

    jboss-3.2.1_tomcat-4.1.24.zip

    学习Struts时,多说孙卫琴的精通Struts基于MVC的Java.Web设计与开发>>比较基础,但是附带光盘中没有“jboss-3.2.1_tomcat-4.1.24.zip“软件,现在把软件的下载地址共享了。(为了中国的软件行业)

    jboss portal手册

    官方网站藏的有点深,而且网站访问实在有些慢,传这里共享

    EBook文档共享与在线预览发布系统

    JBoss, OpenOffice等第三方软件设置而成的文档共享与发布平台。 系统的主要特色为一下: 1、支持文档的在线预览。 2、文档在线预览转换支持线程的监听与控制,应对非法大文件的攻击 3、文档存储采用虚拟目录,保证...

    spring-global-context:这个项目展示了如何让 JBoss 模块能够在 Wildfly 下的 web 应用程序之间共享单个 Spring 上下文

    弹簧全局上下文这个项目展示了如何让 JBoss 模块能够在 Wildfly 下的 web 应用程序之间共享单个 Spring 上下文

Global site tag (gtag.js) - Google Analytics