wildfly install on centos

Root 계정 접속

install JDK

이미 있는 경우는 불필요

yum install java-1.8.0-openjdk-devel

user 생성

Root로 그냥 처리 할 경우 불필요함

[root@localhost ~]# groupadd -r wildfly
[root@localhost ~]# useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly

Download

https://wildfly.org/downloads/

에서 가장 최신 파일 Java EE Full & Web Distribution TGZ url copy

[root@localhost ~]# mkdir wildfly
[root@localhost ~]# cd wildfly/
[root@localhost wildfly]# wget https://download.jboss.org/wildfly/17.0.1.Final/wildfly-17.0.1.Final.tar.gz
--2019-07-25 14:14:51-- https://download.jboss.org/wildfly/17.0.1.Final/wildfly-17.0.1.Final.tar.gz
Resolving download.jboss.org (download.jboss.org)... 104.75.2.61
Connecting to download.jboss.org (download.jboss.org)|104.75.2.61|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 183598392 (175M) [application/x-gzip]
Saving to: ‘wildfly-17.0.1.Final.tar.gz’

100%[=================================================================================================>] 183,598,392 1.50MB/s in 1m 57s

2019-07-25 14:16:49 (1.50 MB/s) - ‘wildfly-17.0.1.Final.tar.gz’ saved [183598392/183598392]

[root@localhost wildfly]#
[root@localhost wildfly]# tar xf wildfly-17.0.1.Final.tar.gz -C /opt/
[root@localhost wildfly]# cd /opt
[root@localhost opt]# ls
gitlab rh vagrant wildfly-17.0.1.Final
[root@localhost opt]# ln -s /opt/wildfly-17.0.1.Final /opt/wildfly
[root@localhost opt]# ls
gitlab rh vagrant wildfly wildfly-17.0.1.Final
[root@localhost opt]#

권한 설정

[root@localhost opt]# chown wildfly:wildfly wildfly
[root@localhost opt]# ls -al
합계 0
drwxr-xr-x. 6 root root 88 7월 25 14:18 .
dr-xr-xr-x. 20 root root 287 7월 15 17:26 ..
drwxr-xr-x. 10 root root 212 7월 8 22:34 gitlab
drwxr-xr-x. 2 root root 6 10월 31 2018 rh
drwxr-xr-x. 4 root root 33 6월 21 19:42 vagrant
lrwxrwxrwx. 1 root root 25 7월 25 14:18 wildfly -> /opt/wildfly-17.0.1.Final
drwxr-xr-x. 11 wildfly wildfly 239 7월 3 10:59 wildfly-17.0.1.Final
[root@localhost opt]#

시스템 등록

[root@localhost etc]# mkdir /etc/wildfly
[root@localhost systemd]# pwd
/opt/wildfly/docs/contrib/scripts/systemd
[root@localhost systemd]# cp wildfly.conf /etc/wildfly/
[root@localhost scripts]# pwd
/opt/wildfly/docs/contrib/scripts
[root@localhost scripts]# ls
README.md init.d service systemd
[root@localhost scripts]# cd systemd/
[root@localhost systemd]# ls
README launch.sh wildfly.conf wildfly.service
[root@localhost systemd]# cp launch.sh /opt/wildfly/bin/
[root@localhost systemd]# chmod +x /opt/wildfly/bin/*.sh
[root@localhost systemd]# cp wildfly.service /etc/systemd/system/
[root@localhost systemd]# systemctl daemon-reload
[root@localhost systemd]# systemctl status wildfly
● wildfly.service - The WildFly Application Server
Loaded: loaded (/etc/systemd/system/wildfly.service; disabled; vendor preset: disabled)
Active: inactive (dead)

상위 프로세스중 wildfly.conf를 복사 하는 부분이 있는 해당 내용은 systemctl에 서비스를 등록 하기 위하여 필요 한 부분인다.

wildfly.service의 내용을 보면 다음과 같다.

[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=httpd.service

[Service]
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=wildfly
LimitNOFILE=102642
PIDFile=/var/run/wildfly/wildfly.pid
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND
StandardOutput=null

[Install]
WantedBy=multi-user.target

EnvironmentFile=-/etc/wildfly/wildfly.conf wildfly에 대한 config 설정 위치를 확인 가능하다.

해당 내용은 서비스를 시작 시켰을 때 다음과 같이 작동 하게 된다.

/opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0

[root@localhost wildfly]# systemctl status wildfly
● wildfly.service - The WildFly Application Server
Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: disabled)
Active: active (running) since 목 2019-07-25 15:14:42 KST; 4min 43s ago
Main PID: 10581 (launch.sh)
Tasks: 56
Memory: 348.6M
CGroup: /system.slice/wildfly.service
├─10581 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
├─10582 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
└─10639 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Sta...

7월 25 15:14:42 localhost.localdomain systemd[1]: Started The WildFly Application Server.
정상 작동 여부 확인
[root@localhost wildfly]# ps -ef | grep wildfly
wildfly 10581 1 0 15:14 ? 00:00:00 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
wildfly 10582 10581 0 15:14 ? 00:00:00 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
wildfly 10639 10582 2 15:14 ? 00:00:11 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=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 -b 0.0.0.0
root 13466 47780 0 15:21 pts/0 00:00:00 grep --color=auto wildfly
[root@localhost wildfly]# netstat -tnlp --tcp | grep 10639
tcp 0 0 127.0.0.1:10090 0.0.0.0:* LISTEN 10639/java
tcp 0 0 0.0.0.0:8180 0.0.0.0:* LISTEN 10639/java
tcp 0 0 0.0.0.0:8543 0.0.0.0:* LISTEN 10639/java

포트 3개가 열려 있는 것을 확인 할 수 있다.

  • 10090 : original 9990 -> management port
  • 8180: original 8080 -> http
  • 8543 : original 8443 -> https

상위와 같이 포트 수정을 위해서는 standard.xml을 수정해야 한다

/opt/wildfly/standalone/configuration

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:100}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>

Port Open

[root@localhost configuration]# sudo firewall-cmd --zone=public --permanent --add-port=8180/tcp
success
[root@localhost configuration]# sudo firewall-cmd --zone=public --permanent --add-port=10090/tcp
success
[root@localhost configuration]# sudo firewall-cmd --reload
success

remote use setting

wildfly administator 또는 remote cli등의 작업을 위해 사용자 등록을 처리한다.

[root@localhost bin]# pwd
/opt/wildfly/bin

[root@localhost 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 : sample
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 'sample' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'sample' to file '/opt/wildfly-17.0.1.Final/standalone/configuration/mgmt-users.properties'
Added user 'sample' to file '/opt/wildfly-17.0.1.Final/domain/configuration/mgmt-users.properties'
Added user 'sample' with groups to file '/opt/wildfly-17.0.1.Final/standalone/configuration/mgmt-groups.properties'
Added user 'sample' with groups to file '/opt/wildfly-17.0.1.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? yes
To represent the user add the following to the server-identities definition <secret value="dGhl1gmM3ODk=" />

Cli 사용법

접속 방법
[root@localhost bin]# ./jboss-cli.sh 
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 127.0.0.1:10090
[standalone@127.0.0.1:10090 /] exit
[root@localhost bin]# ./jboss-cli.sh --connect --controller=127.0.0.1:10090
제공 가능한 명령어

[standalone@127.0.0.1:10090 /] help --commands
Commands available in the current context:
attachment deployment-info run-batch
batch deployment-overlay security disable-http-auth-http-server
cd echo security disable-http-auth-management
clear echo-dmr security disable-sasl-management
command for security disable-ssl-http-server
command-timeout grep security disable-ssl-management
connect help security enable-http-auth-http-server
connection-info history security enable-http-auth-management
data-source if security enable-sasl-management
deploy jdbc-driver-info security enable-ssl-http-server
deployment deploy-cli-archive ls security enable-ssl-management
deployment deploy-file module security reorder-sasl-management
deployment deploy-url patch apply set
deployment disable patch history shutdown
deployment disable-all patch info try
deployment enable patch inspect undeploy
deployment enable-all pwd unset
deployment info quit version
deployment list read-attribute xa-data-source
deployment undeploy read-operation
deployment undeploy-cli-archive reload
To read a description of a specific command execute 'help <command name>'.

자세한 활용 법은

https://docs.jboss.org/author/display/WFLY/Command+Line+Interface

이곳에서 확인 가능

admin console

상위와 같이 작성 하고 테스트 해보면 http 서비스는 잘 접근이 되는데, admin console이 접근이 잘 안될 수 있다.

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    

tcp 0 0 127.0.0.0:10090 0.0.0.0:* LISTEN 64558/java

tcp 0 0 0.0.0.0:8180 0.0.0.0:* LISTEN 64558/java

사유는 127.0.0.0 이 부분 때문에 remote에서 접근이 안되는 것이다.

로컬에서는 잘 접근이 된다.

해당 부분을 해결 하기 위해서는 다음과 같이 수정이 필요 하다.

/opt/wildfly/bin/launch.sh

#!/bin/bash

if [ "x$WILDFLY_HOME" = "x" ]; then
WILDFLY_HOME="/opt/wildfly"
fi

if [[ "$1" == "domain" ]]; then
$WILDFLY_HOME/bin/domain.sh -c $2 -b $3
else
- $WILDFLY_HOME/bin/standalone.sh -c $2 -b $3
+ $WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement $3
fi