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

  • WildFly Cookbook
  • Luigi Fugaro
  • 589字
  • 2021-07-16 13:38:15

Connecting to the CLI

There are three ways to manage your WildFly, that is, by editing the XML file, the Console and the CLI.

  • First of all, editing the XML directly can be error-prone, as it can waste you precious seconds; moreover, every change requires a server restart.
  • The Console gives you visual editing features, but it's not complete. The Web Console can perform just a subset of all the available actions that you can execute using the CLI.
  • CLI stands for Command Line Interface, and it is a tool that you are recommended to use to manage your WildFly application server.

Why the CLI? Most of the time, for security reasons, you connect to enterprise environments via SSH and are thus not able to see the Web Console at all. CLI WildFly comes in handy for this purpose.

CLI is a powerful tool that gives you full control over WildFly; you can deploy and undeploy applications, create and manage data sources, manage logging, change system properties, stop and start instances, and more. Working with the CLI also helps you understand the WildFly core logic so you can really become an expert WildFly administrator. Nevertheless, if you really want a GUI as well, you can have the CLI in GUI version; just execute the following command while you have your WildFly running:

$ cd $WILDFLY_HOME
$ ./bin/jboss-cli.sh --gui

The following screenshot depicts the CLI GUI tool:

CLI GUI tool

Now, it's time to play around with the CLI. Let's see what you can do!

Getting ready

As the CLI is a management tool, you will need to have your WildFly instance up and running. In this case too, we will use the default standalone configuration.

Open a terminal window and start WildFly:

$ cd $WILDFLY_HOME
$ ./bin/standalone.sh
...
22:12:23,600 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) started in 3087ms - Started 202 of 379 services (210 services are lazy, passive or on-demand)

How to do it…

  1. Let's open a terminal window:
    $ cd $WILDFLY_HOME
    $ ./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 /]
  2. Once in, we need to connect to the running instance. By typing the command connect, the tool connects to the instance with the default parameters, which is localhost:9990.
    [disconnected /] connect
    [standalone@localhost:9990 /]
  3. You can also connect to the CLI directly from the command line by passing the --connect parameter as follows:
    $ cd $WILDFLY_HOME
    $ ./bin/jboss-cli.sh --connect
    [standalone@localhost:9990 /]

    From now on, we will connect directly to the CLI without having to connect to it from the inside.

  4. Now try the command listing ls (as you would do in Linux):
  5. The list command gives you all the components that you can operate on, pretty much what you can see editing the standalone.xml. In fact, listing the subsystems, you will see all the subsystems present declared in standalone.xml:

There's more…

Remember that the Tab key on your keyboard is your friend. If you don't remember a command, just hit Tab. If you don't remember how to complete a command, just hit Tab. Hitting the Tab key will show all the possible solutions within your current context.

There are two others special characters within the CLI: / (the forward slash) and : (the colon). The forward slash is used to navigate through the contexts, while the colon is used to invoke method operation within the last selected context. Check the next recipe for an example.

主站蜘蛛池模板: 金山区| 余江县| 鸡泽县| 资源县| 连江县| 天峻县| 视频| 泾阳县| 柯坪县| 西贡区| 澄城县| 白水县| 资溪县| 连山| 千阳县| 泰宁县| 绍兴县| 九龙县| 广安市| 新龙县| 行唐县| 宁国市| 太谷县| 余江县| 葫芦岛市| 六盘水市| 清水县| 邵阳市| 开阳县| 新巴尔虎右旗| 瑞昌市| 嘉鱼县| 怀安县| 环江| 安泽县| 太和县| 阿拉尔市| 安宁市| 青神县| 吉安县| 鲁山县|