Chapter 11. How to…​

The following CLI commands and operations provide basic examples on how to accomplish certain tasks. For detailed instructions, see the appropriate section of the Configuration Guide, Configuring Messaging, or other JBoss EAP documentation.

Unless specified otherwise, the examples apply when running as a standalone server. Use the --help argument on a command to get usage for that command. Use the read-operation-description to get information on a particular operation for a resource.

11.1. Add a Datasource

data-source add --name=DATASOURCE_NAME --jndi-name=JNDI_NAME --driver-name=DRIVER_NAME  --connection-url=CONNECTION_URL

11.2. Add an Extension

Example: Add a New Extension to a Configuration

/extension=EXTENSION_NAME:add

11.3. Add a Jakarta Messaging Queue

jms-queue add --queue-address=QUEUE_NAME --entries=JNDI_NAME

11.4. Add a Jakarta Messaging Topic

jms-topic add --topic-address=TOPIC_NAME --entries=JNDI_NAME

11.5. Add a Module

module add --name=MODULE_NAME --resources=PATH_TO_RESOURCE --dependencies=DEPENDENCIES

Additional resources

Important

Using the module management CLI command to add and remove modules is provided as Technology Preview only. This command is not appropriate for use in a managed domain or when connecting to the management CLI remotely. Modules should be added and removed manually in a production environment. For more information, see the Create a Custom Module Manually and Remove a Custom Module Manually sections of the JBoss EAP Configuration Guide.

Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend to use them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

See Technology Preview Features Support Scope on the Red Hat Customer Portal for information about the support scope for Technology Preview features.

11.6. Add a Server

Example: Add a New Server to a Host in a Managed Domain

/host=HOST_NAME/server-config=SERVER_NAME:add(group=SERVER_GROUP_NAME)

11.7. Add a Server Group

Example: Add a New Server Group in a Managed Domain

/server-group=SERVER_GROUP_NAME:add(profile=PROFILE_NAME, socket-binding-group=SOCKET_BINDING_GROUP_NAME)

11.8. Add a System Property

/system-property=PROPERTY_NAME:add(value=PROPERTY_VALUE)

11.9. Clone a Profile

Example: Clone a Profile in a Managed Domain

/profile=PROFILE_TO_CLONE:clone(to-profile=NEW_PROFILE_NAME)

11.10. Create a Hierarchical Profile

Example: Create a New Profile That Inherits from Other Profiles

/profile=NEW_PROFILE_NAME:add(includes=[PROFILE_1,PROFILE_2])

11.11. Deploy an Application to a Managed Domain

Example: Deploy an Application to All Server Groups

deployment deploy-file /path/to/DEPLOYMENT.war --all-server-groups

Example: Deploy an Application to One or More Server Groups

deployment deploy-file /path/to/DEPLOYMENT.war --server-groups=SERVER_GROUP_1,SERVER_GROUP_2

11.12. Deploy an Application to a Standalone Server

deployment deploy-file /path/to/DEPLOYMENT.war

11.13. Disable All Applications

deployment disable /path/to/DEPLOYMENT.war

You can use the deployment disable-all command to disable all the deployments.

deployment disable-all

11.14. Display the Active User

Example: Command to Display the Current User

:whoami

Example: Output for the Current User

{
    "outcome" => "success",
    "result" => {"identity" => {
        "username" => "$local",
        "realm" => "ManagementRealm"
    }}
}

11.15. Display the Contents of an Attachment

You can use the attachment display command to display the contents of an attachment returned from a management operation. This applies to any management operation that returns the attached-streams response header.

For example, the following operation returns the server.log file attached as a stream.

/subsystem=logging/log-file=server.log:read-attribute(name=stream)
{
    "outcome" => "success",
    "result" => "f61a27c4-c5a7-43ac-af1f-29e90c9acb3e",
    "response-headers" => {"attached-streams" => [{
        "uuid" => "f61a27c4-c5a7-43ac-af1f-29e90c9acb3e",
        "mime-type" => "text/plain"
    }]}
}

You can use the attachment display command to display the contents of the stream returned from this operation to the console.

attachment display --operation=/subsystem=logging/log-file=server.log:read-attribute(name=stream)

This outputs the contents of the server.log file to the console.

ATTACHMENT 3480a327-31dd-4412-bdf3-f36c94ac4a09:
2019-10-18 09:19:37,082 INFO  [org.jboss.modules] (main) JBoss Modules version 1.8.6.Final-redhat-00001
2019-10-18 09:19:37,366 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.5.Final-redhat-00001
2019-10-18 09:19:37,380 INFO  [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final-redhat-1
2019-10-18 09:19:37,510 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: JBoss EAP 7.4.0 (WildFly Core 10.0.0.Final-redhat-20190924) starting
...

11.16. Display Schema Information

To show the schema information for the :product-info command:

:read-operation-description(name=product-info)

To display the schema version, execute an ls command at the management CLI root and look for the management-*-version values:

...
management-major-version=4
management-micro-version=0
management-minor-version=1
...

11.17. Display System and Server Information

Example: Command to Display the System and Server Information

:product-info

Example: Output for the System and Server Information

{
    "outcome" => "success",
    "result" => [{"summary" => {
        "host-name" => "__HOST_NAME__",
        "instance-identifier" => "__INSTANCE_ID__",
        "product-name" => "JBoss EAP",
        "product-version" => "EAP 7.4.0",
        "product-community-identifier" => "Product",
        "product-home" => "__EAP_HOME__",
        "standalone-or-domain-identifier" => "__OPERATING_MODE__",
        "host-operating-system" => "__OS_NAME__",
        "host-cpu" => {
            "host-cpu-arch" => "__CPU_ARCH__",
            "host-core-count" => __CORE_COUNT__
        },
        "jvm" => {
            "name" => "__JAVA_VM_NAME__",
            "java-version" => "__JAVA_VERSION__",
            "jvm-version" => "__JAVA_VM_VERSION__",
            "jvm-vendor" => "__JAVA_VM_VENDOR__",
            "java-home" => "__JAVA_HOME__"
        }
    }}]
}

Similarly, for a managed domain, you can display the information for a particular JBoss EAP host or server:

/host=HOST_NAME:product-info
/host=HOST_NAME/server=SERVER_NAME:product-info

11.18. Enable All Disabled Deployments

deployment enable DEPLOYMENT.war

You can use the deployment enable-all command to enable all the deployments.

deployment enable-all --server-groups=other-server-group

11.19. Get the Command Timeout Value

Example: Display the CLI Command Timeout Value

command-timeout get

The value returned is in seconds. A value of 0 means no timeout.

11.20. Reload a Host Controller

reload --host=HOST_NAME

11.21. Reload a Host Controller in Admin-only Mode

reload --host=HOST_NAME --admin-only=true

11.22. Reload All Servers in a Server Group

Example: Reload All Servers in a Certain Server Group in a Managed Domain

/server-group=SERVER_GROUP_NAME:reload-servers

Note

To reload the servers in a suspended state, pass in the start-mode=suspend argument.

11.23. Reload a Server

Example: Reload a Server in a Managed Domain

/host=HOST_NAME/server=SERVER_NAME:reload

Note

To reload the server in a suspended state, pass in the start-mode=suspend argument.

11.24. Reload a Standalone Server

reload
Note

To reload the server in admin-only mode, pass in the --start-mode=admin-only argument. To reload the server in a suspended state, pass in the --start-mode=suspend argument.

11.25. Remove an Extension

Example: Remove an Existing Extension

/extension=EXTENSION_NAME:remove

11.26. Remove a Module

module remove --name=MODULE_NAME
Important

Using the module management CLI command to add and remove modules is provided as Technology Preview only. This command is not appropriate for use in a managed domain or when connecting to the management CLI remotely. Modules should be added and removed manually in a production environment. For more information, see the Create a Custom Module Manually and Remove a Custom Module Manually sections of the JBoss EAP Configuration Guide.

Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend to use them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

See Technology Preview Features Support Scope on the Red Hat Customer Portal for information about the support scope for Technology Preview features.

11.27. Reset the Command Timeout Value

Example: Reset the Command Timeout to the Default Value

command-timeout reset default

Example: Reset the Command Timeout to the Value Provided by the CLI Configuration

command-timeout reset config

Note

The value provided by the CLI configuration can be set in either in the EAP_HOME/bin/jboss-cli.xml file or passed in with the --command-timeout argument when starting the management CLI.

11.28. Restart All Servers in a Server Group

Example: Restart All Servers in a Certain Server Group in a Managed Domain

/server-group=SERVER_GROUP_NAME:restart-servers

Note

To restart the servers in a suspended state, pass in the start-mode=suspend argument.

11.29. Restart a Server

Example: Restart a Server in a Managed Domain

/host=HOST_NAME/server=SERVER_NAME:restart

Note

To restart the server in a suspended state, pass in the start-mode=suspend argument.

11.30. Save the Contents of an Attachment

You can use the attachment save command to save the contents of an attachment returned from a management operation to a file. This applies to any management operation that returns the attached-streams response header.

For example, the following operation returns the server.log file attached as a stream.

/subsystem=logging/log-file=server.log:read-attribute(name=stream)
{
    "outcome" => "success",
    "result" => "f61a27c4-c5a7-43ac-af1f-29e90c9acb3e",
    "response-headers" => {"attached-streams" => [{
        "uuid" => "f61a27c4-c5a7-43ac-af1f-29e90c9acb3e",
        "mime-type" => "text/plain"
    }]}
}

You can use the attachment save command to save the contents of the stream returned form this operation to a file.

attachment save --operation=/subsystem=logging/log-file=server.log:read-attribute(name=stream) --file=log-output.txt

This saves the contents of the server.log file to EAP_HOME/bin/log-output.txt.

11.31. Set the Command Timeout Value

Example: Set the Maximum Time to Wait for a CLI Command to Complete

command-timeout set TIMEOUT_VALUE

The value is set in seconds. A value of 0 means no timeout.

11.32. Shut Down a Host Controller

Example: Shut Down a Host Controller in a Managed Domain

shutdown --host=HOST_NAME

11.33. Shut Down the Server

Example: Shut Down a Standalone Server

shutdown

11.34. Start All Servers in a Server Group

Example: Start All Servers in a Certain Server Group in a Managed Domain

/server-group=SERVER_GROUP_NAME:start-servers

Note

To start the servers in a suspended state, pass in the start-mode=suspend argument.

11.35. Start a Server

Example: Start a Server in a Managed Domain

/host=HOST_NAME/server=SERVER_NAME:start

Note

To start the server in a suspended state, pass in the start-mode=suspend argument.

11.36. Stop All Servers in a Server Group

Example: Stop All Servers in a Certain Server Group in a Managed Domain

/server-group=SERVER_GROUP_NAME:stop-servers

11.37. Stop a Server

Example: Stop a Server in a Managed Domain

/host=HOST_NAME/server=SERVER_NAME:stop

11.38. Take a Configuration Snapshot

Example: Take a Snapshot of the Current Configurations

:take-snapshot

11.39. Undeploy All Applications

Example: Undeploy All Applications from a Managed Domain

deployment undeploy * --all-relevant-server-groups

Example: Undeploy All Applications from a Standalone Domain

deployment undeploy *

11.40. Undeploy an Application from a Managed Domain

Example: Undeploy an Application from All Server Groups with That Deployment

deployment undeploy DEPLOYMENT.war --all-relevant-server-groups

Example: Undeploy an Application from a Specific Server Group

deployment undeploy DEPLOYMENT.war --server-groups=SERVER_GROUP_NAME

11.41. Undeploy an Application from a Standalone Server

deployment undeploy DEPLOYMENT.war

11.42. Update a Host Name

Example: Update the Name of a Host in a Managed Domain

/host=EXISTING_HOST_NAME:write-attribute(name=name,value=NEW_HOST_NAME)
reload --host=EXISTING_HOST_NAME

The host must be reloaded in order for the changes to take effect.

11.43. Upload an Attachment

You can upload a local file as an attachment to management operations that accept file streams. For example, the following management CLI command uses the input-stream-index option to upload the contents of a local file to an exploded deployment.

/deployment=DEPLOYMENT_NAME.war:add-content(content=[{target-path=/path/to/FILE_IN_DEPLOYMENT, input-stream-index=/path/to/LOCAL_FILE_TO_UPLOAD}]

For more details on uploading files to a deployment, see the Add Content to an Exploded Deployment section of the Configuration Guide.

11.44. View a Server Log

/subsystem=logging/log-file=SERVER_LOG_NAME:read-log-file

11.45. Assigning a generic type command to a specific node

You can assign a generic type command to a specific node type by using the --node-type argument. You can use the generic type command to edit properties or call the operations of a specific node type in a management model.

The --node-type argument is available both on standalone servers and on servers in a managed domain. After you call a command, the server configuration file is updated.

Issue help command in your terminal to view a description of the generic type command and any of its arguments. You can display a description of a command you created by issuing help [COMMAND_NAME], where [COMMAND_NAME] is the name of your command.

The procedure uses examples that demonstrate assigning a generic type command to a specific node type on a standalone server.

You can also assign a generic type command to a specific node type in a managed domain. You must add a profile to each command. The following examples sets default as the profile.

[domain@localhost:9999 /] data-source --profile=default --jndi-name=myds --min-pool-size=11 --max-pool-size=22

Procedure

  1. Append the --node-type argument to the command command. The following example specifies /subsystem=datasources/data-source as the node type, with data-source specified as the generic type command:

     [standalone@localhost:9999 /] command add --node-type=/subsystem=datasources/data-source --command-name=data-source
  2. Identify the target child node of a specified node type by completing one of the following methods:

    1. Specify a read-only property of the child node as an identifying property. The following example calls the flush-all-connection-in-pool operation in the myds resource. This resource is identified by the jndi-name property.

      [standalone@localhost:9999 /] data-source flush-all-connection-in-pool --jndi-name=myds
    2. Specify a value for the child node with the --name argument. The following example calls the flush-all-connection-in-pool operation in the myds resource. This resource is identified by the --name property.

      [standalone@localhost:9999 /] data-source flush-all-connection-in-pool --name=myds
  3. Use the add argument to add a new resource. Added properties are prefixed with --. The following example shows new-ds as the new resource with --driver-name, --connection-url, and --pool-name properties defined for the resource:

    [standalone@localhost:9999 /] data-source add --jndi-name=my-new-ds --driver-name=h2 \ --connection-url=db:url --pool-name=my-ds-pool

    You can now edit writable properties by identifying a resource with the --jndi-name command. The following example displays myds as the identified resource, with the writable properties of min-pool-size and max-pool-size modified.

    [standalone@localhost:9999 /] data-source --jndi-name=myds --min-pool-size=11 --max-pool-size=22

11.46. Assigning a generic type command to a child node

You can assign a generic type command to an existing child node by using the --node-child argument. You can use the generic type command to edit properties or call the operations of a child node in the management model.

The --node-child argument is available both on standalone servers and on servers in a managed domain. After you call a command, the server configuration file is updated.

The procedure uses examples that demonstrate assigning a generic type command to a child node on a standalone server.

You can also assign a generic type command to a child node in a managed domain. You must add a profile to each command. The following examples sets default as the profile.

[domain@localhost:9999 /] authorization --profile=default --provider=rbac --permission-combination-policy=permissive --use-identity-roles=false
Note

If you need to add the child node to the management model, you must specify the child node with the generic type command applied to a node type.

Procedure

  1. Append the --node-child argument to the command command. The following example shows /core-service=management/access=authorization as the child node, with authorization specified as the generic type command:

     [standalone@localhost:9999 /] command add --node-child=/core-service=management/access=authorization --command-name=authorization

    You can now write properties to an existing resource. The following example demonstrates writing properties to existing resources in the authorization child node .

    [standalone@localhost:9999 /] authorization --provider=rbac --permission-combination-policy=permissive --use-identity-roles=false

    Additionally, you can send operations to the existing resource in the authorization child node. The following example sends the read-attribute operation to retrieve a value from the provider property.

    [standalone@localhost:9999 /] authorization read-attribute --name=provider