系统相关
首页 > 系统相关> > linux下jboss安装使用

linux下jboss安装使用

作者:互联网

Jboss是Java EE应用服务器(就像Apache是web服务器一样),专门用来运行Java EE程序的。

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

本章环境:
系统:CentOS Linux release 7.9.2009

前期工作准备:
关闭防火墙 关闭selinux

[root@server-jboos ~]# systemctl stop firewalld.service 
[root@server-jboos ~]# systemctl distable firewalld.service
[root@server-jboos ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 
[root@server-jboos ~]# setenforce 0

或者开放8080和9990端口

vim /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
重启防火墙:
systemctl restart iptables

一 安装 jdk-7u79-linux-x64.tar.gz

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

下载地址:https://www.oracle.com/java/technologies/javase/javase7-archive-downloads.html

下载jdk并将其解压后放到/usr/local/java目录下并设置软链:

[root@server-jboos ~]# mkdir /usr/local/java
[root@server-jboos ~]# tar xf jdk-7u79-linux-x64.tar.gz -C /usr/local/java/
[root@server-jboos bin]# ln -s /usr/local/java/jdk1.7.0_79/ /usr/lib/java

设置环境变量

JAVA_HOME=/usr/local/java/jdk1.7.0_79
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH

在这里插入图片描述
刷新环境变量使其生效并查看版本信息

[root@server-jboos ~]# source /etc/profile
[root@server-jboos java]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

二 安装jboss

2.1 解压
下载jboss-as-7.1.1.Final.zip到/usr/local/下并解压

[root@server-jboos ~]# wget -P /usr/local https://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip
[root@server-jboos ~]# cd /usr/local
[root@server-jboos ~]# unzip jboss-as-7.1.1.Final.zip

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

[root@server-jboos ~]# groupadd jboss
[root@server-jboos ~]# useradd jboss -g jboss
[root@server-jboos ~]# passwd jboss

2.3 配置环境变量
vim /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

在这里插入图片描述
source /etc/profile,使配置生效!

[root@server-jboos ~]# source /etc/profile

2.4 启动jboss

[root@server-jboos ~]# cd /usr/local/jboss-as-7.1.1.Final/bin 
[root@server-jboos bin]# ./standalone.sh &
[1] 9561
[root@server-jboos bin]# =========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /usr/local/jboss-as-7.1.1.Final

  JAVA: /usr/local/java/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

=========================================================================

11:29:03,624 信息    [org.jboss.modules] JBoss Modules version 1.1.1.GA
11:29:03,889 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
11:29:03,941 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
11:29:05,264 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
11:29:05,308 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
11:29:05,328 INFO  [org.xnio] (MSC service thread 1-1) XNIO Version 3.0.3.GA
11:29:05,342 INFO  [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.0.3.GA
11:29:05,366 INFO  [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 3.2.3.GA
11:29:05,446 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
11:29:05,472 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
11:29:05,556 INFO  [org.jboss.as.connector] (MSC service thread 1-2) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
11:29:05,739 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
11:29:05,741 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
11:29:05,813 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
11:29:05,814 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
11:29:06,073 INFO  [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.7.Final
11:29:06,101 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
11:29:06,304 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
11:29:06,464 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session [java:jboss/mail/Default]
11:29:06,636 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.2.GA
11:29:06,836 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory /usr/local/jboss-as-7.1.1.Final/standalone/deployments
11:29:07,003 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:9999
11:29:07,005 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:4447
[root@server-jboos bin]# 11:29:46,770 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
11:29:46,809 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
11:29:46,810 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 43467ms - Started 133 of 208 services (74 services are passive or on-demand)

2.5 修改配置文件

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,再启动即可。

[root@server-jboos configuration]#  kill -9 $(ps -ef | grep -v grep | grep jboss | awk -F " " '{print $2}')
[root@server-jboos configuration]# cd /usr/local/jboss-as-7.1.1.Final/bin 
[root@server-jboos bin]# ./standalone.sh >/dev/null 2>&1 &

2.6 添加管理用户

[root@server-jboos bin]# ./add-user.sh 

What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): #回车

Enter the details of the new user to add.
Realm (ManagementRealm) : #回车
Username : wang
Password :       #wangwang
Re-enter Password :     #wangwang
About to add user 'wang' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'wang' to file '/usr/local/jboss-as-7.1.1.Final/standalone/configuration/mgmt-users.properties'
Added user 'wang' to file '/usr/local/jboss-as-7.1.1.Final/domain/configuration/mgmt-users.properties'
您在 /var/spool/mail/root 中有新邮件
[root@server-jboos bin]# 

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

2.7 测试

远程访问http://ip:8080端口
在这里插入图片描述
点击‘Administration Console’
在这里插入图片描述
在这里插入图片描述

三 部署程序

将war包上传到目录:/usr/local/jboss-as-7.1.1.Final/standalone/deployments下,观察jboss日志(如这里上传jenkins.war):
jenkins.war包下载地址:http://mirrors.jenkins-ci.org/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://ip:8080/jenkins/,就能看到相应的页面啦:

[root@server-jboos deployments]# ls
jenkins.war  jenkins.war.failed  README.txt

在这里插入图片描述

标签:INFO,14,thread,server,jboss,linux,org,安装
来源: https://blog.csdn.net/weixin_43713949/article/details/120362957