在Centos7 下安裝 Wildfly10

URL Link //n.sfs.tw/10255

2016-11-19 10:53:00 By 張○○

wildfly以前叫JBoss,2014.11.20改名叫Wildfly,起始版本是Wildfly8,現在已經出到Wildfly10(2016.2.9釋出)[1]。wildfly8~10都適用Java EE7.0的版本,此文說明如何在Centos7上安裝Wildfly10

系統

# uname -a
Linux java.example.com 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

安裝

安裝 git
# yum install git

安裝 wget
# yum install wget

下載wildfly10的安裝shell[2]
# git clone https://gist.github.com/sukharevd/6087988

git會建立一個目錄6087988/,執行其中的shell卯可
# cd 6087988/
# sh wildfly-install.sh
Downloading: http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.tar.gz...
Cleaning up...
Installation...
Registrating Wildfly as service...
Configuring service...
Configuring application server...
Done.

安裝 java
# yum install java

安裝完後wildfly10會被放在/opt中:
# ll
總計 4
lrwxrwxrwx.  1 wildfly wildfly   26  7月 20 01:44 wildfly -> /opt/wildfly-10.0.0.Final/
drwxr-xr-x. 10 wildfly wildfly 4096  1月 30 06:12 wildfly-10.0.0.Final

啟動

切換到wildfly10執行目錄
# cd /opt/wildfly/bin

Widlfly10啟動方式有獨立方式啟動(tandalone mode)、網域管理相容方式啟動(domain management capabilities)二種[3]
獨立方式啟動
# ./standalone.sh
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/wildfly-10.0.0.Final

  JAVA: java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

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

02:08:13,905 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.1.Final
02:08:14,333 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
02:08:14,490 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final) starting
02:08:16,664 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
....


以上就是有在執行中,可以按 CTRL-C停止執行。放到背景執行:
# ./standalone.sh &

網域方式啟動
#./domain.sh

同上,丟在背景執行
#./domain.sh &

domain mode和standalone mode的差異在[4][5]這裡有說明,基本上要做擴展集中式的管理就用domain,單機單服務的方式則用standalone.

檢驗及測試

要測試有無運作正常,開啟網頁,看看能不能出現歡迎頁:
http://你的ip:28080/
http://127.0.0.1:28080/

採用其他組態啟動

組態的設定檔放在 /opt/wildfly/standalone/configuration (for standalone mode)  或 /opt/wildfly/domain/configuration(for domain mode)

使用不同的設定檔啟動
# ./standalone.sh --server-config=standalone-full-ha.xml

或 domain mode
#./domain.sh --domain-config=my-domain-configuration.xml

設置組態

由設定檔中複製一個
# cp standalone-full-ha.xml my-sa-full-ha.xml

編輯修改listen address
找到public這裡將127.0.0.1改為any-address
        <interface name="public">
<!--            <inet-address value="${jboss.bind.address:127.0.0.1}"/> -->
            <any-address/>
        </interface>

多個位址可寫多行,例如:
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
            <inet-address value="${jboss.bind.address.management:192.168.1.240}"/>
            <inet-address value="${jboss.bind.address.management:[::1]}"/>
        </interface>

新增管理者

# 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 : axer
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 :
WFLYDM0102: Password should have at least 1 non-alphanumeric symbol.
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 'axer' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'axer' to file '/opt/wildfly-10.0.0.Final/standalone/configuration/mgmt-users.properties'
Added user 'axer' to file '/opt/wildfly-10.0.0.Final/domain/configuration/mgmt-users.properties'
Added user 'axer' with groups  to file '/opt/wildfly-10.0.0.Final/standalone/configuration/mgmt-groups.properties'
Added user 'axer' with groups  to file '/opt/wildfly-10.0.0.Final/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? no


進入管理介面(有新增使用者請重啟服務)
http://你的ip:9990/

輪入你的管理者帳密後進到管理畫面(沒有管理者帳號就進不到這個畫面)

參考資料

[1] Wikipedia 中wildfly的說明 https://en.wikipedia.org/wiki/WildFly
[2] Dmitriy Sukharev 寫的安裝shell gist放在github
[3] Wildfly10官網 Getting Started Guide
[4] whats-the-difference-between-standalone-and-domain-on-jee6 @ stackoverflow
[5] JBOSS DOCS domain mode