关闭

linux下安装jboss

2059人阅读 评论(0) 收藏 举报
分类:

JbossJava EE应用服务器(就像Apacheweb服务器一样),专门用来运行Java EE程序的。

JBoss的运行需要JAVA环境的支持,所以我们首先安装JDK。

 

一 安装jdk7

注意:安装jdk8不行,这里安装jdk7.

下载地址:http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.html 

下载jdk并将其解压后放到/usr/local目录下:

tar -xvf jdk-7u79-linux-x64.tar.gz

cd jdk1.7.0_79/

chmod 755 bin

验证是否安装成功:

./bin/java -version

java version"1.7.0_79"
Java(TM) SERuntime Environment (build 1.7.0_79-b15)
Java HotSpot(TM)64-Bit Server VM (build 24.79-b02, mixed mode)

mv /download/jdk1.7.0_79 /usr/local/

建立/usr/local/下的jdk软连接方便以后版本升级:

ln -s /download/jdk1.7.0_79 /usr/local/jdk

 配置环境变量:

/etc/profile中加入以下内容:

JAVA_HOME=/usr/local/jdk1.7.0_79
JAVA_BIN=/usr/local/jdk1.7.0_79/bin
PATH=$PATH:$JAVA_BIN
CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOMEJAVA_BIN PATH CLASSPATH

source /etc/profile

查看java环境变量是否生效

[root@PC ~]# java -version

java version "1.7.0_79"
Java(TM) SE Runtime Environment (build1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build24.79-b02, mixed mode)

二 安装jboss


2.1 解压 

进官网http://jbossas.jboss.org/downloads/下载jboss。

把下载的zip文件放到/usr/local目录,执行:  

cd /usr/local

unzip jboss-as-7.1.1.Final.zip

 

2.2 创建用户 

创建用户:为了安全起见,我们一般不使用root或系统已有的其它用户来运行Jboss 

groupadd jboss

useradd jboss -g jboss

passwd jboss

 

2.3 配置环境变量

  vi /etc/profile,添加下列内容:  

#set jboss environment
JBOSS_HOME=/usr/local/jboss-as-7.1.1.Final
PATH=$PATH:$JBOSS_HOME/bin
CLASSPATH=.:$CLASSPATH:$JBOSS_HOME/lib
export JBOSS_HOME PATH CLASSPATH

 退出vi,然后source /etc/profile,使配置生效!

 

2.4 启动jboss

cd /usr/local/jboss-as-7.1.1.Final/bin 

./standalone.sh &

=========================================================================
 
  JBossBootstrap Environment
 
 JBOSS_HOME: /usr/local/jboss-as-7.1.1.Final
 
  JAVA:/usr/local/jdk1.7.0_79/bin/java
 
 JAVA_OPTS:  -server-XX:+UseCompressedOops -XX:+TieredCompilation -Xms64m -Xmx512m-XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true-Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000-Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true-Djboss.server.default.config=standalone.xml
 
=========================================================================
 
09:06:14,253 INFO  [org.jboss.modules] JBoss Modules version1.1.1.GA
09:06:16,337 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
09:06:16,889 INFO  [org.jboss.as] JBAS015899: JBoss AS7.1.1.Final "Brontes" starting
09:06:31,912 INFO  [org.xnio] XNIO Version 3.0.3.GA
09:06:32,005 INFO  [org.jboss.as.server] JBAS015888: Creatinghttp management service using socket-binding (management-http)
09:06:32,352 INFO  [org.xnio.nio] XNIO NIO ImplementationVersion 3.0.3.GA
09:06:32,540 INFO  [org.jboss.remoting] JBoss Remoting version3.2.3.GA
09:06:33,052 INFO  [org.jboss.as.logging] JBAS011502: Removingbootstrap log handlers
09:06:33,398 INFO  [org.jboss.as.osgi] (ServerService ThreadPool -- 53) JBAS011940: Activating OSGi Subsystem
09:06:33,589 INFO  [org.jboss.as.webservices] (ServerServiceThread Pool -- 62) JBAS015537: Activating WebServices Extension
09:06:35,068 INFO  [org.jboss.as.security] (MSC service thread1-2) JBAS013100: Current PicketBox version=4.0.7.Final
09:06:35,855 INFO  [org.jboss.as.naming] (MSC service thread1-1) JBAS011802: Starting Naming Service
09:06:35,927 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService ThreadPool -- 41) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver(version 1.3)
09:06:35,981 INFO  [org.jboss.as.connector] (MSC service thread1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
09:06:38,304 INFO  [org.jboss.as.mail.extension] (MSC servicethread 1-1) JBAS015400: Bound mail session [java:jboss/mail/Default]
09:06:39,656 INFO  [org.jboss.ws.common.management.AbstractServerConfig](MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.2.GA
09:06:41,104 INFO  [org.apache.coyote.http11.Http11Protocol](MSC service thread 1-1) Starting Coyote HTTP/1.1 on http--0.0.0.0-8080
09:06:46,940 INFO  [org.jboss.as.remoting] (MSC service thread1-2) JBAS017100: Listening on /127.0.0.1:9999
09:06:46,986 INFO  [org.jboss.as.server.deployment.scanner] (MSCservice thread 1-1) JBAS015012: Started FileSystemDeploymentService fordirectory /usr/local/jboss-as-7.1.1.Final/standalone/deployments
09:06:47,025 INFO  [org.jboss.as.remoting] (MSC service thread1-1) JBAS017100: Listening on /0.0.0.0:4447
09:06:47,256 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1)JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
09:06:47,294 INFO  [org.jboss.as] (Controller Boot Thread)JBAS015951: Admin console listening on http://127.0.0.1:9990
09:06:47,295 INFO  [org.jboss.as] (Controller Boot Thread)JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 35217ms -Started 133 of 208 services (74 services are passive or on-demand)

2.5 开放防火墙端口

开放8080和9990

vi /etc/sysconfig/iptables

添加:

-A INPUT -m state--state NEW -m tcp -p tcp --dport 9990 -j ACCEPT

-A INPUT -m state--state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

重启防火墙:

service iptables restart

 

2.6 修改配置文件  

JBoss默认只允许本机访问,若要从任何地方都可以访问,需要修改配置文件中JBoss的监听地址:  

cd /usr/local/jboss-as-7.1.1.Final/standalone/configuration

vi standalone.xml

找到interface name="public"

修改接口绑定地址, 设置可通过本机所有IP都可访问

<interface name="public">

<inet-addressvalue="${jboss.bind.address:127.0.0.1}"/>

</interface>

修改为:

<interface name="public">

<inet-addressvalue="${jboss.bind.address:0.0.0.0}"/>

</interface>

 

找到interface name="management"

<interfacename="management">

    <inet-addressvalue="${jboss.bind.address.management:127.0.0.1}"/>

 </interface>

修改为

<interfacename="management">

    <inet-addressvalue="${jboss.bind.address.management:0.0.0.0}"/>

 </interface> 

修改完之后,重启jboss

kill -9杀掉已经启动的jboss,再启动即可。

  

2.7 添加管理用户 

[root@slave2bin]# ./add-user.sh 

What type ofuser do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User(application-users.properties)
(a):  #回车
 
Enter thedetails of the new user to add.
Realm(ManagementRealm) : #回车
Username : jiao
Password :
Re-enterPassword :
About to adduser 'jiao' for realm 'ManagementRealm'
Is this correctyes/no? yes
Added user'jiao' to file'/usr/local/jboss-as-7.1.1.Final/standalone/configuration/mgmt-users.properties'
Added user'jiao' to file'/usr/local/jboss-as-7.1.1.Final/domain/configuration/mgmt-users.properties'

 #我试验了上面如果没有回车,直接输入值的话,最后登录不进去,汗!

2.8 测试

远程访问http://ip:8080端口

 

 

点击‘Administration Console

 


 

 

三 部署程序

将war包上传到目录:/usr/local/jboss-as-7.1.1.Final/standalone/deployments下,观察jboss日志(如这里上传jenkins.war):

14:13:43,742 INFO  [org.jboss.as.server.deployment] (MSC servicethread 1-1) JBAS015876: Starting deployment of "jenkins.war"
14:14:26,349 INFO  [stdout] (MSC service thread 1-1) Jenkinshome directory: /root/.jenkins found at: $user.home/.jenkins
14:14:31,318 INFO  [org.jboss.web] (MSC service thread 1-1)JBAS018210: Registering web context: /jenkins
14:14:32,182 INFO  [org.jboss.as.server](DeploymentScanner-threads - 1) JBAS018559: Deployed "jenkins.war"
14:14:36,789 INFO  [jenkins.InitReactorRunner](pool-15-thread-2) Started initialization
14:16:17,915 INFO  [jenkins.InitReactorRunner](pool-15-thread-1) Listed all plugins
14:16:18,843 INFO  [jenkins.InitReactorRunner](pool-15-thread-1) Prepared all plugins
14:16:19,305 INFO  [jenkins.InitReactorRunner](pool-15-thread-1) Started all plugins
14:16:45,007 INFO  [jenkins.InitReactorRunner](pool-15-thread-2) Augmented all extensions
14:17:02,485 INFO  [jenkins.InitReactorRunner](pool-15-thread-1) Loaded all jobs
14:17:02,575 INFO  [jenkins.model.DownloadSettings$DailyCheck](Download metadata thread) Started Download metadata
14:17:07,639 INFO  [org.jenkinsci.main.modules.sshd.SSHD](SSHD.init) Started SSHD at port 42249
14:17:07,876 INFO  [jenkins.InitReactorRunner](pool-15-thread-2) Completed initialization
14:17:08,077 INFO  [jenkins.InitReactorRunner](pool-23-thread-2) Started initialization
14:17:08,079 INFO  [jenkins.InitReactorRunner](pool-23-thread-2) Listed all plugins
14:17:08,087 INFO  [jenkins.InitReactorRunner](pool-23-thread-2) Prepared all plugins
14:17:08,109 INFO  [jenkins.InitReactorRunner](pool-23-thread-2) Started all plugins
14:17:08,123 INFO  [jenkins.InitReactorRunner](pool-23-thread-2) Augmented all extensions
14:17:08,151 INFO  [jenkins.InitReactorRunner](pool-23-thread-2) Loaded all jobs
14:17:08,183 INFO  [jenkins.InitReactorRunner](pool-23-thread-2) Completed initialization
14:17:08,230 INFO  [hudson.WebAppMain] (Jenkins initializationthread) Jenkins is fully up and running
14:17:23,260 INFO  [hudson.model.UpdateSite] (Download metadatathread) Obtained the latest update center data file for UpdateSource default
14:17:25,006 INFO  [hudson.model.DownloadService$Downloadable](Download metadata thread) Obtained the updated data file forhudson.tasks.Maven.MavenInstaller
14:17:26,209 INFO  [hudson.model.DownloadService$Downloadable](Download metadata thread) Obtained the updated data file for hudson.tasks.Ant.AntInstaller
14:17:33,243 INFO  [hudson.model.DownloadService$Downloadable](Download metadata thread) Obtained the updated data file forhudson.tools.JDKInstaller
14:17:33,298 INFO  [jenkins.model.DownloadSettings$DailyCheck](Download metadata thread) Finished Download metadata. 30,714 ms
 

部署过程中,会生成一个jenkins.war.deployed文件。

访问http://10.192.203.202:8080/jenkins/,就能看到相应的页面啦:

 

 

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1027757次
    • 积分:14172
    • 等级:
    • 排名:第855名
    • 原创:317篇
    • 转载:626篇
    • 译文:3篇
    • 评论:92条