●JBossインストール ■[環境] RHEL4.0(Nahant) J2SE 5.0U4 apacheとJBossで連携 ※tomcatとJBossは今回は同じホスト上に  インストールします。  エッジとアプリケーションを分けてもかまいません。 ■[準備] ・J2SE5.0をダウンロード http://java.sun.com/j2se/1.5.0/download.jsp [root@localhost ~]# sh jdk-1_5_0_04-linux-i586-rpm.bin ※/usr/java/jdk1.5.0_0Xにインストールされます 環境変数に記述(ex.~/.bashrcなど) JAVA_HOME=/usr/java/jdk1.5.0_04 PATH=$JAVA_HOME/bin:$PATH export PATH JAVA_HOME JBossをダウンロードしてくる。 http://www.jboss.org/downloads/index ・インストール インストールは展開するだけで終了です。 [root@localhost jboss]# gzip -dc jboss-4.0.3RC1.tar.gz|tar xf - /usr/local/jboss/jboss-4.0.3RC1に展開します [起動オプション] 特に何もする必要はありませんが、必要がある場合は設定します。 スタート時にjavaにオプションを渡したいなどの設定は /usr/local/jboss/jboss-4.0.3RC1/bin/run.conf に記述します。 例). JAVA_HOMEをユーザごとではなく JBoss起動時に必ず使用するものに変更する場合 メモリの容量を変更する場合 azulを使用して起動もしています。 # vi /usr/local/jboss/jboss-4.0.3RC1/bin/run.conf JAVA_HOME="/usr/java/jdk1.5.0_04" ←コメントアウトし編集 32行目 JAVA_OPTS="-server -Xms1024m -Xmx1024m" ←編集(44行目) ■[起動] 実際に起動するにはスタート用のスクリプトを 実行するだけです。 [root@localhost bin]# /usr/local/jboss/jboss-4.0.3RC1/bin/run.sh フォアグラウンドで実行されます。 もしバックグラウンドで実行したいなら [root@localhost bin]# /usr/local/jboss/jboss-4.0.3RC1/bin/run.sh & &をつけて起動します。 -cオプションで all :サンプルも含め最大 default :指定のないときのデフォルト minimal :最低限の構成 を指定できる。 これでは、情報が全て標準出力だけに出てログに残らないので ログに残してバックグラウンドで実行したい場合は [root@localhost bin]# ./run.sh -c all > /var/log/jboss-`date "+%Y%m%d%H%M"`.log 2>&1 & とするとログが残せます。 ------ [root@localhost bin]# ./run.sh ========================================================================= JBoss Bootstrap Environment JBOSS_HOME: /usr/local/jboss/jboss-4.0.3RC1 JAVA: /usr/java/jdk1.5.0_04/bin/java JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh CLASSPATH: /usr/local/jboss/jboss-4.0.3RC1/bin/run.jar:/usr/java/jdk1.5.0_04/lib/tools.jar ========================================================================= 05:53:57,863 INFO [Server] Starting JBoss (MX MicroKernel)... 05:53:57,916 INFO [Server] Release ID: JBoss [Zion] 4.0.3RC1 (build: CVSTag=JBoss_4_0_3_RC1 date=200506260723) 05:53:57,921 INFO [Server] Home Dir: /usr/local/jboss/jboss-4.0.3RC1 05:53:57,923 INFO [Server] Home URL: file:/usr/local/jboss/jboss-4.0.3RC1/ 05:53:57,927 INFO [Server] Library URL: file:/usr/local/jboss/jboss-4.0.3RC1/lib/ 05:53:57,944 INFO [Server] Patch URL: null 05:53:57,946 INFO [Server] Server Name: default 05:53:57,949 INFO [Server] Server Home Dir: /usr/local/jboss/jboss-4.0.3RC1/server/default 05:53:57,954 INFO [Server] Server Home URL: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/ 05:53:57,959 INFO [Server] Server Data Dir: /usr/local/jboss/jboss-4.0.3RC1/server/default/data 05:53:57,961 INFO [Server] Server Temp Dir: /usr/local/jboss/jboss-4.0.3RC1/server/default/tmp 05:53:57,964 INFO [Server] Server Config URL: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/conf/ 05:53:57,966 INFO [Server] Server Library URL: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/lib/ 05:53:57,968 INFO [Server] Root Deployment Filename: jboss-service.xml 05:53:57,996 INFO [Server] Starting General Purpose Architecture (GPA)... 05:54:03,740 INFO [ServerInfo] Java version: 1.4.2_07,Azul Systems, Inc. 05:54:03,743 INFO [ServerInfo] Java VM: Java HotSpot(TM) 64-Bit Server VM 1.4.2_07-AVM_2.1.0.1-14,Azul Systems, Inc. 05:54:03,747 INFO [ServerInfo] OS-System: Linux 2.6.9-5.EL,i586 05:54:07,810 INFO [Server] Core system initialized 05:54:36,524 INFO [WebService] Using RMI server codebase: http://localhost.localdomain:8083/ 05:54:36,779 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml 05:54:39,801 INFO [NamingService] Started jndi bootstrap jnpPort=1099, rmiPort=1098, backlog=50, bindAddress=/0.0.0.0, Client SocketFactory=null, Server SocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad093076 05:55:47,720 INFO [Embedded] Catalina naming disabled 05:55:52,693 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8080 05:55:52,712 INFO [Catalina] Initialization processed in 4185 ms 05:55:52,744 INFO [StandardService] Starting service jboss.web 05:55:52,803 INFO [StandardEngine] Starting Servlet Engine: Apache Tomcat/5.5.9 05:55:53,394 INFO [StandardHost] XML validation disabled 05:55:53,605 INFO [Catalina] Server startup in 891 ms 05:55:55,806 INFO [TomcatDeployer] deploy, ctxPath=/invoker, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/http-invoker.sar/invoker.war/ 05:56:05,067 INFO [WebappLoader] Dual registration of jndi stream handler: factory already defined 05:56:10,292 INFO [TomcatDeployer] deploy, ctxPath=/ws4ee, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/tmp/deploy/tmp36885jboss-ws4ee.war/ 05:56:16,725 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jbossweb-tomcat55.sar/ROOT.war/ 05:56:24,506 INFO [TomcatDeployer] deploy, ctxPath=/jbossmq-httpil, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/ 05:56:51,160 INFO [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/management/console-mgr.sar/web-console.war/ 05:57:03,697 INFO [MailService] Mail Service bound to java:/Mail 05:57:08,121 INFO [RARDeployment] Required license terms exist view the META-INF/ra.xml: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jboss-ha-local-jdbc.rar 05:57:09,320 INFO [RARDeployment] Required license terms exist view the META-INF/ra.xml: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jboss-ha-xa-jdbc.rar 05:57:10,402 INFO [RARDeployment] Required license terms exist view the META-INF/ra.xml: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jboss-local-jdbc.rar 05:57:11,768 INFO [RARDeployment] Required license terms exist view the META-INF/ra.xml: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jboss-xa-jdbc.rar 05:57:13,115 INFO [RARDeployment] Required license terms exist view the META-INF/ra.xml: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jms/jms-ra.rar 05:57:14,260 INFO [RARDeployment] Required license terms exist view the META-INF/ra.xml: file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/mail-ra.rar 05:57:24,846 INFO [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:name=DefaultDS,service=DataSourceBinding to JNDI name 'java:DefaultDS' 05:57:28,699 INFO [A] Bound to JNDI name: queue/A 05:57:28,716 INFO [B] Bound to JNDI name: queue/B 05:57:28,742 INFO [C] Bound to JNDI name: queue/C 05:57:28,756 INFO [D] Bound to JNDI name: queue/D 05:57:28,769 INFO [ex] Bound to JNDI name: queue/ex 05:57:29,253 INFO [testTopic] Bound to JNDI name: topic/testTopic 05:57:29,275 INFO [securedTopic] Bound to JNDI name: topic/securedTopic 05:57:29,290 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic 05:57:29,318 INFO [testQueue] Bound to JNDI name: queue/testQueue 05:57:30,046 INFO [UILServerILService] JBossMQ UIL service available at : /0.0.0.0:8093 05:57:30,508 INFO [DLQ] Bound to JNDI name: queue/DLQ 05:57:32,571 INFO [ConnectionFactoryBindingService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:name=JmsXA,service=ConnectionFactoryBinding to JNDI name 'java:JmsXA' 05:57:33,011 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jmx-console.war/ 05:57:41,309 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080 05:57:42,235 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009 05:57:42,382 INFO [JkMain] Jk running ID=0 time=0/450 config=null 05:57:42,433 INFO [Server] JBoss (MX MicroKernel) [4.0.3RC1 (build: CVSTag=JBoss_4_0_3_RC1 date=200506260723)] Started in 3m:44s:436ms ------ 実際に動作しているかどうかは http://ホスト:8080/ http://ホスト:8080/web-console/ でアクセスするとJBossの管理画面が現れます。 ■[停止] [root@localhost bin]# ./shutdown.sh -S ----- 05:53:07,880 INFO [Server] LifeThread.run exits! 05:53:07,898 INFO [Server] Shutting down the JVM now! 05:53:07,906 INFO [Server] JBoss SHUTDOWN: Undeploying all packages 05:53:07,915 INFO [TomcatDeployer] undeploy, ctxPath=/jmx-console, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jmx-console.war/ Shutdown message has been posted to the server. Server shutdown may take a while - check logfiles for completion [root@localhost bin]# 05:53:08,098 INFO [ConnectionFactoryBindingService] Unbound connection factory for resource adapter for ConnectionManager 'jboss.jca:name=JmsXA,service=ConnectionFactoryBinding from JNDI name 'java:JmsXA' 05:53:08,368 INFO [ConnectionFactoryBindingService] Unbound connection factory for resource adapter for ConnectionManager 'jboss.jca:name=DefaultDS,service=DataSourceBinding from JNDI name 'java:DefaultDS' 05:53:09,503 INFO [HypersonicDatabase] Database standalone closed clean 05:53:09,868 INFO [MailService] Mail service 'java:/Mail' removed from JNDI 05:53:09,903 INFO [TomcatDeployer] undeploy, ctxPath=/web-console, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/management/console-mgr.sar/web-console.war/ 05:53:10,572 INFO [TomcatDeployer] undeploy, ctxPath=/jbossmq-httpil, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/ 05:53:10,641 INFO [TomcatDeployer] undeploy, ctxPath=/, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/jbossweb-tomcat55.sar/ROOT.war/ 05:53:10,730 INFO [Http11Protocol] Pausing Coyote HTTP/1.1 on http-0.0.0.0-8080 05:53:11,821 INFO [StandardService] Stopping service jboss.web 05:53:11,909 INFO [Http11Protocol] Stopping Coyote HTTP/1.1 on http-0.0.0.0-8080 05:53:11,947 INFO [TomcatDeployer] undeploy, ctxPath=/invoker, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/deploy/http-invoker.sar/invoker.war/ 05:53:11,972 INFO [TomcatDeployer] undeploy, ctxPath=/ws4ee, warUrl=file:/usr/local/jboss/jboss-4.0.3RC1/server/default/tmp/deploy/tmp25757jboss-ws4ee.war/ Shutting down 05:53:13,054 INFO [Server] Shutdown complete Shutdown complete Halting VM ----- -S以外のオプションは以下参照 --- A JMX client to shutdown (exit or halt) a remote JBoss server. usage: shutdown [options] options: -h, --help Show this help message (default) -D[=] Set a system property -- Stop processing options -s, --server= Specify the JNDI URL of the remote server -n, --serverName= Specify the JMX name of the ServerImpl -a, --adapter= Specify JNDI name of the MBeanServerConnection to use -u, --user= Specify the username for authentication -p, --password= Specify the password for authentication operations: -S, --shutdown Shutdown the server -e, --exit= Force the VM to exit with a status code -H, --halt= Force the VM to halt with a status code ---- ■apacheとの連携 apacheとの連携はtomcatのmod_jkのインストールの項を参照。 http://unix-study.com/unix/install/appserver/tomcat.txt JBossはtomcatのエンジンを使っているので、連携方法も 設定も全く同じでよい。 JBossでサーブレットが動いているかどうか 確認するには、httpd.confで ---- LoadModule jk_module modules/mod_jk.so JkWorkersFile /etc/httpd/conf/workers.properties JkLogFile /var/log/httpd/jk.log JkLogLevel info # Sample JkMounts. Replace these with the paths you would # like to mount from your JSP server. JkMount /*.jsp worker1 JkMount /servlet/* worker1 JkMount /examples/* worker1 JkMount /jsp-examples/* worker1 JkMount /servlet-examples/* worker1 JkMount /jmx-console/* worker1 ←JBossの管理画面 JkMount /web-console/* worker1 ←JBossの管理画面 ---- 「←JBossの管理画面」の2行を追加して、 apacheを再起動 # apchectl graceful して、 http://ホスト/web-console/ http://ホスト/jmx-console/ にアクセスしてJBossの管理画面が表示されるかどうか確認する。 ■起動順番 起動はいつも 1.JBoss [root@localhost bin]# cd $JBOSS_HOME/bin [root@localhost bin]# ./run.sh -c all > /var/log/jboss-`date "+%Y%m%d%H%M"`.log 2>&1 & 2.apache [root@localhost bin]# apachectl start or [root@localhost bin]# service httpd start  ※RHELなどでchkconfigで登録されている場合 の順番で起動するようにします。