官术网_书友最值得收藏!

The installation guide and basic configuration

At this point, we assume that Java is correctly installed and configured as discussed in the previous section.

Now we are ready to download WildFly and start our installation. The download of the WildFly application server is available at http://wildfly.org/downloads/.

After the download completes and the file is sent to the server, we can initiate the installation. For this example, we will use a compressed version in the TGZ format, such as wildfly-8.0.0.Final.tar.gz.

First we must define a directory to perform the installation; one of the ways that I use to standardize my installation is by always using the following directory structure:

/opt/server/{wfly_dir_name}

Where {wfly_dir_name} is the name that you use to identify the instalation directory of your server.

Creating and accessing /opt/server using the following commands:

[root@wfly_book opt]# cd /opt/
[root@wfly_book opt]# mkdir /opt/server
[root@wfly_book opt]# cd /opt/server

Starting the WildFly extraction using the following commands:

[root@wfly_book server]# tar -xzvf /root/wildfly-8.0.0.Final.tar.gz
[root@wfly_book server]# ls
wildfly-8.0.0.Final

Note that the server directory has been created; we now have our WildFly application server installed. In the next topic, I'll talk a bit more about the installation and some basic settings, how to create a new user to access the management console and change the connection port numbers; we will also create a test application to perform a fresh deployment.

Before going on to the next step in which we will perform the first startup of the server, it is very interesting to understand how the subdirectories of WildFly are divided. The following are all the folders and their functions:

  • appclient: Configuration files, deployment content, and writable areas used by the application client container are run from this installation.
  • bin: All the server binaries, the startup script and also scripts that are used to setup the JVM startup parameters such as memory, heap memory size, among others, are present here.
  • docs: In this directory, the license files, sample configurations, documentation, and other documents are located that will increase your knowledge about WildFfy.
  • domain: This directory will only be used if the server is started in the domain mode. Inside are the settings files, deployments contents, and areas of writing used by the server to store log files and temporary files.
  • modules: The WildFly classloading is structured in a modular way. All the necessary modules are stored in this directory. Also, the new modules that are installed should be stored here following the directory pattern. This directory should only be modified if you know what you're doing to avoid classloading issues.
  • standalone: This directory will only be used when the server is started in the standalone mode. Here are configuration files, deployment contents, and areas of writing used by the server to store temporary files and logs, as well as the domain mode.
  • welcome-content: This is an area of internal use of the server that should not be used by end users unless they want to overwrite and insert their own application in the / context. Its alteration can influence the functioning of WildFly, welcome pages, or error messages that are present in this directory.

With a prior understanding of the function of each directory present in the WildFly installation, it is also very important to have an understanding of each of the modes in which WildFly works as well as knowing your directory structure; the possible modes of execution are the domain and standalone modes. A short description about them is given in the upcoming section.

Content of WildFly standalone and domain modes

The following directories are part of the Wildfly filesystem:

  • Configuration: It contains all the configuration files that are necessary to run this installation.
  • Deployments: This is the directory utilized to perforn your application deployments.
  • Lib/ext: This is the location for installed library jars referenced by applications using the Extension-List mechanism.
  • Tmp: These are the temporary files written by the server.
  • Data: This directory is not present on the domain mode. Here are files written by the server during startup and their lifecycle.
  • Log: These are the log files generated by the application server.
  • Content (only for domain): This directory must not be modified by end users. Here the Host Controller is stored in the internal work area for this installation.
  • Servers (only for domain): It is the writable area used by each application server instance that runs from this installation. Each application server instance will have its own subdirectory, created when the server is first started. In each server's subdirectory, there will be the following subdirectories:
    • data: This is the information written by the server that needs to survive a restart of the server
    • log: These are the server's log files
    • tmp: This is the location for temporary files written by the server
  • Tmp/auth (only for domain): This is the special location used to exchange authentication tokens with local clients, so they can confirm that they are local to the running AS process.

Overview of the configuration files

Basically, the main difference is in the management of the two modes.

The domain mode does not accept exploded deployment. Also, the domain mode allows centralized management of all running instances to perform the deploys across all group instances simultaneously, which may cause application downtime during the deploy. Meanwhile, the standalone mode keeps each single instance as a single server instance and it is not necessary to have a more complex configuration for implementation; the deployment can be performed instance by instance. The following is a brief explanation of each configuration present in the each WildFly 8 installation:

The standalone mode

The relevant files used in the standalone mode are explained as follows:

  • application-roles.properties: This is the file that contains the user permissions to access the applications. This file is changed by the user creation script that we will see later.
  • application-users.properties: This is the file that contains user information and password to access applications. This file is changed by the user creation script that we will see later.
  • mgmt-users.properties: This is the file that contains user information and password for access to the management console. This file is created by the user creation script available on the installation of the /bin directory.
  • mgmt-groups.properties: This file contains group information and administration permissions that the users have. This file is created by the user creation script.
  • logging.properties: This contains the initial bootstrap logging configuration for the AS instance. This boostrap logging configuration is replaced with the logging configuration specified in the standalone.xml file once the server boot has reached the point where that configuration is available.
  • standalone-full-ha.xml: It is a Java Enterprise Edition 6 certified full-profile configuration file with a high availability and the full list of services.
  • standalone-ha.xml: It is a Java Enterprise Edition 6 certified full-profile configuration file with high availability and the basic services.
  • standalone-full.xml: It is a Java Enterprise Edition 6 full-profile certified configuration file that includes all the technologies required by the full-profile specification, including most other OSGI with the full services.
  • standalone.xml: It is a Java Enterprise Edition 6 full-profile certified configuration file that includes all the technologies required by the Full Profile specification including most other OSGI with the full services.

The domain mode

The relevant files used in the domain mode are explained as follows:

  • application-users.properties: This is the file that contains the user permissions to access the applications. This file is changed by the user creation script that we will see later.
  • application-roles.properties: This is the file that contains user information and password to access applications. This file is changed by the user creation script that we will see later.
  • default-server-logging.properties: These are additional logger configurations. The root logger will always be configured.
  • domain.xml: It is a Java Enterprise Edition 6 full-profile certified configuration file that includes the technologies required by the full profile specification plus others including OSGi.
  • host-master.xml: This contains all the information contained in the host.xml file; however, with a little difference, these configurations will be applied to the host master of the cluster. In the review of the file we have "A simple configuration for a host controller that only acts as the master domain controller and does not itself directly control any servers."
  • host-slave.xml: In this file, all the information that will be applied in the domain hosts slaves is present, that is., all instances of WildFly that make up the cluster.
  • host.xml: This is the host controller configuration file for the installation. Each cluster member must have its host.xml file that contains particular information for each site. It must have information such as the name of the instance of the cluster, configurations about how a new member will contact the domain to register and access the domain configuration settings, as well as specific physical installation, for example, the name of the network interface that will be used for executing the WildFly.
  • logging.properties: This contains the logging configuration for the host controller and process controller that run off this installation. It also defines the initial bootstrap logging configuration for each individual AS instance. This boostrap logging configuration is replaced with the logging configuration specified in the domain.xml file once the server boot has reached the point where that configuration is available.
  • mgmt-users.properties: This is the file that contains user information and password for access to the management console. This file is created by the user creation script available on the installation of /bin.
  • mgmt-groups.properties: This file contains group information and administration permissions that the users have; this file is created by the user creation script.

Now that you know a bit about the structure of WildFly directories and subdirectories, as well as their possible modes of execution and its main configuration files, you may also want to deepen the content of the bin directory. It is the directory that contains all the operations contained in the server. The main ones start and stop WildFly and many other files access the bin directory to check this out.

The contents of the directory may seem a bit lengthy, but it is actually because the scripts are duplicated except those inside init.d. In this case, it is only usable in Linux RedHat or Debian and the service folder that is designed only for Windows. Both are binaries needed to run the WildFly as a service; all others are duplicated. All scripts with the sh extension are for Linux and all with the bat extension are for Windows. Now we will study only the main scripts based on scripts only for Linux, since Windows will have the same function. The following is a brief explanation of the principal scripts and that will be mostly used in everyday life:

  • add-user.sh: This is used to create an application or manage users that we will see later on in the chapter
  • domain.sh: This is the domain mode startup script
  • domain.conf: This is the boot configuration file that is used by domain.sh to set the boot parameters
  • standalone.sh: This is the standalone mode startup script
  • standalone.conf: This is the startup configuration file that is used by standalone.sh to set the boot parameters

The configuration files provide a little more detail. Instead of having the extension .conf, configuration files for Windows are terminated with .con f.bat.

Starting WildFly

WildFly has two execution modes, namely standalone and domain as previously described.

Starting the standalone mode

The following instructions will allow you to start WildFly in the standalone mode:

  1. Go to the bin directory of the installation. If you do not remember, you can get their location through the environment variable set previously, as shown in the following command:
    [root@wfly_book ~]# echo $JBOSS_HOME
    /opt/server/wildfly-8.0.0.CR1
    
  2. So just run the following command:
    [root@wfly_book ~]# cd $JBOSS_HOME/bin
    
  3. And then run WildFly in the standalone mode through the standalone.sh script as follows:
    [root@wfly_book bin]# ./standalone.sh
    

Note that during the boot we received a little warning saying it was unable to obtain the hostname using the previous method (InetAddress.getLocalHost ()). This method searches the hostname configured on the local DNS server; on Linux systems it is located under /etc /hosts. See the following warning:

16:35:20,783 WARN [com.arjuna.ats.arjuna] (Transaction Expired Entry Monitor) ARJUNA012210: Unable to use InetAddress.getLocalHost() to resolve address.

To solve this problem just add the hostname of the machine under /etc/hosts. There are two ways to do this. We can use the loopback address (127.0.0.1) or use the assigned address configured network interface (for example, eth0). For this example, we will use the network interface eth0.

To find your active interface type the following command:

  • Linux: ifconfig
  • Windows: ipconfig

Note

These commands must be performed in a command-line tool (bash/cmd).

After the set up, the hosts file will look similar to the following lines of command:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
#ip #Hostname
192.168.11.109 wfly_book

Now when you run the ping command, the hostname should respond by the configured IP address:

[root@wfly_book bin]# ping wfly_book
PING wfly_book (192.168.11.109) 56(84) bytes of data.
64 bytes from wfly_book (192.168.11.109): icmp_seq=1 ttl=64 time=0.023 ms

You can see that the warning we saw in the last startup did not occur again. If the startup at this moment occurred as expected without any error, it means that the settings made so far are correct.

Starting the domain mode

Assuming that the local directory is now /bin, run the following command:

[root@wfly_book bin]# ./domain.sh

Note that, unlike the standalone mode that starts only one process, in this mode we have four processes started by default. They are explained as follows:

  • Host Controller: This process is the instance that acts as a central point of administration for all servers that are in the same domain
  • Process Controller: This process is responsible for rehabilitating and monitoring other processes during its life cycle
  • Server One: This is the process corresponding to the first server. It is the first instance of the WildFly domain
  • Server Two: This is the process corresponding to the second server. It is the second instance of the WildFly domain

It is also important that we change the bind IP address of an application server, so we can access it from another machine. By default, WildFly will listen only on the loopback interface, or localhost, as shown in the following command:

tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 2745/Java

This information was acquired through the netstat command. You can also get this information through the server logs as shown in the following command:

18:42:29,119 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017519: Undertow HTTP listener default listening on /127.0.0.1:8080

So we can change the bind address. We have two options to make this configuration. The first is by passing the parameter to the JVM and running the startup script from the command line or through the standalone.conf or domain.conf configuration files. The parameter responsible for this configuration is as follows:

jboss.bind.address

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

To change the bind address only for one time, it can be changed for any purpose whatsoever. Pass the parameter in the startup script as follows:

[root@wfly_book bin]# ./standalone.sh -Djboss.bind.address=<your ip address>

To permanently make this change so that every time the instance is started it remains active, we have two choices: using standalone|domain.conf or in the configuration file of the installation (stanalone|domain.xml).

In the standalone|domain.conf file, at the end of the next line add the configuration mentioned previously:

JAVA_OPTS="-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.bind.address=<your ip address>"

And we also have the option to change the XML configuration file for the actual installation. This method is not very advisable, because the configuration file works with variables. The jboss.bind.address parameter is nothing but a variable that can be amended by passing a parameter to the JVM; if nothing is passed, WildFly will assume the default value for this and any other variable present in the configuration file.

To do this, change the variable value passing its IP address, as follows:

<interface name="public">
 <inet-address value="${jboss.bind.address:<your ip address>}"/>
</interface>

You can see that the bind address of WildFly now changes to what it was configured, using any of the ways mentioned earlier. Check the following part of the output:

19:13:05,888 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017519: Undertow HTTP listener default listening on /192.168.11.109:8080

And with the netstat command:

tcp 0 0 192.168.11.109:8080 0.0.0.0:* LISTEN 3070/java

We will access the running instance through a browser of your choice with the IP that was set up. In my case, the IP is 192.168.11.109 and we have the following page displayed:

Starting the domain mode
主站蜘蛛池模板: 南平市| 桐城市| 唐河县| 保山市| 栖霞市| 张家港市| 沙田区| 万源市| 乌兰察布市| 赤峰市| 濮阳市| 望江县| 连城县| 寿阳县| SHOW| 海门市| 逊克县| 石家庄市| 汤阴县| 扎兰屯市| 花莲市| 饶阳县| 晴隆县| 罗田县| 古田县| 波密县| 大丰市| 太康县| 玉山县| 雷州市| 澄江县| 布尔津县| 万安县| 木里| 博爱县| 乐山市| 曲麻莱县| 平定县| 大渡口区| 铁力市| 台安县|