Java應用服務器WildFly

我的博客已遷移到xdoujiang.com請去那邊和我交流
紅帽公司宣佈JBoss AS的繼任者WildFly,WildFly將推動下一代應用服務器技術的發展,
這個項目的名字是JBoss.org社區成員在2012年底投票產生。
WildFly將繼續保留 JBoss 企業應用平臺並定位一些關鍵的中間件技術,
包括更靈活和更先進的應用開發,實現開放混合雲和 Java EE 7.
該項目首個迭代版本WildFly 8將首先通過Java EE 7認證,
帶來更簡化、標準化和嵌入式特性,適合雲計算和移動開發場景。
紅帽已經演示了很多項目,包括 JBoss AS 7、Infinispan以及運行在Raspberry Pi、嵌入式設備和移動電話上。
WildFly曾用名:JBoss Application Server

一、基礎環境
1、角色、ip、版本、內核
serverA 10.1.10.185 3.2.0-4-amd64 7.8 jdk wildfly
clientB win7
wildfly-9.0.1.Final.zip
jdk-8u51-linux-x64.tar.gz

2、安裝基礎包
apt-get -y install axel unzip

二、安裝java環境
1、下載
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz"

2、創建目錄
mkdir -p /opt/java

3、解壓
tar zxvf jdk-8u51-linux-x64.tar.gz -C /opt/java/

4、配置java的環境變量
cat /etc/profile
export JAVA_HOME=/opt/java/jdk1.8.0_51
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

5、生效
source /etc/profile

6、查看java版本
1)java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

7、使用jps命令查看相關java信息
1)jps -mlv
11885 sun.tools.jps.Jps -mlv -Denv.class.path=.:/opt/java/jdk1.8.0_51/lib/dt.jar:/opt/java/jdk1.8.0_51/lib/tools.jar -Dapplication.home=/opt/java/jdk1.8.0_51 -Xms8m
2)參數說明
-m  Displays the arguments passed to the main method.The output may be null for embedded JVMs(輸出main method的參數) 
-l  Displays the full package name for the application s main class or the full path name to the application s JAR file(輸出完全的包名,應用主類名,jar的完全路徑名) 
-v  Displays the arguments passed to the JVM(輸出jvm參數) 

三、安裝wildfly
1、下載wildfly-9.0.1.Final.zip
axel -n 10 http://download.jboss.org/wildfly/9.0.1.Final/wildfly-9.0.1.Final.zip

2、解壓
unzip wildfly-9.0.1.Final.zip -d /opt/

3、改名
mv /opt/wildfly-9.0.1.Final/ /opt/wildfly

4、查看下目錄結構
ll /opt/wildfly-9.0.1.Final/
total 424
drwxr-xr-x 3 root root   4096 Jul 23 21:01 appclient
drwxr-xr-x 5 root root   4096 Jul 23 21:01 bin
-rw-r--r-- 1 root root   2451 Jul 23 21:01 copyright.txt
drwxr-xr-x 4 root root   4096 Jul 23 21:01 docs
drwxr-xr-x 5 root root   4096 Jul 23 21:01 domain
-rw-r--r-- 1 root root 366323 Jul 23 21:01 jboss-modules.jar
-rw-r--r-- 1 root root  26530 Jul 23 21:01 LICENSE.txt
drwxr-xr-x 3 root root   4096 Jul 23 21:01 modules
-rw-r--r-- 1 root root   2531 Jul 23 21:01 README.txt
drwxr-xr-x 6 root root   4096 Jul 23 21:01 standalone
drwxr-xr-x 2 root root   4096 Jul 23 21:01 welcome-content

5、複製配置文件
cp /opt/wildfly/standalone/configuration/standalone.xml /opt/wildfly/standalone/configuration/standalone.xml.bak

6、修改配置
sed -i 's/127.0.0.1/10.1.10.185/' /opt/wildfly/standalone/configuration/standalone.xml

7、添加wildfly用戶用於啓動腳本的
adduser --system --group --no-create-home --home /opt/wildfly/ --disabled-login wildfly
Adding system user wildfly (UID 102) ...
Adding new group wildfly (GID 104) ...
Adding new user wildfly (UID 102) with group wildfly ...
Not creating home directory /opt/wildfly/.

8、更改目錄權限
chown wildfly /opt/wildfly/ -R

9、複製啓動腳本
cp /opt/wildfly/bin/init.d/wildfly-init-debian.sh /etc/init.d/wildfly

10、啓動服務
/etc/init.d/wildfly start
[ ok ] Starting WildFly Application Server: wildfly.

11、查看端口和進程
1)查看端口
netstat -tupnl |grep java
tcp        0      0 10.1.10.185:8080        0.0.0.0:*               LISTEN      2874/java       
tcp        0      0 10.1.10.185:9990        0.0.0.0:*               LISTEN      2874/java   
2)查看進程
ps -ef |grep stan
wildfly    2796      1  0 11:20 pts/1    00:00:00 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml
wildfly    2874   2796  3 11:20 pts/1    00:00:06 /opt/java/jdk1.8.0_51/bin/java -D[Standalone] -server -XX:+UseCompressedOops -server -XX:+UseCompressedOops -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/opt/wildfly/standalone/log/server.log -Dlogging.configuration=file:/opt/wildfly/standalone/configuration/logging.properties -jar /opt/wildfly/jboss-modules.jar -mp /opt/wildfly/modules org.jboss.as.standalone -Djboss.home.dir=/opt/wildfly -Djboss.server.base.dir=/opt/wildfly/standalone -c standalone.xml

12、查看相關日誌
cat /opt/wildfly/standalone/log/server.log
2015-09-29 11:20:30,338 INFO  [org.jboss.as.server] (Thread-2) WFLYSRV0220: Server shutdown has been requested.
2015-09-29 11:20:30,408 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0010: Unbound data source [java:jboss/datasources/ExampleDS]
2015-09-29 11:20:30,412 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0019: Host default-host stopping
2015-09-29 11:20:30,426 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0019: Stopped Driver service with driver-name = h2
2015-09-29 11:20:30,433 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0008: Undertow HTTP listener default suspending
2015-09-29 11:20:30,438 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0007: Undertow HTTP listener default stopped, was bound to /127.0.0.1:8080
2015-09-29 11:20:30,441 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0004: Undertow 1.2.9.Final stopping
2015-09-29 11:20:30,463 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0050: WildFly Full 9.0.1.Final (WildFly Core 1.0.1.Final) stopped in 83ms
2015-09-29 11:20:37,185 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final
2015-09-29 11:20:37,726 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
2015-09-29 11:20:37,819 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 9.0.1.Final (WildFly Core 1.0.1.Final) starting
2015-09-29 11:20:37,831 DEBUG [org.jboss.as.config] (MSC service thread 1-2) Configured system properties:
    [Standalone] = 
    awt.toolkit = sun.awt.X11.XToolkit
    file.encoding = UTF-8
    file.encoding.pkg = sun.io
    file.separator = /
    java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
    java.awt.headless = true
    java.awt.printerjob = sun.print.PSPrinterJob
    java.class.path = /opt/wildfly/jboss-modules.jar
    java.class.version = 52.0
    java.endorsed.dirs = /opt/java/jdk1.8.0_51/jre/lib/endorsed
    java.ext.dirs = /opt/java/jdk1.8.0_51/jre/lib/ext:/usr/java/packages/lib/ext
    java.home = /opt/java/jdk1.8.0_51/jre
    java.io.tmpdir = /tmp
    java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
    java.net.preferIPv4Stack = true
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.8.0_51-b16
    java.specification.name = Java Platform API Specification
    java.specification.vendor = Oracle Corporation
    java.specification.version = 1.8
    java.util.logging.manager = org.jboss.logmanager.LogManager
    java.vendor = Oracle Corporation
    java.vendor.url = http://java.oracle.com/
    java.vendor.url.bug = http://bugreport.sun.com/bugreport/
    java.version = 1.8.0_51
    java.vm.info = mixed mode
    java.vm.name = Java HotSpot(TM) 64-Bit Server VM
    java.vm.specification.name = Java Virtual Machine Specification
    java.vm.specification.vendor = Oracle Corporation
    java.vm.specification.version = 1.8
    java.vm.vendor = Oracle Corporation
    java.vm.version = 25.51-b03
    javax.management.builder.initial = org.jboss.as.jmx.PluggableMBeanServerBuilder
    javax.xml.datatype.DatatypeFactory = __redirected.__DatatypeFactory
    javax.xml.parsers.DocumentBuilderFactory = __redirected.__DocumentBuilderFactory
    javax.xml.parsers.SAXParserFactory = __redirected.__SAXParserFactory
    javax.xml.stream.XMLEventFactory = __redirected.__XMLEventFactory
    javax.xml.stream.XMLInputFactory = __redirected.__XMLInputFactory
    javax.xml.stream.XMLOutputFactory = __redirected.__XMLOutputFactory
    javax.xml.transform.TransformerFactory = __redirected.__TransformerFactory
    javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema = __redirected.__SchemaFactory
    javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom = __redirected.__XPathFactory
    jboss.home.dir = /opt/wildfly
    jboss.host.name = debian
    jboss.modules.dir = /opt/wildfly/modules
    jboss.modules.system.pkgs = org.jboss.byteman
    jboss.node.name = debian
    jboss.qualified.host.name = debian
    jboss.server.base.dir = /opt/wildfly/standalone
    jboss.server.config.dir = /opt/wildfly/standalone/configuration
    jboss.server.data.dir = /opt/wildfly/standalone/data
    jboss.server.deploy.dir = /opt/wildfly/standalone/data/content
    jboss.server.log.dir = /opt/wildfly/standalone/log
    jboss.server.name = debian
    jboss.server.persist.config = true
    jboss.server.temp.dir = /opt/wildfly/standalone/tmp
    line.separator = 
    logging.configuration = file:/opt/wildfly/standalone/configuration/logging.properties
    module.path = /opt/wildfly/modules
    org.jboss.boot.log.file = /opt/wildfly/standalone/log/server.log
    org.jboss.resolver.warning = true
    org.xml.sax.driver = __redirected.__XMLReaderFactory
    os.arch = amd64
    os.name = Linux
    os.version = 3.2.0-4-amd64
    path.separator = :
    sun.arch.data.model = 64
    sun.boot.class.path = /opt/java/jdk1.8.0_51/jre/lib/resources.jar:/opt/java/jdk1.8.0_51/jre/lib/rt.jar:/opt/java/jdk1.8.0_51/jre/lib/sunrsasign.jar:/opt/java/jdk1.8.0_51/jre/lib/jsse.jar:/opt/java/jdk1.8.0_51/jre/lib/jce.jar:/opt/java/jdk1.8.0_51/jre/lib/charsets.jar:/opt/java/jdk1.8.0_51/jre/lib/jfr.jar:/opt/java/jdk1.8.0_51/jre/classes
    sun.boot.library.path = /opt/java/jdk1.8.0_51/jre/lib/amd64
    sun.cpu.endian = little
    sun.cpu.isalist = 
    sun.io.unicode.encoding = UnicodeLittle
    sun.java.command = /opt/wildfly/jboss-modules.jar -mp /opt/wildfly/modules org.jboss.as.standalone -Djboss.home.dir=/opt/wildfly -Djboss.server.base.dir=/opt/wildfly/standalone -c standalone.xml
    sun.java.launcher = SUN_STANDARD
    sun.jnu.encoding = UTF-8
    sun.management.compiler = HotSpot 64-Bit Tiered Compilers
    sun.os.patch.level = unknown
    user.country = US
    user.dir = /opt/wildfly
    user.home = /opt/wildfly/
    user.language = en
    user.name = wildfly
    user.timezone = Asia/Shanghai
2015-09-29 11:20:37,832 DEBUG [org.jboss.as.config] (MSC service thread 1-2) VM Arguments: -D[Standalone] -XX:+UseCompressedOops -XX:+UseCompressedOops -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/opt/wildfly/standalone/log/server.log -Dlogging.configuration=file:/opt/wildfly/standalone/configuration/logging.properties 
2015-09-29 11:20:39,982 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 17) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
2015-09-29 11:20:39,984 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 12) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=ExampleDS' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
2015-09-29 11:20:40,084 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
2015-09-29 11:20:40,127 INFO  [org.xnio] (MSC service thread 1-2) XNIO version 3.3.1.Final
2015-09-29 11:20:40,163 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.3.1.Final
2015-09-29 11:20:40,256 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 4.0.9.Final
2015-09-29 11:20:40,339 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
2015-09-29 11:20:40,341 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 2 core threads with 16 task threads based on your 1 available processors
2015-09-29 11:20:40,414 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
2015-09-29 11:20:40,427 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
2015-09-29 11:20:40,453 INFO  [org.jboss.as.connector] (MSC service thread 1-2) WFLYJCA0009: Starting JCA Subsystem (IronJacamar 1.2.4.Final)
2015-09-29 11:20:40,475 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
2015-09-29 11:20:40,493 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
2015-09-29 11:20:40,435 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
2015-09-29 11:20:40,539 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
2015-09-29 11:20:40,566 INFO  [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=4.9.2.Final
2015-09-29 11:20:40,617 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = h2
2015-09-29 11:20:40,725 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0003: Undertow 1.2.9.Final starting
2015-09-29 11:20:40,765 INFO  [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
2015-09-29 11:20:40,733 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0003: Undertow 1.2.9.Final starting
2015-09-29 11:20:40,782 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
2015-09-29 11:20:41,211 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path /opt/wildfly/welcome-content
2015-09-29 11:20:41,397 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0012: Started server default-server.
2015-09-29 11:20:41,707 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
2015-09-29 11:20:41,737 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on /10.1.10.185:8080
2015-09-29 11:20:42,175 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
2015-09-29 11:20:42,209 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/wildfly/standalone/deployments
2015-09-29 11:20:42,510 INFO  [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBoss Web Services - Stack CXF Server 5.0.0.Final
2015-09-29 11:20:42,890 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://10.1.10.185:9990/management
2015-09-29 11:20:42,893 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://10.1.10.185:9990
2015-09-29 11:20:42,894 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.1.Final (WildFly Core 1.0.1.Final) started in 6225ms - Started 203 of 379 services (210 services are lazy, passive or on-demand)

四、測試(clientB)
1、輸入10.1.10.185:8080後看到頁面出來了

wKiom1YKg-3Cyrw9AAQeasxBvvE595.jpg2、輸入10.1.10.185:9990後看到管理頁面
wKioL1YKhATSjRVNAAbblHTzovw638.jpg

3、添加管理者
cd /opt/wildfly/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): a
Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : admin
The username 'admin' is easy to guess
Are you sure you want to add user 'admin' yes/no? yes
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
Password : 
WFLYDM0099: Password should have at least 8 characters!
Are you sure you want to use the password entered yes/no? yes
Re-enter Password : 
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: 
About to add user 'admin' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'admin' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
Added user 'admin' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
Added user 'admin' with groups  to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
Added user 'admin' with groups  to file '/opt/wildfly/domain/configuration/mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process? 
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret value="cmVkaGF0" />
PS:根據提示創建管理用戶

wKioL1YKhBPxhgpTAAG6-VMS5Is799.jpg

wKiom1YKhAmBeDA4AAUN81WyP3I887.jpg

五、參考文章
http://wildfly.org/
https://docs.jboss.org/author/display/WFLY9/Documentation
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章