Linux下Jboss安装使用+Jboss部署脚本「建议收藏」

Linux下Jboss安装使用+Jboss部署脚本「建议收藏」Jboss是JavaEE应用服务器(就像Apache是web服务器一样),专门用来运行JavaEE程序的。JBoss的运行需要JAVA环境的支持,所以我们首先安装JDK。本章环境:系统:CentOSLinuxrelease7.9.2009前期工作准备:关闭防火墙关闭selinux[root@server-jboos~]#systemctlstopfirewalld.service[root@server-jboos~]#systemctldistablefir

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

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的监听地址:

[root@server-jboos ~]# cd /usr/local/jboss-as-7.1.1.Final/standalone/configuration
[root@server-jboos ~]# vim 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
[root@server-jboos deployments]# ls
jenkins.war  jenkins.war.deployed  README.txt

在这里插入图片描述

附上脚本:

#!/bin/bash
#stop firewalld & selinux
systemctl stop firewalld.service 
systemctl distable firewalld.service
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 
setenforce 0
#install JDK7u79
wget https://file.api.ym68.cc/Package/Java/jdk-7u79-linux-x64.tar.gz
mkdir /usr/local/java
tar xf jdk-7u79-linux-x64.tar.gz -C /usr/local/java/
ln -s /usr/local/java/jdk1.7.0_79 /usr/bin/java
cat << EOF >>/etc/profile
JAVA_HOME=/usr/local/java/jdk1.7.0_79
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
EOF
source /etc/profile
#install Jboss
wget -P /usr/local/ https://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip
cd /usr/local
UZ=`rpm -qa | grep -w unzip | wc -l`
if [ $UZ -ge 1 ];then
unzip jboss-as-7.1.1.Final.zip
else
yum -y install unzip 
if [ $? -eq 0 ];then
unzip jboss-as-7.1.1.Final.zip
else
echo "NO Unzip stop"
fi
fi
#Creat Jboss users
PASS=(Wang*Llinx)
NAME=(jboss)
useradd $NAME
echo $PASS | passwd $NAME --stdin
cat << EOF >>/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
EOF
source /etc/profile
#Modifies jboss file
cd /usr/local/jboss-as-7.1.1.Final/standalone/configuration
chenk1=`cat -n /usr/local/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml | grep "interface name\=\"management\"" | awk -F " " '{ print $1+1 }'`
sed -i "$chenk1"s/127.0.0.1/0.0.0.0/g /usr/local/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml
chenk2=`cat -n /usr/local/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml | grep "interface name\=\"public\"" | awk -F " " '{ print $1+1 }'`
sed -i "$chenk2"s/127.0.0.1/0.0.0.0/g /usr/local/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml
kill -9 $(ps -ef | grep -v grep | grep jboss | awk -F " " '{print $2}')
mkdir /var/log/jboss/
nohup /usr/local/jboss-as-7.1.1.Final/bin/standalone.sh >/var/log/jboss/jboss.log 2>&1 &
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/189137.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • shell数组变量赋值_形参可以是常量变量或表达式

    shell数组变量赋值_形参可以是常量变量或表达式1.定义数组bash支持一维数组(不支持多维数组),并且没有限定数组的大小。类似于C语言,数组元素的下标由0开始编号。获取数组中的元素要利用下标,下标可以是整数或算术表达式,其值应大于或等于0。在Shell中,用括号来表示数组,数组元素用”空格”符号分割开。定义数组的一般形式为:【示例】定义数组:array_name=(value0value1value2value3)数组的值类型任意,个数不限可以不使用连续的下标,而且下标的范围没有限制:array_name=([0]

    2022年10月30日
  • phpstorm2021 激活码【2021免费激活】

    (phpstorm2021 激活码)这是一篇idea技术相关文章,由全栈君为大家提供,主要知识点是关于2021JetBrains全家桶永久激活码的内容https://javaforall.cn/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~2QQ4OQYW6M-eyJsaWNlb…

  • js 正则替换换行符

    js 正则替换换行符vardiv=document.getElementById(‘div’);vars=div.innerHTML.replace(/(\n|\r|(\r\n)|(\u0085)|(\u2028)|(\u2029))/g,””);//g的意思是:执行全局匹配(查找所有匹配而非在找到第一个匹配后停止)。//取消了空格之后在做其他的替换才可以,否则不能替换

  • MATLAB学习笔记 plotyy函数

    MATLAB学习笔记 plotyy函数1、

  • adb常用命令–安装apk[通俗易懂]

    adb常用命令–安装apk[通俗易懂]方法一:adbpush  adbpushxxxx.apk/system/app(安装到 system/app目录下,有时安装不成功)手机中的系统apk应用(*.apk)位置:/system/app安装新apk到手机 adbpushxxxx.apk/system/app。后面的/system/app就是apk的安装目录。adbpush没有adbinstall保险,

  • win右键菜单二级菜单

    win右键菜单二级菜单参考:https://blog.csdn.net/mzYangMao/article/details/82913316一、创建对应的菜单组创建二级菜单,必须在下面创建SubCommands二、创建shell三、在shell下面创建对应的名字组,比如我这的sublime四、创建对应的command,然后对应的默认属性设置对应的值最终效果:…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号