Jboss AS7 Installation on RHEL5U10(Standalone)
(本日志详细呈现在RHEL5 Update 10上部署JBOSS AS7的技术细节)
本文的环境中的操作系统版本为:RHEL5U10。
1 2 3 4 5 6 7 8 |
[root@localhost ~]# lsb_release -a LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch Distributor ID: RedHatEnterpriseServer Description: Red Hat Enterprise Linux Server release 5.10 (Tikanga) Release: 5.10 Codename: Tikanga You have mail in /var/spool/mail/root [root@localhost ~]# |
开始本文当前,你需要准备JBOSS AS7的介质包。
URL:http://jbossas.jboss.org/downloads/
本环境中用到的是:JBoss AS 7.1.1.Final。
Download Link is:http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip
环境说明。
本环境通过VMware workstation 10构建。
其中包含了两台与JBOSS有关的虚拟机:
JBOSS1与JBOSS2,后期会作为JBOSS群集的两个节点,在本文中,仅适用JBOSS1,作为单实例运行。
IP说明:
JBOSS1 192.168.37.137
JBOSS2 192.168.37.138(本文中,暂时不会用到)
——————————————————————————————————————————————————————————————————————
零、关闭系统防火墙与SELINUX
关闭防火墙:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
[root@localhost ~]# service iptables status Table: filter Chain INPUT (policy ACCEPT) num target prot opt source destination 1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0 Chain FORWARD (policy ACCEPT) num target prot opt source destination 1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0 Chain OUTPUT (policy ACCEPT) num target prot opt source destination Chain RH-Firewall-1-INPUT (2 references) num target prot opt source destination 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 icmp type 255 3 ACCEPT esp -- 0.0.0.0/0 0.0.0.0/0 4 ACCEPT ah -- 0.0.0.0/0 0.0.0.0/0 5 ACCEPT udp -- 0.0.0.0/0 224.0.0.251 udp dpt:5353 6 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:631 7 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:631 8 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 9 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 10 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited [root@localhost ~]# chkconfig iptables off [root@localhost ~]# service iptables stop Flushing firewall rules: [ OK ] Setting chains to policy ACCEPT: filter [ OK ] Unloading iptables modules: [ OK ] [root@localhost ~]# |
关闭SELINUX:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@localhost ~]# sestatus SELinux status: enabled SELinuxfs mount: /selinux Current mode: enforcing Mode from config file: disabled Policy version: 21 Policy from config file: targeted [root@localhost ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted [root@localhost ~]# |
对SELINUX的修改需要重启系统方能生效。
一、设置主机名,并加入/etc/hosts表中:
Log:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@localhost ~]# cat /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=yes HOSTNAME=jboss1 [root@localhost ~]# [root@localhost ~]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. # LOCAL Domain 127.0.0.1 localhost # for JBOSS 192.168.37.137 jboss1 [root@localhost ~]# |
Error.Eg:
如果没有写入HOSTS表,那么,在后面启动JBOSS的时候,将会出现如下的错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
[root@jboss1 ~]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. #127.0.0.1 localhost.localdomain localhost #::1 localhost6.localdomain6 localhost6 127.0.0.1 localhost #188.0.1.191 jboss1 188.0.1.192 jboss2 [root@jboss1 ~]# [root@jboss1 ~]# /Jboss/bin/standalone.sh ========================================================================= JBoss Bootstrap Environment JBOSS_HOME: /Jboss JAVA: java JAVA_OPTS: -server -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 ========================================================================= 10:39:11,143 INFO [org.jboss.modules] JBoss Modules version 1.0.2.GA 10:39:11,505 INFO [org.jboss.msc] JBoss MSC version 1.0.1.GA 10:39:11,590 INFO [org.jboss.as] JBoss AS 7.0.2.Final "Arc" starting 10:39:11,807 ERROR [stderr] Exception in thread "Controller Boot Thread" java.lang.RuntimeException: org.jboss.as.controller.persistence.ConfigurationPersistenceException: Failed to parse configuration 10:39:11,807 ERROR [stderr] at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:89) 10:39:11,807 ERROR [stderr] at java.lang.Thread.run(Thread.java:724) 10:39:11,808 ERROR [stderr] Caused by: org.jboss.as.controller.persistence.ConfigurationPersistenceException: Failed to parse configuration 10:39:11,808 ERROR [stderr] at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:115) 10:39:11,808 ERROR [stderr] at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:104) 10:39:11,808 ERROR [stderr] at org.jboss.as.server.ServerService.boot(ServerService.java:195) 10:39:11,808 ERROR [stderr] at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:83) 10:39:11,809 ERROR [stderr] ... 1 more 10:39:11,809 ERROR [stderr] Caused by: java.lang.RuntimeException: Unable to determine a default name based on the local host name 10:39:11,809 ERROR [stderr] at org.jboss.as.controller.parsing.CommonXml.getDefaultName(CommonXml.java:184) 10:39:11,809 ERROR [stderr] at org.jboss.as.controller.parsing.StandaloneXml.readServerElement(StandaloneXml.java:137) 10:39:11,810 ERROR [stderr] at org.jboss.as.controller.parsing.StandaloneXml.readElement(StandaloneXml.java:91) 10:39:11,810 ERROR [stderr] at org.jboss.as.controller.parsing.StandaloneXml.readElement(StandaloneXml.java:79) 10:39:11,810 ERROR [stderr] at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:100) 10:39:11,810 ERROR [stderr] at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:59) 10:39:11,812 ERROR [stderr] at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:107) 10:39:11,812 ERROR [stderr] ... 4 more 10:39:11,812 ERROR [stderr] Caused by: java.net.UnknownHostException: jboss1: jboss1 10:39:11,812 ERROR [stderr] at java.net.InetAddress.getLocalHost(InetAddress.java:1466) 10:39:11,813 ERROR [stderr] at org.jboss.as.controller.parsing.CommonXml.getDefaultName(CommonXml.java:182) 10:39:11,813 ERROR [stderr] ... 10 more 10:39:11,813 ERROR [stderr] Caused by: java.net.UnknownHostException: jboss1 10:39:11,813 ERROR [stderr] at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) 10:39:11,813 ERROR [stderr] at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:894) 10:39:11,814 ERROR [stderr] at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1286) 10:39:11,814 ERROR [stderr] at java.net.InetAddress.getLocalHost(InetAddress.java:1462) 10:39:11,814 ERROR [stderr] ... 11 more 10:39:15,313 INFO [org.jboss.as] JBoss AS 7.0.2.Final "Arc" stopped in 0ms [root@jboss1 ~]# |
注意上述日志中的“10:39:11,809 ERROR [stderr] Caused by: java.lang.RuntimeException: Unable to determine a default name based on the local host name”。
二、创建JBOSS的目录位置
1 2 3 4 5 6 7 8 9 10 |
[root@localhost ~]# ls / bin boot dev etc home lib lib64 lost+found media misc mnt net opt proc root sbin selinux srv sys tmp usr var [root@localhost ~]# mkdir /Jboss [root@localhost ~]# ll -ld /Jboss/ drwxr-xr-x 2 root root 4096 Jul 10 19:47 /Jboss/ [root@localhost ~]# ls -al /Jboss/ total 16 drwxr-xr-x 2 root root 4096 Jul 10 19:47 . drwxr-xr-x 25 root root 4096 Jul 10 19:47 .. [root@localhost ~]# |
1 2 3 4 5 6 7 8 |
[root@jboss1 ~]# cd /software [root@jboss1 software]# ls [root@jboss1 software]# ll total 70796 -rw-r--r-- 1 root root 72415289 Jul 10 20:22 jboss-as-web-7.0.2.Final.zip [root@jboss1 software]# du -sh * 70M jboss-as-web-7.0.2.Final.zip [root@jboss1 software]# |
四、解压(部署)
Command:unzip jboss-as-web-7.0.2.Final.zip
Log:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
[root@jboss1 software]# unzip jboss-as-web-7.0.2.Final.zip (... ...etc) [root@jboss1 software]# ll total 70800 drwxr-xr-x 9 root root 4096 Sep 22 2011 jboss-as-web-7.0.2.Final -rw-r--r-- 1 root root 72415289 Jul 10 20:22 jboss-as-web-7.0.2.Final.zip [root@jboss1 software]# ls jboss-as-web-7.0.2.Final/ bin bundles copyright.txt docs domain jboss-modules.jar LICENSE.txt modules README.txt standalone welcome-content [root@jboss1 software]# [root@jboss1 software]# ls /Jboss/ [root@jboss1 software]# [root@jboss1 software]# mv jboss-as-web-7.0.2.Final/* /Jboss/ [root@jboss1 software]# [root@jboss1 software]# ls /Jboss/ bin bundles copyright.txt docs domain jboss-modules.jar LICENSE.txt modules README.txt standalone welcome-content [root@jboss1 software]# [root@jboss1 software]# ls jboss-as-web-7.0.2.Final [root@jboss1 software]# |
五、配置JBOSS(Standalone)
修改配置文件:$JBOSS_HOME/standalone/configuration/standalone.xml
修改其中如下代码段:
修改前:
1 2 3 4 5 6 7 8 |
<interfaces> <interface name="management"> <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> </interface> <interface name="public"> <inet-address value="${jboss.bind.address:127.0.0.1}"/> </interface> </interfaces> |
修改后:
1 2 3 4 5 6 7 8 |
<interfaces> <interface name="management"> <inet-address value="${jboss.bind.address.management:0.0.0.0}"/> </interface> <interface name="public"> <inet-address value="${jboss.bind.address:0.0.0.0}"/> </interface> </interfaces> |
六、为特定用户设置JBOSS环境变量
本环境中,该用户为:root。
为root设置环境变量:JBOSS_HOME
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[root@jboss1 Jboss]# cat /root/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH unset USERNAME # for JBOSS export JBOSS_HOME=/Jboss [root@jboss1 Jboss]# env | grep JBOSS [root@jboss1 Jboss]# [root@jboss1 Jboss]# source ~/.bash_profile [root@jboss1 Jboss]# [root@jboss1 Jboss]# env | grep JBOSS JBOSS_HOME=/Jboss [root@jboss1 Jboss]# |
七、JAVA支持
JBOSS AS7对于Java的要求最低为:Java 1.6。
这里使用YUM安装JAVA,需要预配置好YUM环境。(http://d-prototype.com/archives/66)
Log:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
[root@jboss1 ~]# yum list | grep --color java | grep open This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.41.1.11.11.90.el5_9 java-1.6.0-openjdk-demo.x86_64 1:1.6.0.0-1.41.1.11.11.90.el5_9 java-1.6.0-openjdk-devel.x86_64 1:1.6.0.0-1.41.1.11.11.90.el5_9 java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.0-1.41.1.11.11.90.el5_9 java-1.6.0-openjdk-src.x86_64 1:1.6.0.0-1.41.1.11.11.90.el5_9 java-1.7.0-openjdk.x86_64 1:1.7.0.25-2.3.10.5.el5_9 Server java-1.7.0-openjdk-demo.x86_64 1:1.7.0.25-2.3.10.5.el5_9 Server java-1.7.0-openjdk-devel.x86_64 1:1.7.0.25-2.3.10.5.el5_9 Server java-1.7.0-openjdk-javadoc.x86_64 1:1.7.0.25-2.3.10.5.el5_9 Server java-1.7.0-openjdk-src.x86_64 1:1.7.0.25-2.3.10.5.el5_9 Server [root@jboss1 ~]# [root@jboss1 ~]# yum install -y java-1.7.0-openjdk.x86_64 Loaded plugins: product-id, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package java-1.7.0-openjdk.x86_64 1:1.7.0.25-2.3.10.5.el5_9 set to be updated --> Processing Dependency: jpackage-utils >= 1.7.3-1jpp.2 for package: java-1.7.0-openjdk --> Processing Dependency: tzdata-java for package: java-1.7.0-openjdk --> Processing Dependency: rhino for package: java-1.7.0-openjdk --> Processing Dependency: libgif.so.4()(64bit) for package: java-1.7.0-openjdk --> Running transaction check ---> Package giflib.x86_64 0:4.1.3-7.3.3.el5 set to be updated ---> Package jpackage-utils.noarch 0:1.7.3-1jpp.3.el5 set to be updated ---> Package rhino.noarch 0:1.7-0.7.r2.3.el5_6 set to be updated --> Processing Dependency: jline for package: rhino ---> Package tzdata-java.x86_64 0:2013c-2.el5 set to be updated --> Running transaction check ---> Package jline.noarch 0:0.9.94-0.9.el5_6 set to be updated --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================================== Installing: java-1.7.0-openjdk x86_64 1:1.7.0.25-2.3.10.5.el5_9 Server 39 M Installing for dependencies: giflib x86_64 4.1.3-7.3.3.el5 Server 39 k jline noarch 0.9.94-0.9.el5_6 Server 84 k jpackage-utils noarch 1.7.3-1jpp.3.el5 Server 61 k rhino noarch 1.7-0.7.r2.3.el5_6 Server 788 k tzdata-java x86_64 2013c-2.el5 Server 186 k Transaction Summary =================================================================================================================================================== Install 6 Package(s) Upgrade 0 Package(s) Total download size: 40 M Downloading Packages: --------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.4 GB/s | 40 MB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : giflib 1/6 Installing : jpackage-utils 2/6 Installing : jline 3/6 Installing : rhino 4/6 Installing : tzdata-java 5/6 Installing : java-1.7.0-openjdk 6/6 Cluster/productid | 1.7 kB 00:00 ClusterStorage/productid | 1.7 kB 00:00 Server/productid | 1.7 kB 00:00 Installed: java-1.7.0-openjdk.x86_64 1:1.7.0.25-2.3.10.5.el5_9 Dependency Installed: giflib.x86_64 0:4.1.3-7.3.3.el5 jline.noarch 0:0.9.94-0.9.el5_6 jpackage-utils.noarch 0:1.7.3-1jpp.3.el5 rhino.noarch 0:1.7-0.7.r2.3.el5_6 tzdata-java.x86_64 0:2013c-2.el5 Complete! [root@jboss1 ~]# |
确认当前的Java版本:
1 2 3 4 5 |
[root@jboss1 ~]# java -version java version "1.7.0_25" OpenJDK Runtime Environment (rhel-2.3.10.5.el5_9-x86_64) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode) [root@jboss1 ~]# |
八、运行JBOSS。
LOG:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
[root@jboss1 ~]# /Jboss/bin/standalone.sh ========================================================================= JBoss Bootstrap Environment JBOSS_HOME: /Jboss JAVA: java JAVA_OPTS: -server -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 ========================================================================= 21:29:34,580 INFO [org.jboss.modules] JBoss Modules version 1.0.2.GA 21:29:34,965 INFO [org.jboss.msc] JBoss MSC version 1.0.1.GA 21:29:35,017 INFO [org.jboss.as] JBoss AS 7.0.2.Final "Arc" starting 21:29:36,295 WARN [org.jboss.as] No security realm defined for native management service, all access will be unrestricted. 21:29:36,321 INFO [org.jboss.as] creating http management service using network interface (management) port (9990) 21:29:36,326 WARN [org.jboss.as] No security realm defined for http management service, all access will be unrestricted. 21:29:36,339 INFO [org.jboss.as.logging] Removing bootstrap log handlers 21:29:36,359 INFO [org.jboss.as.connector.subsystems.datasources] (Controller Boot Thread) Deploying JDBC-compliant driver class org.h2.Driver (version 1.2) 21:29:36,376 INFO [org.jboss.as.clustering.infinispan.subsystem] (Controller Boot Thread) Activating Infinispan subsystem. 21:29:36,495 INFO [org.jboss.as.naming] (Controller Boot Thread) JBAS011800: Activating Naming Subsystem 21:29:36,508 INFO [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service 21:29:36,518 INFO [org.jboss.as.osgi] (Controller Boot Thread) JBAS011910: Activating OSGi Subsystem 21:29:36,554 INFO [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 3.2.0.Beta2 21:29:36,566 INFO [org.xnio] (MSC service thread 1-1) XNIO Version 3.0.0.Beta3 21:29:36,580 INFO [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.0.0.Beta3 21:29:36,606 INFO [org.jboss.as.security] (Controller Boot Thread) Activating Security Subsystem 21:29:36,849 INFO [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-2) The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 21:29:37,015 INFO [org.jboss.as.remoting] (MSC service thread 1-1) Listening on /0.0.0.0:9999 21:29:37,097 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Starting Coyote HTTP/1.1 on http--0.0.0.0-8080 21:29:37,101 INFO [org.jboss.as.jmx.JMXConnectorService] (MSC service thread 1-2) Starting remote JMX connector 21:29:37,333 INFO [org.jboss.as.ee] (Controller Boot Thread) Activating EE subsystem 21:29:37,409 INFO [org.jboss.as.connector] (MSC service thread 1-2) Starting JCA Subsystem (JBoss IronJacamar 1.0.3.Final) 21:29:37,446 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) Bound data source [java:jboss/datasources/ExampleDS] 21:29:38,057 INFO [org.jboss.as.deployment] (MSC service thread 1-1) Started FileSystemDeploymentService for directory /Jboss/standalone/deployments 21:29:38,074 INFO [org.jboss.as] (Controller Boot Thread) JBoss AS 7.0.2.Final "Arc" started in 4118ms - Started 93 of 148 services (55 services are passive or on-demand) (...etc) |
打开浏览器,访问:http://192.168.37.137:8080/
——————————————————————————————————————————————————————————————
Finished。
No one want to say something??[/可爱]