Configuration JBoss AS 7通过cli更新系统属性

Configuration JBoss AS 7通过cli更新系统属性,configuration,jboss7.x,Configuration,Jboss7.x,我可以通过以下方式通过CLI界面读取系统属性: /system property=propertyname:read属性(name=“value”) 是否有一种简单的方法可以通过CLI界面更新属性?您可以使用写入属性操作更改系统属性值 /system-property=propertyname:write-attribute(name="value", value="newValue") 有关更好的描述,请参见答案。您可以使用写入属性操作 [domain@localhost:9999 /] /

我可以通过以下方式通过CLI界面读取系统属性:

/system property=propertyname:read属性(name=“value”)


是否有一种简单的方法可以通过CLI界面更新属性?

您可以使用
写入属性操作更改系统属性值

/system-property=propertyname:write-attribute(name="value", value="newValue")

有关更好的描述,请参见答案。

您可以使用
写入属性操作

[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-resource-description 
{
    "outcome" => "success",
    "result" => {
        "description" => "A system property to set on all servers in the domain.",
        "head-comment-allowed" => true,
        "tail-comment-allowed" => false,
        "attributes" => {
            "value" => {
                "type" => STRING,
                "description" => "The value of the system property.",
                "required" => false,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            },
            "boot-time" => {
                "type" => BOOLEAN,
                "description" => "If true the system property is passed on the command-line to the started server jvm. If false, it will be pushed to the server as part of the startup sequence.",
                "required" => false,
                "default" => true,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            }
        }
    }
}
管理CLI的健康工作流是公开、读取和写入资源属性。为了给出此工作流的示例,我们将在JBoss Application Server 7.1.0Beta1的新默认安装上执行以下步骤

识别和写入系统资源属性的步骤
  • 读取所有系统属性
  • 更详细地阅读特定的系统属性
  • 公开一个示例系统属性
  • 编写一个示例系统属性
  • 公开更改以确认它
  • 将属性重置回原始值
  • 1.读取所有系统属性 我们并不总是知道我们要找的东西的确切名称。我们可以混合使用制表符补全和通配符搜索,以便于公开资源和属性。
    读取资源
    操作是任何工作流的良好开端,因为它公开了所有现有实体

    [domain@localhost:9999 /] /system-property=*:read-resource
    {
        "outcome" => "success",
        "result" => [{
            "address" => [("system-property" => "java.net.preferIPv4Stack")],
            "outcome" => "success",
            "result" => {
                "boot-time" => true,
                "value" => "true"
            }
        }]
    }
    
    2.更详细地阅读特定的系统属性
    read resource
    操作公开了
    java.net.preferIPv4Stack
    属性。我们可以使用
    readresourcesdescription
    操作进一步查询此信息

    [domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-resource-description 
    {
        "outcome" => "success",
        "result" => {
            "description" => "A system property to set on all servers in the domain.",
            "head-comment-allowed" => true,
            "tail-comment-allowed" => false,
            "attributes" => {
                "value" => {
                    "type" => STRING,
                    "description" => "The value of the system property.",
                    "required" => false,
                    "access-type" => "read-write",
                    "storage" => "configuration",
                    "restart-required" => "no-services"
                },
                "boot-time" => {
                    "type" => BOOLEAN,
                    "description" => "If true the system property is passed on the command-line to the started server jvm. If false, it will be pushed to the server as part of the startup sequence.",
                    "required" => false,
                    "default" => true,
                    "access-type" => "read-write",
                    "storage" => "configuration",
                    "restart-required" => "no-services"
                }
            }
        }
    }
    
    3.公开一个示例系统属性
    read resource description
    操作打印有关资源的信息,包括其属性。我们可以使用
    读取属性
    操作专门查询这些属性。同样,tab completion可以在您开始键入时轻松地组合这些操作字符串,并点击tab完成字符串或建议可用的添加

    [domain@localhost:9999/]/system property=java.net.preferIPv4Stack:read属性(name=boot time)
    { “结果”=>“成功”, “结果”=>true }

    4.编写一个示例系统属性 就像我们刚才查询属性一样,我们可以更改它。在这种情况下,我们可以使用
    写入属性
    操作,记住
    读取资源描述
    操作报告的预期值类型。此操作将属性声明为布尔值,但您只需查看
    read attribute
    命令(定义属性的位置)中的现有值即可解决此问题

    5.公开更改以确认它 我们可以再次运行
    read属性
    操作来显示值的更改

    [domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-attribute(name=boot-time)              
    {
        "outcome" => "success",
        "result" => false
    }
    
    6.将属性重置回原始值 为了优雅地结束这个示例,让我们将该值更改回原始状态

    [domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:write-attribute(name=boot-time, value=true) 
    {
        "outcome" => "success",
        "result" => {
            "domain-results" => {"step-1" => undefined},
            "server-operations" => undefined
        }
    }
    
    总结
    是的,您可以写入属性值。为了简化流程,一个公开属性值和文件类型定义的工作流习惯是一个很好的实践,应该使流程更清晰

    为了完整起见,下面介绍如何删除(取消定义)属性属性:

    /system-property=propertyname:undefine-attribute(name=attribute-name)
    

    无需功能请求,因为写入属性操作可以按照名称更新这些属性。是否可以创建/覆盖属性?如果我添加一个存在的属性,我会收到一个错误,如果我写入一个不存在的属性,我会提示另一个错误。您必须使用CLI batch命令,然后执行batch。无法在单个命令中更新多个属性。是否需要重新启动服务器以反映此新值?取决于该值的使用方式。如果您在部署过程中或在某种类型的单例中需要它,可以。谢谢您的回答,它对我帮助很大。我是否需要运行另一个命令才能使更改生效?我可以更改该值,但jboss似乎没有识别出该更改。