Wildfly - 如何在Windows上以域模式安装

时间:2015-11-10 14:46:59

标签: java jboss configuration windows-services wildfly

我设法在域名模式下在Wildfly上运行Ubuntu,但我在Windows遇到了麻烦。这是我的设置和步骤:

  1. 我有两台Windows服务器(例如,S1S2),Wildfly将以Windows service
  2. 运行
  3. 我有domain.xmlhost-master.xmlhost-slave.xml个文件。在Linux上,我更新/etc/default/wildfly文件以告诉S1服务器它将成为master而S2将成为slave。主配置和从属配置位于host-master.xmlhost-slave.xml个文件中。所以基本上,我告诉S1使用host-master和S2 to host-slave。如果我添加S3服务器,我告诉它使用具有适当配置的主机 - 从服务器。
  4. 在Linux上,在告诉Wildfly使用哪个xml文件之后,我将它们安装为Linux服务。这就是我想在Windows上做的事情
  5. 我cd到wildfly\bin\service目录
  6. 这是我用于主人的代码:service install /controller S1:9990 /host master /user user /password pass
  7. 这是针对奴隶:service install /controller S1:9990 /host slave /user user /password pass
  8. 但是你可以猜到,虽然我可以登录管理控制台,但我看不到奴隶。只有主人在场。此外,当我尝试在S2上登录管理控制台时,我仍然可以看到具有主配置的控制台。

    我肯定错过了一些东西,但我不知道它是什么。你能帮忙吗?

    我的host-master.xml文件:

    <?xml version='1.0' encoding='UTF-8'?>
    
    <host name="S1" xmlns="urn:jboss:domain:3.0">
    
        <extensions>
            <extension module="org.jboss.as.jmx"/>
        </extensions>
        <management>
            <security-realms>
                <security-realm name="ManagementRealm">
                    <authentication>
                        <local default-user="$local" skip-group-loading="true"/>
                        <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/>
                    </authentication>
                    <authorization map-groups-to-roles="false">
                        <properties path="mgmt-groups.properties" relative-to="jboss.domain.config.dir"/>
                    </authorization>
                </security-realm>
                <security-realm name="ApplicationRealm">
                    <authentication>
                        <local default-user="$local" allowed-users="*" skip-group-loading="true"/>
                        <properties path="application-users.properties" relative-to="jboss.domain.config.dir"/>
                    </authentication>
                    <authorization>
                        <properties path="application-roles.properties" relative-to="jboss.domain.config.dir"/>
                    </authorization>
                </security-realm>
            </security-realms>
            <audit-log>
                <formatters>
                    <json-formatter name="json-formatter"/>
                </formatters>
                <handlers>
                    <file-handler name="host-file" formatter="json-formatter" path="audit-log.log" relative-to="jboss.domain.data.dir"/>
                    <file-handler name="server-file" formatter="json-formatter" path="audit-log.log" relative-to="jboss.server.data.dir"/>
                </handlers>
                <logger log-boot="true" log-read-only="false" enabled="false">
                    <handlers>
                        <handler name="host-file"/>
                    </handlers>
                </logger>
                <server-logger log-boot="true" log-read-only="false" enabled="false">
                    <handlers>
                        <handler name="server-file"/>
                    </handlers>
                </server-logger>
            </audit-log>
            <management-interfaces>
                <native-interface security-realm="ManagementRealm">
                    <socket interface="management" port="${jboss.management.native.port:9999}"/>
                </native-interface>
                <http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
                    <socket interface="management" port="${jboss.management.http.port:9990}"/>
                </http-interface>
            </management-interfaces>
        </management>
    
        <domain-controller>
            <local/>
        </domain-controller>
    
        <interfaces>
            <interface name="management">
                <any-address/>
            </interface>
        </interfaces>
    
        <jvms>
            <jvm name="default">
                <heap size="64m" max-size="256m"/>
                <permgen size="256m" max-size="256m"/>
                <jvm-options>
                    <option value="-server"/>
                </jvm-options>
            </jvm>
        </jvms>
    
        <servers>
            <server name="solr-server" group="solr_server" auto-start="false">
                <socket-bindings socket-binding-group="full-sockets" port-offset="983"/>
            </server>
            <server name="80-8200" group="edys-web-servers" auto-start="false">
                <socket-bindings socket-binding-group="full-sockets" port-offset="199"/>
            </server>
    </servers>
        <profile>
            <subsystem xmlns="urn:jboss:domain:jmx:1.3">
                <expose-resolved-model/>
                <expose-expression-model/>
                <remoting-connector/>
            </subsystem>
        </profile>
    </host>
    

    我的host-slave.xml文件:

    <?xml version='1.0' encoding='UTF-8'?>
    
    <host name="S2" xmlns="urn:jboss:domain:3.0">
    
        <extensions>
            <extension module="org.jboss.as.jmx"/>
        </extensions>
        <management>
            <security-realms>
                <security-realm name="ManagementRealm">
                    <server-identities>
                        <secret value="UGFzc3cwcmQ="/>
                    </server-identities>
                    <authentication>
                        <local default-user="$local" skip-group-loading="true"/>
                        <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/>
                    </authentication>
                    <authorization map-groups-to-roles="false">
                        <properties path="mgmt-groups.properties" relative-to="jboss.domain.config.dir"/>
                    </authorization>
                </security-realm>
                <security-realm name="ApplicationRealm">
                    <authentication>
                        <local default-user="$local" allowed-users="*" skip-group-loading="true"/>
                        <properties path="application-users.properties" relative-to="jboss.domain.config.dir"/>
                    </authentication>
                    <authorization>
                        <properties path="application-roles.properties" relative-to="jboss.domain.config.dir"/>
                    </authorization>
                </security-realm>
            </security-realms>
            <audit-log>
                <formatters>
                    <json-formatter name="json-formatter"/>
                </formatters>
                <handlers>
                    <file-handler name="host-file" formatter="json-formatter" path="audit-log.log" relative-to="jboss.domain.data.dir"/>
                    <file-handler name="server-file" formatter="json-formatter" path="audit-log.log" relative-to="jboss.server.data.dir"/>
                </handlers>
                <logger log-boot="true" log-read-only="false" enabled="false">
                    <handlers>
                        <handler name="host-file"/>
                    </handlers>
                </logger>
                <server-logger log-boot="true" log-read-only="false" enabled="false">
                    <handlers>
                        <handler name="server-file"/>
                    </handlers>
                </server-logger>
            </audit-log>
            <management-interfaces>
                <native-interface security-realm="ManagementRealm">
                    <socket interface="management" port="${jboss.management.native.port:9999}"/>
                </native-interface>
            </management-interfaces>
        </management>
    
        <domain-controller>
            <remote security-realm="ManagementRealm" username="ebys">
                <discovery-options>
                    <static-discovery name="primary" protocol="${jboss.domain.master.protocol:remote}" host="${jboss.domain.master.address:S1}" 
                    port="${jboss.domain.master.port:9999}"/>
                </discovery-options>
            </remote>
        </domain-controller>
    
        <interfaces>
            <interface name="management">
                <inet-address value="${jboss.bind.address.management:S2}"/>
            </interface>
            <interface name="public">
                <inet-address value="${jboss.bind.address:S2}"/>
            </interface>
            <interface name="unsecure">
                <inet-address value="${jboss.bind.address.unsecure:S2}"/>
            </interface>
        </interfaces>
    
        <jvms>
            <jvm name="default">
                <heap size="64m" max-size="256m"/>
                <permgen size="256m" max-size="256m"/>
                <jvm-options>
                    <option value="-server"/>
                </jvm-options>
            </jvm>
        </jvms>
    
        <profile>
            <subsystem xmlns="urn:jboss:domain:jmx:1.3">
                <expose-resolved-model/>
                <expose-expression-model/>
                <remoting-connector/>
            </subsystem>
        </profile>
    </host>
    

    PS:Windows上有一个我无法阻止Wildfly服务的错误。我必须重新启动服务器(服务处于手动模式),然后卸载服务。因此,我不能在不重新启动服务器的情况下卸载和安装服务。报告了一个关于此的错误,但不幸的是这些建议对我没有用。

2 个答案:

答案 0 :(得分:1)

  1. 将WildFly作为服务运行
  2. 在将WildFly作为服务进行评论之前,应该定义一个环境变量:

    JAVA_OPTS=-Djboss.bind.address=<local bind address> -Djboss.bind.address.management=<management bind address> -Djboss.domain.master.address=<address of the domain controller>
    

    <强>注意!!!对于WildFly 10,需要添加额外的变量:jboss.bind.address.private =&lt;群集中服务器的地址&gt;

    Powershell的:

    [Environment]::SetEnvironmentVariable("JAVA_OPTS", "-Djboss.bind.address=<local bind address> -Djboss.bind.address.management=<management bind address> -Djboss.domain.master.address=<address of the domain controller>", "Machine")
    

    最后一个参数“jboss.domain.master.address” - 只需要从属节点。

    Windows服务可以通过里面的脚本安装 &LT; wildfly_home_dir&gt; / bin / service:

    主节点

    service.bat install /host master
    

    从属节点

    service.bat install /controller <domain_conroller_address>:9990 /host <slave_host_name> /user <admin_user_to_domain_controller> /password <admin_password_to_domain_controller>
    

    对于从属节点,需要更改系统注册表项(激活从属模式配置):

    注册表编辑器

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\Wildfly\Parameters\Start
    Params:REG_MULTI_SZ
    /c "set NOPAUSE=Y && domain.bat --host-config=host-slave.xml"
    
    1. 定义管理的安全凭据
    2. 在域控制器节点上为从属节点添加新用户(可以是所有节点的一个用户)。交互式命令行脚本 - add_user [.bat]。

      完成后 - 它将在控制台上打印带有密码的XML标签(&lt;秘密值...)。应将其复制并插入从属节点上的host-slave.xml文件中(用户名应作为属性“username”添加到标记host / domain-controller / remote:

      主机slave.xml

      <host xmlns="urn:jboss:domain:3.0" name="slave">
          <management>
              <security-realms>
                  <security-realm name="ManagementRealm">
                      <server-identities>
                          <secret value="MQ=="/>
                      </server-identities>
                  </security-realm>
              </security-realms>
          </management>
          <domain-controller>
              <remote security-realm="ManagementRealm" username="slave">
                  <discovery-options>
                      <static-discovery name="primary" protocol="${jboss.domain.master.protocol:remote}" host="${jboss.domain.master.address}" port="${jboss.domain.master.port:9999}"/>
                  </discovery-options>
              </remote>
          </domain-controller>
      </host>
      
      1. 启动主节点
      2. 配置HornetMQ / ActiveMQ群集密码
      3. 的JBoss-CLI

        /profile=full-ha/subsystem=messaging/hornetq-server=default:write-attribute(name=cluster-password,value="${jboss.messaging.cluster.password:CHANGE ME!!}")
        

        另一种方法是为全ha配置中的所有WildFly节点定义系统环境变量:jboss.messaging.cluster.password(可以在启动域控制器后在管理UI界面中完成)。

        5.启动从属节点

答案 1 :(得分:0)

我建议您使用https://github.com/tfonteyn/jboss7service.bat EAP6 / AS7 / WildFly8 +的服务脚本,因为它也支持域模式。

您需要单独使用的是apache prunsrv.exe,您可以从中获取:http://commons.apache.org/proper/commons-daemon/binaries.html

我建议您阅读service.bat中的评论,以了解哪些选项以及如何使用它。