Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

Chapter 10. 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 or other JBoss EAP guide.

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.

10.1. Add a Datasource

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

10.2. Add an Extension

Example: Add a New Extension to a Configuration

/extension=EXTENSION_NAME:add

10.3. Add a JMS Queue

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

10.4. Add a JMS Topic

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

10.5. Add a Module

module add --name=MODULE_NAME --resources=PATH_TO_RESOURCE --dependencies=DEPENDENCIES
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.

10.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)

10.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)

10.8. Add a System Property

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

10.9. Clone a Profile

Example: Clone a Profile in a Managed Domain

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

10.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])

10.11. Deploy an Application to a Managed Domain

Example: Deploy an Application to All Server Groups

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

Example: Deploy an Application to One or More Server Groups

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

10.12. Deploy an Application to a Standalone Server

deploy /path/to/DEPLOYMENT.war

10.13. Disable All Applications

undeploy * --keep-content

Use a wildcard (*) for the deployment name.

10.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"
    }}
}

10.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 form 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 f61a27c4-c5a7-43ac-af1f-29e90c9acb3e:
2017-08-14 15:20:01,472 INFO  [org.jboss.modules] (main) JBoss Modules version 1.6.0.CR2-redhat-1
2017-08-14 15:20:01,721 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.7.SP1-redhat-1
2017-08-14 15:20:01,853 INFO  [org.jboss.as] (MSC service thread 1-8) WFLYSRV0049: JBoss EAP 7.1.0.GA (WildFly Core 3.0.0.Beta30-redhat-1) starting
...

10.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
...

10.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" => "7.1.0.GA",
        "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

10.18. 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.

10.19. Redeploy All Disabled Deployments

deploy --name=*

Use a wildcard (*) for the deployment name.

10.20. Reload a Host Controller

reload --host=HOST_NAME

10.21. Reload a Host Controller in Admin-only Mode

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

10.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.

10.23. Reload a Server

Example: Reload a Server in a Managed Domain

/host=HOST_NAME/server-config=SERVER_NAME:reload

Note

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

10.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.

10.25. Remove an Extension

Example: Remove an Existing Extension

/extension=EXTENSION_NAME:remove

10.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.

10.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.

10.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.

10.29. Restart a Server

Example: Restart a Server in a Managed Domain

/host=HOST_NAME/server-config=SERVER_NAME:restart

Note

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

10.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.

10.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.

10.32. Shut Down a Host Controller

Example: Shut Down a Host Controller in a Managed Domain

shutdown --host=HOST_NAME

10.33. Shut Down the Server

Example: Shut Down a Standalone Server

shutdown

10.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.

10.35. Start a Server

Example: Start a Server in a Managed Domain

/host=HOST_NAME/server-config=SERVER_NAME:start

Note

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

10.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

10.37. Stop a Server

Example: Stop a Server in a Managed Domain

/host=HOST_NAME/server-config=SERVER_NAME:stop

10.38. Take a Configuration Snapshot

Example: Take a Snapshot of the Current Configurations

:take-snapshot

10.39. Undeploy All Applications

undeploy *

Use a wildcard (*) for the deployment name.

10.40. Undeploy an Application from a Managed Domain

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

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

Example: Undeploy an Application from a Specific Server Group

undeploy DEPLOYMENT.war --server-groups=SERVER_GROUP_NAME --keep-content

The --keep-content parameter is required in order to keep the content in the repository for other server groups with that deployment.

10.41. Undeploy an Application from a Standalone Server

undeploy DEPLOYMENT.war

10.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.

10.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.

10.44. View a Server Log

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