Wildfly8 domain模式搭建

1.wildfly下载

http://wildfly.org/downloads/

2.domain方式搭建集群

ps:基于8.2.0.Final做测试

2.0机器列表

192.168.236.101 (master+domain controller)

192.168.236.102(slave)

2.1新增用户名

新增仅需在master机器上完成;

2.1.1.解压:tar-zxvf wildfly-8.2.0.Final.tar.gz  

2.1.2 重命名:mv wildfly-8.2.0.Final wildfly8

2.1.2 增加用户 ./wildfly8/bin/add-user.sh

新增管理员用户 a) Management User (mgmt-users.properties) 

最后记录下该用户名的加密密码:(引号内容)用于后面的配置

To represent the user add the following to the server-identities definition <secret value="c2FsdmU=" />

3.master配置

所在目录:/usr/local/wildfly8/domain/configuration/

host.xml配置(注意与slave的host.xml作对比)

<?xml version='1.0' encoding='UTF-8'?>

<host name="master" xmlns="urn:jboss:domain:2.2">

    <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.domai
n.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" relative-to=
"jboss.domain.data.dir" path="audit-log.log"/>
                <file-handler name="server-file" formatter="json-formatter" relative-t
o="jboss.server.data.dir" path="audit-log.log"/>
            </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:99
99}"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm" http-upgrade-enabled="tru
e">
                <socket interface="management" port="${jboss.management.http.port:9990
}"/>
            </http-interface>
        </management-interfaces>
    </management>

    <domain-controller>
       <local/>
    </domain-controller>

    <interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:192.168.236.101}"/>
        </interface>
        <interface name="public">
           <inet-address value="${jboss.bind.address:192.168.236.101}"/>
        </interface>
        <interface name="unsecure">
            <!-- Used for IIOP sockets in the standard configuration.
                 To secure JacORB you need to setup SSL -->
            <inet-address value="${jboss.bind.address.unsecure:192.168.236.101}"/>
        </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="server-one" group="main-server-group">
        </server>
    </servers>
</host>

4.slave配置

将slave机器下 /usr/local/wildfly8/domain/configuration/domain.xml重命名,既slave不需要该文件

#mv domain.xml domain.xml_back

然后就是修改host.xml配置文件

host.xml

<?xml version='1.0' encoding='UTF-8'?>

<host name="slave" xmlns="urn:jboss:domain:2.2">

    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <server-identities>
                     #前面master增加的用户加密密码
                     <secret value="YWRtaW4="/>
                </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-lo
ading="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" relati
ve-to="jboss.domain.data.dir" path="audit-log.log"/>
                <file-handler name="server-file" formatter="json-formatter" rela
tive-to="jboss.server.data.dir" path="audit-log.log"/>
            </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.p
ort:9999}"/>
            </native-interface>
        </management-interfaces>
    </management>

    <domain-controller>
        # master主机地址 和前面新增的用户名
       <remote host="192.168.236.101" port="9999" security-realm="ManagementReal
m" username="admin"/>
    </domain-controller>

    <interfaces>
        <interface name="management">
            #本机地址
            <inet-address value="${jboss.bind.address.management:192.168.236.102
}"/>
        </interface>
        <interface name="public">
           <inet-address value="${jboss.bind.address:192.168.236.102}"/>
        </interface>
        <interface name="unsecure">
            <inet-address value="${jboss.bind.address.unsecure:192.168.236.102}"
/>
        </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="server-one" group="main-server-group"/>
    </servers>
</host>

5.将wildfly配置系统服务

新增配置文件(master与slave都需要以下配置)
vi /etc/default/wildfly.conf
文件内容
## JDK目录
JAVA_HOME="/usr/local/jdk"

## JBOSS_HOME是Wildfly的安装根目录
JBOSS_HOME="/usr/local/wildfly8"

## 这里需要改为执行wildfly的用户
JBOSS_USER=root

## 指定运行模式为domain
JBOSS_MODE=domain

## 指定domain的配置文件为domain.xml,slave的配置文件为host.xml
JBOSS_DOMAIN_CONFIG=domain.xml
JBOSS_HOST_CONFIG=host.xml

设置为系统服务
##将.sh启动命令放到系统目录下
cp wildfly8/bin/init.d/wildfly-init-redhat.sh /etc/init.d/wildfly
##增加执行权限
chmod +x /etc/init.d/wildfly
##增加系统服务
chkconfig --add wildfly
##设置开机启动
chkconfig wildfly on
##启动wildfly,记得先启动master,再启动salve
service wildfly start

6.验证
访问master的地址:http://192.168.236.101:9990/console/App.html#host-vm
查看活跃的主机:


更多精彩内容请继续关注我的博客http://blog.csdn.net/caicongyang

记录与分享,你我共成长 -from  caicongyang

如果你觉得本文对你有帮助,可以扫描下面的微信二维码,请我喝杯水咯!







评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值