目前分類:JBoss (13)

瀏覽方式: 標題列表 簡短摘要

在 Tomcat 的 server.xml 裡設定

<Context docBase="weixin" path="/weixin" reloadable="true" source="org.eclipse.jst.jee.server:weixin">
        <Resource name="jdbc/mysqlLocalDS01" username="root" password="password" url="jdbc:mysql://localhost:3306?characterEncoding=utf-8" auth="Container" driverClassName="com.mysql.cj.jdbc.Driver" factory="org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory" maxIdle="10" maxTotal="20" maxWaitMillis="-1" type="javax.sql.DataSource" />      
        <Resource name="jdbc/JappsDS01" username="ap" password="password" url="jdbc:oracle:thin:@127.0.0.1:1521:xe" driverClassName="oracle.jdbc.driver.OracleDriver" maxIdle="2" maxTotal="4" maxWaitMillis="5000"  type="javax.sql.DataSource" validationQuery="select 1 from dual"/>
    <Resources>
       <PreResources base="C://CKFinderJava//userfiles" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/userfiles"/>
   </Resources>
</Context>

在 JBoss EAP 6.x 上, 需建一個檔案: WEB-INF\jboss-web.xml

<jboss-web version="7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jboss="http://www.jboss.com/xml/ns/javaee"  
               xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee jboss-web_7_0.xsd">  
        <symbolic-linking-enabled>true</symbolic-linking-enabled>    
        <overlay>C:/CKFinderJava/userfiles</overlay>
 
</jboss-web>

就可以用下列的連結來看檔案。

PS: mis 是目前的專案,而 images/S_13164601.jpgC:/CKFinderJava/userfiles 下的目錄及檔案

http://localhost:8080/mis/images/S_13164601.jpg

 

REF: https://developer.jboss.org/thread/266445

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

在wildfly的standalone.xml內中
約在83行左右,確認該行<subsystem xmlns="urn:jboss:domain:logging:2.0">下是否有加入
     <use-deployment-logging-config value="false"/>
 
EAP的設定大致相同,但加入的參數不同,約在88行左右
  <subsystem xmlns="urn:jboss:domain:logging:1.5">在之下,加入
   <add-logging-api-dependencies value="false"/>

以上設定,表單即不會因多次開啟而造成死當。
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/pdf/Migration_Guide/JBoss_Enterprise_Application_Platform-6.4-Migration_Guide-en-US.pdf     第17頁中表示因要排除第三方(log4j)的依賴性,所以要設成false,不然會有問題,不過不曉得跟死當有什麼直接關係,
但是補上該設定,系統是可以working的。
不過還滿好奇的是wildfly的console仍會秀出,但EAP的console始終沒有秀出我們的consoel。持續查找中。

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

為了讓 WEB APP 不因一台主機當機而影響作業,開始架構二台 JBOSS 主機,並利用 JBOSS plug in 在 Apache 的 mod_cluster-1.2.6 來作 Load Balancer

版本:

JDK:jdk-8u45-linux-x64.rpm

JBOSS EAP 6.4

Apache & mod_cluster 1.2.6.Final : http://downloads.jboss.org/mod_cluster//1.2.6.Final/linux-i686/mod_cluster-1.2.6.Final-src-ssl.tar.gz

環境:

domain Master :192.168.30.100

domain Slave:192.168.30.101

EAPDomainCluster  

一、開始安裝 JDK

Step 01: 移除 OpenJDK

[root@localhost ~]# rpm -qa | grep java
[root@localhost ~]# yum remove java*

 

Step 02:安裝 JDK

[root@localhost tmp]# rpm -ivh jdk-8u45-linux-x64.rpm

[root@bm tmp]# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

[root@bm tmp]# javac -version
javac 1.8.0_45

 

Step 03:編輯「/etc/profile」檔案,在最後加入

export JAVA_HOME=/usr/java/jdk1.8.0_45
export JRE_HOME=/usr/java/jdk1.8.0_45/jre
export ANT_HOME=/opt/apache-ant-1.7.0
export JBOSS_HOME=/opt/jboss-eap-6.4
export APACHE_HOME=/opt/jboss/httpd

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH:$ANT_HOME/bin
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JRE_HOME/lib

 

二、開始安裝 JBoss EAP 6.4

Step 01:上傳 jboss-eap-6.4.0.zip 並解壓於 /opt 下

[root@bm tmp]# unzip jboss-eap-6.4.0.zip
[root@bm tmp]# mv jboss-eap-6.4 /opt

 

Step 02:重開主機,並啟動 JBOSS Domain Mode 作測試( Master 與 Slave 作同樣的動作)

[root@bm tmp]# $JBOSS_HOME/bin/domain.sh

 

三、開始作 Domain Configuration 設定

 ■ Interface config on master(192.168.30.100)

 

Step 01:修改 vi domain/configuration/host.xml
初始值如下:

<interfaces>
    <interface name="management">
        <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
    </interface>
    <interface name="public">
       <inet-address value="${jboss.bind.address:127.0.0.1}"/>
    </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:127.0.0.1}"/>
    </interface>
</interfaces>

變更如下

<interfaces>
    <interface name="management">
        <inet-address value="${jboss.bind.address.management:192.168.30.100}"/>
    </interface>
    <interface name="public">
       <inet-address value="${jboss.bind.address:192.168.30.100}"/>
    </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.30.100}"/>
    </interface>
</interfaces>

 

Step02:建立 Domain Mode 主機間溝通用專用的帳號:domainAdmin,並取得 secret key
增加管理帳號:domainAdmin
密碼:password

[root@localhost bin]# ./add-user.sh

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a):
Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : domainAdmin
Password requirements are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password must not be one of the following restricted values {root, admin, administrator}
 - The password must contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
 - The password must be different from the username
Password : password
Re-enter Password : password
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]:
About to add user 'domainMaster' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'domainMaster' to file '/opt/jboss-eap-6.3/standalone/configuration/mgmt-users.properties'
Added user 'domainMaster' to file '/opt/jboss-eap-6.3/domain/configuration/mgmt-users.properties'
Added user 'domainMaster' with groups  to file '/opt/jboss-eap-6.3/standalone/configuration/mgmt-groups.properties'
Added user 'domainMaster' with groups  to file '/opt/jboss-eap-6.3/domain/configuration/mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret value="SkJvc3NFQVA2LjM=" />

 

Interface config on slave(192.168.30.101)

Step 01:修改 vi domain/configuration/host.xml 相關的值如下

<?xml version='1.0' encoding='UTF-8'?>
<host name="slave" xmlns="urn:jboss:domain:1.6">
    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                    <server-identities>
                       <secret value="SkJvc3NFQVA2LjM=" />
                    </server-identities>
                    <authentication>
                        <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" relative-to="jboss.domain.data.dir" path="audit-log.log"/>
                <file-handler name="server-file" formatter="json-formatter" relative-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.port:9999}"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.http.port:9990}"/>
            </http-interface>
        </management-interfaces>
    </management>

    <domain-controller>
       <remote host="192.168.30.100" port="9999" security-realm="ManagementRealm" username="domainAdmin" />
       <!-- Alternative remote domain controller configuration with a host and port -->
       <!-- <remote host="${jboss.domain.master.address}" port="${jboss.domain.master.port:9999}" security-realm="ManagementRealm"/> -->
    </domain-controller>
    <interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:192.168.30.101}"/>
        </interface>
        <interface name="public">
           <inet-address value="${jboss.bind.address:192.168.30.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.30.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="slave-one" group="other-server-group">
            <!-- Remote JPDA debugging for a specific server
            <jvm name="default">
              <jvm-options>
                <option value="-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"/>
              </jvm-options>
           </jvm>
           -->
        </server>
        <server name="slave-two" group="other-server-group" auto-start="true">
            <!-- server-two avoids port conflicts by incrementing the ports in
                 the default socket-group declared in the server-group -->
            <socket-bindings port-offset="150"/>
        </server>
        <server name="slave-three" group="other-server-group" auto-start="false">
            <!-- server-three avoids port conflicts by incrementing the ports in
                 the default socket-group declared in the server-group -->
            <socket-bindings port-offset="250"/>
        </server>
    </servers>
</host>

 

Step 02:Domain Mode 是聽從 Master 主機,所以將 Slave 的 domain.xml 更名為 domain.xml.move

mv $JBOSS_HOME/domain/configuration/domain.xml $JBOSS_HOME/domain/configuration/domain.xml.move

 

四、Cluster Configuration 使用 mod_cluster 1.2.6.Final

Step 01: 安裝 apache,到 http://mod-cluster.jboss.org/downloads 下載 mod_cluster-1.2.6.Final-linux2-x64-ssl.tar.gz
將 mod_cluster-1.2.6.Final-linux2-x64-ssl.tar.gz 上載到Server後解壓

[root@eap-master tmp]# tar -xzvf mod_cluster-1.2.6.Final-linux2-x64-ssl.tar.gz
[root@eap-master tmp]# cp –rp /tmp/opt/jboss /opt

 

Step 02:  分別修改 192.168.30.100 & 192.168.30.101 Apache 的 httpd.conf

修改 Master(192.168.30.100) 的 mod_cluster:vi $APACHE_HOME/httpd/conf/httpd.conf

ServerName eap-master.globeunion.com:80

<VirtualHost 192.168.30.100:80>
  <Directory />
    Order deny,allow
    Deny from all
    Allow from all
  </Directory>
  <Location /cluster_manager>
    SetHandler mod_cluster-manager
    Order deny,allow
    Deny from all
    Allow from all
  </Location>
</VirtualHost>

Listen 192.168.30.100:6666
#ManagerBalancerName mycluster   
ManagerBalancerName other-server-group
<VirtualHost 192.168.30.100:6666>
  <Directory />
    Order deny,allow
      Deny from all
      Allow from all
  </Directory>
  ServerAdvertise on http://192.168.30.100:6666
  EnableMCPMReceive
</VirtualHost>

 

修改 Slave(192.168.30.101) 的 mod_cluster:vi $APACHE_HOME/httpd/conf/httpd.conf

ServerName eap-slave.globeunion.com:80

# MOD_CLUSTER_ADDS
# Adjust to you hostname and subnet.
<IfModule manager_module>
    <VirtualHost 192.168.30.101:80>
      <Directory />
        Order deny,allow
        Deny from all
        Allow from all
      </Directory>
      <Location /cluster_manager>
        SetHandler mod_cluster-manager
        Order deny,allow
        Deny from all
        Allow from all
      </Location>
    </VirtualHost>

    Listen 192.168.30.101:6666
    #ManagerBalancerName mycluster   
    ManagerBalancerName other-server-group
    <VirtualHost 192.168.30.101:6666>
      <Directory />
        Order deny,allow
          Deny from all
          Allow from all
      </Directory>
      ServerAdvertise on http:// 192.168.30.101:6666
      EnableMCPMReceive
    </VirtualHost>
</IfModule>

 

Step 03:修改192.168.30.100-Master 的 domain.xml 裡的 profile name="full-ha":

vi domain/configuration/domain.xml 相關的值如下

<profile name="full-ha">
<subsystem xmlns="urn:jboss:domain:messaging:1.4">
    <hornetq-server>
        <cluster-user>domainAdmin</cluster-user>
        <cluster-password>password</cluster-password>
        <persistence-enabled>true</persistence-enabled>
        <journal-type>NIO</journal-type>
        <journal-min-files>2</journal-min-files>
        <connectors>
            <netty-connector name="netty" socket-binding="messaging"/>
            <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                <param key="batch-delay" value="50"/>
            </netty-connector>
            <in-vm-connector name="in-vm" server-id="0"/>
        </connectors>
 
    </hornetq-server>
</subsystem>
<subsystem xmlns="urn:jboss:domain:modcluster:1.2">
    <mod-cluster-config advertise-socket="modcluster" connector="ajp" proxy-list="192.168.30.100:6666,192.168.30.101:6666" balancer="mycluster">
        <dynamic-load-provider>
            <load-metric type="busyness"/>
        </dynamic-load-provider>
    </mod-cluster-config>
</subsystem>
<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false" instance-id="${jboss.node.name}">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
    <virtual-server name="default-host" enable-welcome-root="true">
        <alias name="localhost"/>
        <alias name="example.com"/>
    </virtual-server>
</subsystem>
</profile>

 

五、關閉防火牆

[root@bm bin]# systemctl list-unit-files | grep fire

firewalld.service enabled

[root@bm bin]# systemctl disable firewalld.service

 

六、相關服務手動啟動

#Apache Server Start/Stop

$APACHE_HOME/sbin/apachectl start/stop/status

#JBOSS EAP Server Start

$JBOSS_HOME/bin/domain.sh

#JBOSS EAP Domain 管理介面

http://192.168.30.100:9990/console

 

 

七、將 Apache Server 設定成 Service

Step 01:copy apachectl 到 /etc/init.d

[root@eap-master init.d]# cp /opt/jboss/httpd/sbin/apachectl /etc/init.d

 

Step 02: 修改 /etc/init.d/apachectl

#!/bin/sh

在第二行加入以下兩句:

# chkconfig: 2345 80 90
# description:auto_run

第一行,告訴系統使用的shell,所以的shell腳本都是這樣。
第二行,chkconfig後面有三個參數2345,80和90告 訴chkconfig程式,需要在rc2.d~rc5.d目錄下,創建名字為 S80auto_run的檔連接,連接到/etc/rc.d/init.d目錄下的的auto_run腳本。第一個字元是S,系統在啟動的時候,運行腳 本auto_run,就會添加一個start參數,告訴腳本,現在是啟動模式。同時在rc0.d和rc6.d目錄下,創建名字為K90auto_run的 檔連接,第一個字元為K,個系統在關閉系統的時候,會運行auto_run,添加一個stop,告訴腳本,現在是關閉模式。
注意上面的三行是中,第二、三行是必須的,否則在運行chkconfig --add auto_run時,會報錯。

完整如下:

#!/bin/sh
# chkconfig: 2345 80 90
# description:auto_run
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Apache control script designed to allow an easy command line interface
# to controlling Apache.  Written by Marc Slemko, 1997/08/23
#
# The exit codes returned are:
#   XXX this doc is no longer correct now that the interesting
#   XXX functions are handled by httpd
#    0 - operation completed successfully
#    1 -
#    2 - usage error
#    3 - httpd could not be started
#    4 - httpd could not be stopped
#    5 - httpd could not be started during a restart
#    6 - httpd could not be restarted during a restart
#    7 - httpd could not be restarted during a graceful restart
#    8 - configuration syntax error
#
# When multiple arguments are given, only the error from the _last_
# one is reported.  Run "apachectl help" for usage info
#
ARGV="$@"
#
# |||||||||||||||||||| START CONFIGURATION SECTION  ||||||||||||||||||||
# --------------------                              --------------------
#
# the path to your httpd binary, including options if necessary
HTTPD='/opt/jboss/httpd/sbin/httpd'
#
# pick up any necessary environment variables
if test -f /opt/jboss/httpd/sbin/envvars; then
  . /opt/jboss/httpd/sbin/envvars
fi
#
# a command that outputs a formatted text version of the HTML at the
# url given on the command line.  Designed for lynx, however other
# programs may work.  
LYNX="lynx -dump"
#
# the URL to your server's mod_status status page.  If you do not
# have one, then status and fullstatus will not work.
STATUSURL="http://localhost:80/server-status"
#
# Set this variable to a command that increases the maximum
# number of file descriptors allowed per child process. This is
# critical for configurations that use many file descriptors,
# such as mass vhosting, or a multithreaded server.
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
# --------------------                              --------------------
# ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||

# Set the maximum number of file descriptors allowed per child process.
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
    $ULIMIT_MAX_FILES
fi

ERROR=0
if [ "x$ARGV" = "x" ] ; then
    ARGV="-h"
fi

case $ARGV in
start|stop|restart|graceful|graceful-stop)
    $HTTPD -k $ARGV
    ERROR=$?
    ;;
startssl|sslstart|start-SSL)
    echo The startssl option is no longer supported.
    echo Please edit httpd.conf to include the SSL configuration settings
    echo and then use "apachectl start".
    ERROR=2
    ;;
configtest)
    $HTTPD -t
    ERROR=$?
    ;;
status)
    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
    ;;
fullstatus)
    $LYNX $STATUSURL
    ;;
*)
    $HTTPD $ARGV
    ERROR=$?
esac

exit $ERROR

 

Step 03: 強制設成 Service

[root@eap-master init.d]# chkconfig --add apachectl

[root@eap-master init.d]# chkconfig --list apachectl

這樣 apache 除了會自動開機啟動外,還可以直接下 service apachectl start/stop 啟動

 

八、設定 建立 JBoss EAP 的 Domain 為 Service

Step 01: copy jboss-as.conf 到 /etc/jboss-as/ ;copy jboss-as-domain.sh 到 /etc/init.d/

[root@bm etc]# cp /opt/jboss-eap-6.4/bin/init.d/jboss-as.conf /etc/jboss-as/

[root@bm jboss-as]# cp /opt/jboss-eap-6.4/bin/init.d/jboss-as-domain.sh /etc/init.d/


Step 02: 修改 /etc/jboss-as/jboss-as.conf

# The username who should own the process.
#
JBOSS_USER=root

# The amount of time to wait for startup
#
STARTUP_WAIT=30

# The amount of time to wait for shutdown
#
# SHUTDOWN_WAIT=30

# Location to keep the console log
#
# JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log

 

Step 03: 修改 /etc/init.d/jboss-as-domain.sh

#!/bin/sh
#
# JBoss domain control script
#
# chkconfig: - 80 20
# description: JBoss AS Domain
# processname: domain
# pidfile: /var/run/jboss-as/jboss-as-domain.pid
# config: /etc/jboss-as/jboss-as.conf

# Source function library.
. /etc/init.d/functions

# Load Java configuration.
#[ -r /etc/java/java.conf ] && . /etc/java/java.conf
#export JAVA_HOME

# Load JBoss AS init.d configuration.
if [ -z "$JBOSS_CONF" ]; then
  JBOSS_CONF="/etc/jboss-as/jboss-as.conf"
fi

[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}"

# Set defaults.

if [ -z "$JBOSS_HOME" ]; then
  JBOSS_HOME=/opt/jboss-eap-6.4
fi
export JBOSS_HOME

 

Step 04: 註冊 JBOSS 成 Service

[user@host init.d]$ sudo chkconfig --add jboss-as-domain.sh

[user@host init.d]$ sudo chkconfig --level 2345 jboss-as-domain.sh on #設置 jboss-as-domain.sh 在運行級別為2、3、4、5的情況下都是on(開啟)的狀態

 

 這樣子就可以兩台相互備援了.

 

附註:

■ 若同一個環境有不同的 mod_cluster, 為了不要互相引響,可以在 mod_cluster 的httpd.conf 加入 allow 作限制如下:vi $APACHE_HOME/httpd/conf/httpd.conf

## 2015/09/22 added by polin wei
<VirtualHost 192.168.30.100:80>
  <Directory />
    Order deny,allow
    Deny from all
    Allow from all
  </Directory>
  <Location /cluster_manager>
    SetHandler mod_cluster-manager
    Order deny,allow
    Deny from all
    Allow from 192.168.30.
  </Location>
</VirtualHost>

Listen 192.168.30.100:6666
#ManagerBalancerName mycluster   
ManagerBalancerName other-server-group
<VirtualHost 10.10.2.52:6666>
  <Directory />
    Order deny,allow
      Deny from all
      Allow from 192.168.30.100
      Allow from 192.168.30.101
  </Directory>
  ServerAdvertise on http://192.168.30.100:6666
  EnableMCPMReceive
</VirtualHost>

 

 

 

 

 

參考:

http://wiki.lunarpages.com/Allow_and_Deny_by_IP_Address

 

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

之前的 JBoss 的 JBoss EAP6 Domain Mode Setup 與 JBoss EAP6.x Standalone Mode Cluster Configuration 都在 Windows 平台上作測試,現在起將拋棄 微軟 擁抱 Linux,因為後續的資料庫也是使用 Oracle DataBase,因此 Linux 平台選擇 Oracle Linux,大致的安裝過程可以查看 Oracle Linux Install Using LVM

安裝檔下載:

1. Oracle Linux 的來源可從下面取得:

https://edelivery.oracle.com/linux

 

2. 下載JDK:

Oracle的官網可以下載到最新的JDK版本,官網網址如下:http://www.oracle.com/technetwork/java/javase/downloads/index.html

所有的版本:http://www.oracle.com/technetwork/java/archive-139210.html

3. 指令:

會使用到 rpm 或 yum 的安裝移除令,可以參考 yum 基本介紹和參數說明

安裝 JDK 方法一開始(建議以此方法為主):

1. 查詢 Oracle Linux 預設的 openJDK : OracleLinux7.1_x86_64 所搭配的 Java 是 openJDK ,用 rpm -qa | grep java 查詢後將它移除

[root@localhost ~]# rpm -qa | grep java
java-1.7.0-openjdk-1.7.0.75-2.5.4.2.0.1.el7_0.x86_64
python-javapackages-3.4.1-6.el7_0.noarch
javapackages-tools-3.4.1-6.el7_0.noarch
tzdata-java-2015a-1.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.75-2.5.4.2.0.1.el7_0.x86_64

2. 移除 openJDK ,可以使用 yum remove java* 或者 rpm -e package_name 指令

[root@localhost ~]# yum remove java*
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-openjdk.x86_64 1:1.7.0.75-2.5.4.2.0.1.el7_0 will be erased
--> Processing Dependency: java-1.7.0-openjdk for package: icedtea-web-1.5.2-0.el7.x86_64
---> Package java-1.7.0-openjdk-headless.x86_64 1:1.7.0.75-2.5.4.2.0.1.el7_0 will be erased
---> Package javapackages-tools.noarch 0:3.4.1-6.el7_0 will be erased
--> Processing Dependency: jpackage-utils for package: rhino-1.7R4-5.el7.noarch
--> Processing Dependency: jpackage-utils for package: rhino-1.7R4-5.el7.noarch
--> Processing Dependency: jpackage-utils for package: tagsoup-1.2.1-8.el7.noarch
--> Processing Dependency: jpackage-utils >= 1.6 for package: tagsoup-1.2.1-8.el7.noarch
--> Processing Dependency: jpackage-utils for package: jline-1.0-8.el7.noarch
--> Running transaction check
---> Package icedtea-web.x86_64 0:1.5.2-0.el7 will be erased
---> Package jline.noarch 0:1.0-8.el7 will be erased
---> Package rhino.noarch 0:1.7R4-5.el7 will be erased
---> Package tagsoup.noarch 0:1.2.1-8.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch   Version                      Repository     Size
================================================================================
Removing:
 java-1.7.0-openjdk     x86_64 1:1.7.0.75-2.5.4.2.0.1.el7_0 @anaconda/7.1 493 k
 java-1.7.0-openjdk-headless
                        x86_64 1:1.7.0.75-2.5.4.2.0.1.el7_0 @anaconda/7.1  90 M
 javapackages-tools     noarch 3.4.1-6.el7_0                @anaconda/7.1 155 k
Removing for dependencies:
 icedtea-web            x86_64 1.5.2-0.el7                  @anaconda/7.1 1.8 M
 jline                  noarch 1.0-8.el7                    @anaconda/7.1  72 k
 rhino                  noarch 1.7R4-5.el7                  @anaconda/7.1 1.0 M
 tagsoup                noarch 1.2.1-8.el7                  @anaconda/7.1 140 k

Transaction Summary
================================================================================
Remove  3 Packages (+4 Dependent packages)

Installed size: 94 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Erasing    : icedtea-web-1.5.2-0.el7.x86_64                               1/7
  Erasing    : rhino-1.7R4-5.el7.noarch                                     2/7
  Erasing    : jline-1.0-8.el7.noarch                                       3/7
  Erasing    : tagsoup-1.2.1-8.el7.noarch                                   4/7
  Erasing    : 1:java-1.7.0-openjdk-1.7.0.75-2.5.4.2.0.1.el7_0.x86_64       5/7
  Erasing    : 1:java-1.7.0-openjdk-headless-1.7.0.75-2.5.4.2.0.1.el7_0.x   6/7
  Erasing    : javapackages-tools-3.4.1-6.el7_0.noarch                      7/7
  Verifying  : 1:java-1.7.0-openjdk-headless-1.7.0.75-2.5.4.2.0.1.el7_0.x   1/7
  Verifying  : icedtea-web-1.5.2-0.el7.x86_64                               2/7
  Verifying  : tagsoup-1.2.1-8.el7.noarch                                   3/7
  Verifying  : rhino-1.7R4-5.el7.noarch                                     4/7
  Verifying  : 1:java-1.7.0-openjdk-1.7.0.75-2.5.4.2.0.1.el7_0.x86_64       5/7
  Verifying  : jline-1.0-8.el7.noarch                                       6/7
  Verifying  : javapackages-tools-3.4.1-6.el7_0.noarch                      7/7

Removed:
  java-1.7.0-openjdk.x86_64 1:1.7.0.75-2.5.4.2.0.1.el7_0
  java-1.7.0-openjdk-headless.x86_64 1:1.7.0.75-2.5.4.2.0.1.el7_0
  javapackages-tools.noarch 0:3.4.1-6.el7_0

Dependency Removed:
  icedtea-web.x86_64 0:1.5.2-0.el7         jline.noarch 0:1.0-8.el7
  rhino.noarch 0:1.7R4-5.el7               tagsoup.noarch 0:1.2.1-8.el7

Complete!

3. 使用 rpm 指令安裝 jdk-8u45-linux-x64.rpm

[root@localhost tmp]# rpm -ivh jdk-8u45-linux-x64.rpm
正在準備…                       ################################# [100%]
Updating / installing...
   1:jdk1.8.0_45-2000:1.8.0_45-fcs    ################################# [100%]
Unpacking JAR files...
    rt.jar...
    jsse.jar...
    charsets.jar...
    tools.jar...
    localedata.jar...
    jfxrt.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
[root@localhost tmp]# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
[root@localhost tmp]# javac -version
javac 1.8.0_45

利用 rpm 安裝完的 JDK,根目錄會在 /usr/java/jdk1.8.0_45

[root@localhost java]# pwd
/usr/java
[root@localhost java]# ls -l
總計 4
lrwxrwxrwx. 1 root root   16  8月 17 16:36 default -> /usr/java/latest
drwxr-xr-x. 9 root root 4096  8月 17 16:36 jdk1.8.0_45
lrwxrwxrwx. 1 root root   21  8月 17 16:36 latest -> /usr/java/jdk1.8.0_45

4. 編輯「/etc/profile」檔案。這個profile檔案裡寫的指令在系統開機時會自動執行。

 使用「export」指令來設定Java相關的系統環境變數。要設定的變數有「JAVA_HOME」、「JRE_HOME」、「PATH」、 「CLASSPATH」。「JAVA_HOME」為JDK的目錄,就是剛剛複製到「/usr/lib」目錄中的JDK目錄,「JRE_HOME」為 JRE(Java Runtime Environment)的目錄,JDK有包含JRE,位置就在JDK目錄下的「jre」目錄。「PATH」變數為系統尋找指令(檔案)的路徑,將 「JAVA_HOME」變數和「JRE_HOME」變數加進原先的「PATH」變數前。「CLASSPATH」變數為Java尋找Java程式所使用到的 Class路徑,路徑可以是目錄也可以是.jar檔案,將目前的目錄「.」和「$JAVA_HOME/lib」與「$JAVA_HOME/jre /lib」加進變數中吧!

 範例如下:

export JAVA_HOME=/usr/java/jdk1.8.0_45
export JRE_HOME=/usr/java/jdk1.8.0_45/jre
export ANT_HOME=/opt/apache-ant-1.7.0
export JBOSS_HOME=/opt/jboss-eap-6.3

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH:$ANT_HOME/bin
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JRE_HOME/lib

重新關機後,就可以生效。

 

安裝 JDK 方法二開始(特殊需求時使用):

Step 01:將 jdk-8u45-linux-x64.tar.gz 解壓縮在 /opt/jdk1.8.0_45

Linux_JDK.png  

 

 Step 02:編輯「/etc/profile」檔案。這個profile檔案裡寫的指令在系統開機時會自動執行。

export ANT_HOME=/opt/apache-ant-1.7.0
export JAVA_HOME=/opt/jdk1.8.0_45_x64
export JRE_HOME=/opt/jdk1.8.0_45_x64/jre
export JBOSS_HOME=/opt/jboss-eap-6.3

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH:$ANT_HOME/bin
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JRE_HOME/lib

 重新關機後,就可以生效。

 

安裝 JBoss EAP 開始:

1. 到 https://access.redhat.com/downloads/ 下載 jboss-eap-6.3 的 zip 檔,並解壓縮放在 /opt/jboss-eap-6.3

2. 執行 /opt/jboss-eap-6.3/bin/add-user.sh 增加管理 JBoss EAP Server 的帳號

3. 執行 /opt/jboss-eap-6.3/bin/standalone.sh 就可以手動啟動 JBoss EAP , 並可以在本機輸入網址 http://localhost:9990/console/ 進入管理.

在 Oracle Linux 上建立 JBoss EAP 的 Service

1. 編輯 $JBOSS_HOME/bin/init.d/jboss-as.conf   ,檔案內容至要少有 JBOSS_HOME & JBOSS_USER 這兩個變數的設定。

範例如下:

# General configuration for the init.d scripts,
# not necessarily for JBoss AS itself.

# The username who should own the process.
#
JBOSS_USER=root
JBOSS_HOME=/opt/jboss-eap-6.3

2. 將 $JBOSS_HOME/bin/init.d/jboss-as.conf 複制到 /etc/jboss-as 目錄,與 $JBOSS_HOME/bin/init.d/jboss-as-standalone.sh 複制到 /etc/init.d

Copy the modified configuration file to the /etc/jboss-as directory.

[user@host init.d]$ sudo mkdir /etc/jboss-as

[user@host init.d]$ sudo cp $JBOSS_HOME/bin/init.d/jboss-as.conf /etc/jboss-as/

Copy the start-up script to the /etc/init.d directory.

[user@host init.d]$ sudo cp $JBOSS_HOME/bin/init.d/jboss-as-standalone.sh /etc/init.d

3. 修改 /etc/init.d/jboss-as-standalone.sh 內容,如紅色標注部份,因為 JAVA_HOME 已在前面有設定了, 所以不用再作判斷。

#!/bin/sh
#
# JBoss standalone control script
#
# chkconfig: - 80 20
# description: JBoss AS Standalone
# processname: standalone
# pidfile: /var/run/jboss-as/jboss-as-standalone.pid
# config: /etc/jboss-as/jboss-as.conf

# Source function library.
. /etc/init.d/functions

# Load Java configuration.
#[ -r /etc/java/java.conf ] && . /etc/java/java.conf
#export JAVA_HOME

# Load JBoss AS init.d configuration.
if [ -z "$JBOSS_CONF" ]; then
  JBOSS_CONF="/etc/jboss-as/jboss-as.conf"
fi

[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}"

# Set defaults.

if [ -z "$JBOSS_HOME" ]; then
  JBOSS_HOME=/opt/jboss-eap-6.3
fi
export JBOSS_HOME

.

.

.

 

4. 註冊 JBoss 為 Service

[user@host init.d]$ sudo chkconfig --add jboss-as-standalone.sh

 5. 執行指令 setup 檢查 JBoss EAP 的服務是否有設為自動啟動( [*] jboss-as-standalone.sh),若沒有則按空白鍵作設定。這樣啟 OS 時,JBoss EAP 就會自動帶啟。

[root@localhost ~]# setup

linux_setup

setup_jboss_service  

4. 手動啟動/停止/重啟 JBoss

[root@localhost ~]# sudo service jboss-as-standalone start [stop] [restart] [status]

[root@localhost ~]# sudo service jboss-as-standalone
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status)

 

 

 

參考:

http://magiclen.org/linux-jdk/

https://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html

http://wei-meilin.blogspot.tw/2012/10/jeap-6-red-hat-linux-service.html

https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html/Installation_Guide/Install_JBoss_Enterprise_Application_Platform_6_Red_Hat_Enterprise_Linux_Service.html

https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.3/html/Installation_Guide/Install_JBoss_Enterprise_Application_Platform_6_Red_Hat_Enterprise_Linux_Service.html

[user@host init.d]$ sudo chkconfig --add jboss-as-standalone.sh
文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

JBOSS & Wildfly 常用設置

1. JBoss伺服器改成支援外網訪問
standalone.xml文件中找到

<interface name="public">
            <inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>

在這個下面加入

 <interface name="any">
            <any-ipv4-address/>
 </interface>

另外把1改成2
1  <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
2  <socket-binding-group name="standard-sockets" default-interface="any" port-offset="${jboss.socket.binding.port-offset:0}">

或改成

<interface name="public">
    <any-address/>
</interface>

也可以用圖形管理界面來作修改,如下圖,將 Address Wildcard 設為:Any Address,並將 Inet Address 設為空值,不然會有錯誤。

JBoss interface 對外  

修改管理介面的網址限制

jboss_manageIP  
 
2.
訪問埠的更改
<socket-binding name="http" port="${jboss.http.port:80}"/>
 
3.
改為可以修改JSP頁面不用重啟

<servlet-container name="default">
    <jsp-config/>
    <websockets/>
</servlet-container>

改為

<servlet-container name="default">
      <jsp-config development="true"/>
</servlet-container>

 
4.
部署的程式不用wildfly內置CXF
 在應用的WEB-INF目錄下面增加該檔:jboss-deployment-structure.xml

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
  <!-- exclude-subsystem prevents a subsystems deployment unit processors running on a deployment -->
     <!-- which gives basically the same effect as removing the subsystem, but it only affects single deployment -->
        <exclude-subsystems>
            <subsystem name="webservices" />
        </exclude-subsystems>
    </deployment>
</jboss-deployment-structure>

 

參考:

http://misforum.ddns.net/forum.php?mod=viewthread&tid=19

http://my.oschina.net/zhaoqian/blog/366406

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

JBoss EAP 6.x 上要建立 Oracle DataBase 的 Java Naming and Directory Interface (JNDI) 作法分三個步驟如下:

Step 01: 在 $JBOSS_HOME 目錄 modules 下建立 oracle 相關資訊

$ mkdir -p $JBOSS_HOME/modules/com/oracle/main/
$ touch $JBOSS_HOME/modules/com/oracle/main/module.xml

 Step 02: 維護 $JBOSS_HOME/modules/com/oracle/main/module.xml 內容如下

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle">  
    <resources>  
        <resource-root path="ojdbc6.jar"/>  
    </resources>  
    <dependencies>  
        <module name="javax.api"/>  
        <module name="javax.transaction.api"/>  
    </dependencies>  
</module>

Oracle DB 的 JDBC Jar 檔 ojdbc6.jar 可以從 Oracle Database 11g Release 2 JDBC Drivers 下載,並將下載的檔案ojdbc6.jar 放在 $JBOSS_HOME/modules/com/oracle/main 裡。

 

Step 03: 這裡以 JBoss EAP standalone Mode 作為範例,修改 $JBOSS_HOME/standalone/configuration/standalone.xml

<profile>
...
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
    <datasources>
        ...               
      <datasource jndi-name="java:/xe" pool-name="xe" enabled="true">
          <connection-url>jdbc:oracle:thin:@127.0.0.1:1521:XE</connection-url>
          <driver>oracle</driver>
          <pool>
              <min-pool-size>10</min-pool-size>
              <max-pool-size>200</max-pool-size>
              <prefill>true</prefill>
          </pool>
          <security>
              <user-name>system</user-name>
              <password>oracle</password>
          </security>
      </datasource>
        <drivers>
            ...
            <driver name="oracle" module="com.oracle">
                <datasource-class>oracle.jdbc.driver.OracleDriver</datasource-class>
            </driver>
        </drivers>
    </datasources>
</subsystem>
</profile>

 

再重啟 JBoss EAP standalone Mode: $JBOSS_HOME/bin/standalone.bat 即可

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

裝完 JBoss EAP 6.x ,並利用 Eclipse 開發程式除錯 Debug 時,發現一般使用 System.out.println() &  logger.info() 都沒有出現在 Console 中,查了好久才找到正解如下:

1. 在 Eclipse 開發環境:

在 Servers 視窗下的 JBoss EAP Server 點兩下,選擇 Open Launch configuration ,然後在 VM arguments 裡最後加入 -Dorg.jboss.as.logging.per-deployment=false 即可,如下圖:

JBossEAP_Eclipse.png  

這樣訊息就會出來了,但 System.out.print() 仍會不出現,直到下一個 System.out.println() 才會一起出現,這是JBoss EAP 的 Bug.

 

2. 在 JBoss 正式環境的設定:

Step 1 :

修改 $JBOSS_HOME/standalone/configuration/standalone.xml 增加 <use-deployment-logging-config value="false"/> 在 <profile>...</profile> 中如下:

    <profile>
        <subsystem xmlns="urn:jboss:domain:logging:2.0">
              <use-deployment-logging-config value="false"/>
            <console-handler name="CONSOLE">
                <level name="INFO"/>
                <formatter>
                    <named-formatter name="COLOR-PATTERN"/>
                </formatter>
            </console-handler>

 

參考:

http://mariemjabloun.blogspot.tw/2013/11/disable-jboss-eap-6-logging-exclude.html

https://bugzilla.redhat.com/show_bug.cgi?id=1070453

文章標籤

MIS 發表在 痞客邦 留言(1) 人氣()

JBoss EAP 6.x 上要建立 MySQL 的 Java Naming and Directory Interface (JNDI) 作法分三個步驟如下:

Step 01: 在 $JBOSS_HOME 目錄 modules 下建立 mysql 相關資訊

$ mkdir -p $JBOSS_HOME/modules/com/mysql/main/
$ touch $JBOSS_HOME/modules/com/mysql/main/module.xml

 

Step 02: 維護 $JBOSS_HOME/modules/com/mysql/main/module.xml 內容如下

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
  <resources>
    <resource-root path="mysql-connector-java-5.1.7-bin.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

MySQL 的 JDBC Jar 檔可以從 http://dev.mysql.com/downloads/connector/j/ 網站下載,並將下載的檔案 mysql-connector-java-x.x.x-bin.jar 放在 $JBOSS_HOME/modules/com/mysql/main 裡。

Step 03: 這裡以 JBoss EAP standalone Mode 作為範例,修改 $JBOSS_HOME/standalone/configuration/standalone.xml

<profile>
...
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
    <datasources>
        ...               
        <datasource jndi-name="java:jboss/datasources/ExampleInfinispanDS" pool-name="ExampleInfinispanDS" enabled="true" use-java-context="true" use-ccm="true">
            <connection-url>jdbc:mysql://localhost:3306/EXAMPLEINFINISPAN</connection-url>
            <driver>mysql</driver>
            <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
            <pool>
                <min-pool-size>10</min-pool-size>
                <max-pool-size>100</max-pool-size>
                <prefill>true</prefill>
            </pool>
            <security>
                <user-name>root</user-name>
                <password>root</password>
            </security>
            <validation>
                <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
            </validation>
            <timeout>
                <!-- using default timeout values -->
            </timeout>
            <statement>
                <prepared-statement-cache-size>100</prepared-statement-cache-size>
                <share-prepared-statements>true</share-prepared-statements>
            </statement>
        </datasource>
        <drivers>
            ...
            <driver name="mysql" module="com.mysql">
                <datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</datasource-class>
            </driver>
        </drivers>
    </datasources>
</subsystem>
</profile>

 

再重啟 JBoss EAP standalone Mode: $JBOSS_HOME/bin/standalone.bat 即可

 

 

參考:

http://magnus-k-karlsson.blogspot.tw/2013/08/complete-configuration-of-mysql-5.html

http://www.vogella.com/tutorials/MySQLJava/article.html

https://access.redhat.com/documentation/en-US/JBoss_Enterprise_BRMS_Platform/5/html/BRMS_Administrator_Guide/Configuring_a_Datasource_for_JBoss_Enterprise_Application_Platform_6.html

JBoss EAP 6.1 Administration and Configuration Guide. Chapter 6.6. Datasource Configuration

MySQL 5 Manual. Chapter 22.3.5.1 Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

在 JBoss EAP6.x Standalone Mode Cluster Configuration 驗證了 Standalone Mode 的 Cluster 機制,在 Domain Mode 的設定也很簡單,還記得在 JBoss EAP6 Domain Mode Setup 中 host.xml 對每台 server 作了 port-offset ,而這就是 workers.properties 檔案裡的 node。

 

JBoss_Domain_RealCase.png  

 

 

 

 

所以在 workers.properties 的設定如下:

# Define list of workers that will be used  
# for mapping requests  
worker.list=loadbalancer,status  
 
# Define Node1  
# modify the host as your host IP or DNS name.  
worker.node1.port=8009  
worker.node1.host=10.10.2.4
worker.node1.type=ajp13  
worker.node1.ping_mode=A  
worker.node1.lbfactor=1   
 
# Define Node2  
# modify the host as your host IP or DNS name.  
worker.node2.port=8109
worker.node2.host=10.10.3.118
worker.node2.type=ajp13  
worker.node2.ping_mode=A  
worker.node2.lbfactor=1  
 
# Define Node3  
# modify the host as your host IP or DNS name.  
worker.node3.port=8209
worker.node3.host=10.10.3.118
worker.node3.type=ajp13  
worker.node3.ping_mode=A  
worker.node3.lbfactor=1

# Define Node4  
# modify the host as your host IP or DNS name.  
worker.node4.port=8409
worker.node4.host=10.10.3.118
worker.node4.type=ajp13  
worker.node4.ping_mode=A  
worker.node4.lbfactor=1

 
# Load-balancing behavior  
worker.loadbalancer.type=lb  
worker.loadbalancer.balance_workers=node1,node2,node3,node4
worker.loadbalancer.sticky_session=0  
 
# Status worker for managing load balancer  
worker.status.type=status

 

啟動的順序是,先將 JBoss 開始後,再啟動 Apache 就可以了。

JBoss 的啟動指令 JBoss EAP6 Domain Mode Setup 裡的 Step04 & Step05 相同,不需修改。

 

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

JBoss EAP 6.x (Enterprise Application Platform) 提供 Cluster 的機制,但需要 apache 的 mod-jk.conf 配合,現在以 Standalone Mode 作為 HA 來測試看看。

Step 01: apache 的設定

APACHE_HOME/conf/httpd.conf

# Include mod_jk's specific configuration file  
Include conf/mod-jk.conf

<VirtualHost 192.168.2.4:80>
    JkMount /* loadbalancer  
</VirtualHost>

 

APACHE_HOME/conf/mod-jk.conf

# Load mod_jk module
# Specify the filename of the mod_jk lib 
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile conf/workers.properties

# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/uriworkermap.properties

# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/mod_jk.shm

# Where to put jk logs
JkLogFile logs/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Mount your applications
JkMount /* loadbalancer

<Location /jkstatus/>  
    JkMount status  
    Order deny,allow  
    Deny from all  
    Allow from all  
</Location> 

 

APACHE_HOME/conf/workers.properties

# Define list of workers that will be used  
# for mapping requests  
worker.list=loadbalancer,status  
 
# Define Node1  
# modify the host as your host IP or DNS name.  
worker.node1.port=8009  
worker.node1.host=192.168.2.4
worker.node1.type=ajp13  
worker.node1.ping_mode=A  
worker.node1.lbfactor=1   
 
# Define Node2  
# modify the host as your host IP or DNS name.  
worker.node2.port=8009
worker.node2.host=192.168.3.118
worker.node2.type=ajp13  
worker.node2.ping_mode=A  
worker.node2.lbfactor=1  
 
# Load-balancing behavior  
worker.loadbalancer.type=lb  
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1  
 
# Status worker for managing load balancer  
worker.status.type=status

 

APACHE_HOME/conf/uriworkermap.properties

# Simple worker configuration file  
 
# Mount the Servlet context to the ajp13 worker  
/jmx-console=loadbalancer  
/jmx-console/*=loadbalancer  
/web-console=loadbalancer  
/web-console/*=loadbalancer  
#/printSession=loadbalancer  
#/printSession/*=loadbalancer

作好設定後,就可以啟動 apache Server。

 

Step 02: 設定第一個 JBoss Standalone : node1 (worker.node1.host=192.168.2.4 )

JBOSS_HOME/standalone/configuration/standalone-ha.xml

<subsystem xmlns="urn:jboss:domain:web:1.5" default-virtual-server="default-host" instance-id="node1" native="false">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
    <virtual-server name="default-host" enable-welcome-root="true">
        <alias name="localhost"/>
        <alias name="example.com"/>
    </virtual-server>
</subsystem>

 

Step 03: 設定第二個 JBoss Standalone : node2 (worker.node2.host=192.168.3.118 )

JBOSS_HOME/standalone/configuration/standalone-ha.xml

<subsystem xmlns="urn:jboss:domain:web:1.5" default-virtual-server="default-host" instance-id="node2" native="false">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
    <virtual-server name="default-host" enable-welcome-root="true">
        <alias name="localhost"/>
        <alias name="example.com"/>
    </virtual-server>
</subsystem>

 

Step 04: 分別啟動 node1 & node2

standalone.bat -c standalone-ha.xml -Djobss.node.name=node1 -b 192.168.2.4

standalone.bat -c standalone-ha.xml -Djobss.node.name=node2 -b 192.168.3.118

 

Step 05: 建立一個 example.war 檔來測試

WebContent\WEB-INF\web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>example</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
 
 <distributable/>
    <description>session test</description>  
</web-app>

 

WebContent\sessionTest.jsp

<%@page    import="java.util.*, java.lang.reflect.*, javax.servlet.http.HttpSession, java.net.*"%>
<%
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort();
    String cPath = request.getContextPath();
    String sPath = request.getServletPath();
    String nodeId = System.getProperty("jboss.server.name");
    String nodeName = System.getProperty("jboss.node.name");
    //String hostName = System.getProperty("jboss.host.name");
    String hostName = System.getProperty("java.rmi.server.hostname");
    String variableString = (String) session
            .getAttribute("SESSION_TEST_VARIABLE");
    int count = 0;

    if (variableString != null) {
        count = Integer.parseInt(variableString);
        count++;
    }

    session.setAttribute("SESSION_TEST_VARIABLE", String.valueOf(count));
%>

<html>
<body bgcolor=white>

    Edit By Polin
    <table columns=1>
        <tr>
            <td><font color=blue>Edit By Polin</td>/
        </tr>
    </table>
    <table columns=2>
        <tr>
            <td><font color=blue>The sessionId is: </font></td>
            <td><%=session.getId()%></td>
        </tr>
        <tr>
            <td><font color=blue>The sessionObj is: </font></td>
            <td><%=session%></td>
        </tr>
        <tr>
            <td><font color=blue>The nodeId is: </font></td>
            <td><%=nodeId%></td>
        </tr>
        <tr>
            <td><font color=blue>The nodeName is: </font></td>
            <td><%=nodeName%></td>
        </tr>
        <tr>
            <td><font color=blue>The server hostName is: </font></td>
            <td><%=hostName%></td>
        </tr>
        <tr>
            <td><font color=blue># of requests placed on session: </font></td>
            <td><%=count%></td>
        </tr>
    </table>
</body>
</html>

 

這樣就可以在 https://192.168.2.4/example 作訪問驗證,apache 會自動將 Session 分配到 192.168.2.4 & 192.168.3.118

 

參考:

http://docs.jboss.org/jbossas/docs/Clustering_Guide/5/html/clustering-http-modjk.html

http://blog.c2b2.co.uk/2013/01/setting-up-jboss-eap-5-cluster-with.html

https://docs.jboss.org/jbossas/docs/Clustering_Guide/5/html_single/#d0e1257

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

JBoss EAP(Enterprise Application Platform) 提供 Domain Mode ,可以讓應用系統佈署簡單化,也可以讓應用系統不會因一台主機掛了,而導致使用者就無法登入,至於 Domain Mode 的概念在 JBoss EAP 與 JBoss AS/Community edition 及 WildFly 的差異 有提了一下,現在我們來實作,整個架構如下圖。

 

 JBoss_Domain_plan.png  

 Step 01: 設定 Domain Control 主機 Host name: dc-master / ip: 192.168.2.4

修改d:\AppServ\jboss-eap-6.2-master\domain\configuration\host.xml,host name 的值必需是唯一值

<host name="EAP-Domain-Master" xmlns="urn:jboss:domain:1.5">

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

    <servers>
        <server name="server-one" group="main-server-group"/>
    </servers>

</host>

 

Step 02:在 Domain Control 主機 Host name: dc-master / ip: 192.168.2.4 建立 Domain Mode 主機間溝通用專用的帳號:domainMaster,並取得 secret key

D:\AppServ\jboss-eap-6.2\bin>add-user.bat

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): a

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : domainMaster
Password : xxxxx
Re-enter Password : xxxxx
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]:
About to add user 'domainMaster' for realm 'ManagementRealm' Is this correct yes/no? yes
Added user 'domainMaster' to file 'D:\AppServ\jboss-eap-6.2\standalone\configuration\mgmt-users.properties'
Added user 'domainMaster' to file 'D:\AppServ\jboss-eap-6.2\domain\configuration\mgmt-users.properties'
Added user 'domainMaster' with groups  to file 'D:\AppServ\jboss-eap-6.2\standalone\configuration\mgmt-groups.properties'
Added user 'domainMaster' with groups  to file 'D:\AppServ\jboss-eap-6.2\domain\configuration\mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls. yes/no? yes
To represent the user add the following to the server-identities definition <secret value="UEBzc3cwcmQ=" />
Press any key to continue . . .

 

接下來的 Step03 & Step04 因為是在同一台主機 Host name: dc-slave / ip: 192.168.3.118 上,所以 management port 要作變動

Step03: 設定 Slave 主機 Host name: dc-slave / ip: 192.168.3.118 上的第一個EAP主機: EAP-instance-two

修改 D:\AppServ\jboss-eap-6.2-1\domain\configuration\host.xml

<host name="EAP-instance-two" xmlns="urn:jboss:domain:1.5">

    .
    .
    .
    <management>

        <security-realms>
            <security-realm name="ManagementRealm">
                <server-identities>
                    <secret value="UEBzc3cwcmQ="/>
                </server-identities>
    .
    .
    .
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.native.port:9998}"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.http.port:9991}"/>
            </http-interface>
        </management-interfaces>
    </management>

    <domain-controller>
        <remote host="192.168.2.4"  port="9999" security-realm="ManagementRealm" username="domainMaster" />        
    </domain-controller>

        <server name="server-two" group="main-server-group" auto-start="true">
            <socket-bindings port-offset="100"/>
        </server>

</host>

 

Step04: 設定 Slave 主機 Host name: dc-slave / ip: 192.168.3.118 上的第二個EAP主機: EAP-instance-three,因為在此 EAP Instance 上有兩個 server:server-threeserver-four 所以要作 port-offset

修改 D:\AppServ\jboss-eap-6.2-1\domain\configuration\host.xml

<host name="EAP-instance-three" xmlns="urn:jboss:domain:1.5">

    .
    .
    .
    <management>

        <security-realms>
            <security-realm name="ManagementRealm">
                <server-identities>
                    <secret value="UEBzc3cwcmQ="/>
                </server-identities>
    .
    .
    .
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.native.port:9997}"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.http.port:9992}"/>
            </http-interface>
        </management-interfaces>
    </management>

    <domain-controller>
        <remote host="192.168.2.4"  port="9999" security-realm="ManagementRealm" username="domainMaster" />        
    </domain-controller>

    <servers>
        <server name="server-three" group="main-server-group" auto-start="true">
            <socket-bindings port-offset="200"/>
        </server>
        <server name="server-four" group="main-server-group" auto-start="true">
            <socket-bindings socket-binding-group="ha-sockets" port-offset="300"/>
        </server>
    </servers>

</host>

 

Step05:啟動 Domain Control 主機 Host name: dc-master / ip: 192.168.2.4

d:/>domain.bat -b YourMasterHostName -bmanagement YourMasterHostName

例:

d:/>domain.bat -b dc-master -bmanagement dc-master

d:/>domain.bat -b 192.168.2.4  -bmanagement 192.168.2.4

 

Step06:啟動 Slave 主機 Host name: dc-slave / ip: 192.168.3.118 上的兩個EAP主機
./domain.sh -Djboss.domain.master.address=YourMasterHostName -b SlaveHostName -bmanagement SlaveHostName

D:\>AppServ\jboss-eap-6.2-1\bin\domain.bat -Djboss.domain.master.address=192.168.2.4 -b 192.168.3.118 -bmanagement 192.168.3.118

D:\>AppServ\jboss-eap-6.2-2\bin\domain.bat -Djboss.domain.master.address=192.168.2.4 -b 192.168.3.118 -bmanagement 192.168.3.118

 

Step07:進入管理介面 http://192.168.2.4:9990/console

JBoss_Domain_RealCase.png  

 

附記:

Configuring a Domain Controller 相關設定文件

Configuration

domain.xml

host.xml

<extensions>

X

 

<system-properties>

X

X

<paths>

X

X

<management>

 

X

<profiles>

X

 

<interfaces>

X

X

<domain-controller>

 

X

<jvms>

 

X

<servers>

 

X

<socket-binding-groups>

X

 

<server-groups>

X

 

<deployments>

X

 

 

 

參考

How to setup EAP6 in Domain Mode with Remote Host Controllers ?

http://wei-meilin.blogspot.tw/2012/07/jeap-6-standalone-domain-mode.html

文章標籤

MIS 發表在 痞客邦 留言(1) 人氣()

JBoss 是一套應用程式伺服器,屬於開源的企業級Java中介軟體軟體,用於實作基於SOA架構的web應用和服務。目前有分:付費有支援的版本JBoss EAP(Enterprise Application Platform) 及 Red Hat 支援社群的 Community edition 免費版本JBoss AS;與一般社群的 WildFly 版本,軟體下載位置 http://wildfly.org/downloads/

JBoss EAP (Enterprise Application Platform) 是一個支持 Java EE 6 的應用服務器,目前 EAP6 實現了兩個 Java EE 6 的配置文件:Full Profile & Web Profile。在實務作業中有 Standalone & Domain Mode 兩種模式,如下圖:

JBoss_Standalone_Domain.png  

 

環境配置的文件分別是:

Standalone Mode:standalone.xml

Domain Mode:domain.xml & host.xml

Standalone Mode 的執行是最簡單的,下載 EAP 6.2.0 GA 壓縮檔並解壓於D:\AppServ\jboss-eap-6.2,編輯 D:\AppServ\jboss-eap-6.2\bin\standalone.bat ,加上JAVA_HOME的設定,即可執行。

@echo off
rem -------------------------------------------------------------------------
rem JBoss Bootstrap Script for Windows
rem -------------------------------------------------------------------------

rem Use --debug to activate debug mode with an optional argument to specify the port
rem Usage : standalone.bat --debug
rem         standalone.bat --debug 9797


set "JAVA_HOME=D:\Progs\jdk1.7.0_45_x64"

 

啟動Jboss:

Windows: standalone.bat
Linux: ./standalone.sh

本機預設的 JBoss 網址:http://localhost:8080
本機預設的 JBoss 管理網址:http://localhost:9990

 

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

環境:

JBoss: 7.1.1.Final 下載地址: http://www.jboss.org/jbossas/downloads

JDK  下載地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html

Windows 8 x64bit

Oracle Linux 6.5 x64bit

 

一、安裝 JBoss 7.x

1) 將 jboss-as-7.1.1.Final.zip 解壓到 C:\AppServ\jboss-as-7.1.1.Final ( Linux:jboss-as-7.1.1.Final.tar.gz 解壓到 \opt\jboss-as-7.1.1.Final )

2) 安裝 jdk-7u45 後,複制到 D:\Progs\jdk1.7.0_45_x64

3) 修改 C:\AppServ\jboss-as-7.1.1.Final\bin\standalone.bat

Windows:
set JAVA_HOME="D:\Progs\jdk1.7.0_45_x64"

4) 啟動JBoss。

在 Windows 平台執行 D:\programs\jboss-as-7.1.1.Final\bin\standalone.bat 完成啟動。

在 Linux 平台執行 /opt/jboss-as-7.1.1.Final/bin/standalone.sh 完成啟動

5) 停止 JBoss

Windows / Linux 平台:在Server的命令列控制台,只要按下 Ctrl + C 就能夠乾淨的停止這個Server。

 

二、增加管理使用者

訪問該Web伺服器時,提示新增用戶。可在服務端執行add-user.bat / add-user.sh 來添加管理員用戶。

Windows: C:\AppServ\jboss-as-7.1.1.Final\bin\add-user.bat
Linux: /opt/jboss-as-7.1.1.Final/bin/add-user.sh
What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a):

選擇 a) 按 Enter

Enter the details of the new user to add.
Realm (ManagementRealm) :              // 直接按 Enter ,使用預計值
Username :                                       // 填寫管理員用戶名
Password :
Re-enter Password :

添加管理員後,訪問 http://127.0.0.1:9990/console 

 

三、外面的使用者流覽設定:

如:http://192.168.3.50:8080/  是無法訪問的。因為部署完後,預設只能本機端訪問(即:只有 http://127.0.0.1/localhost 能訪問),如果想讓其他人也可以訪問你的網頁,需要修改JBoss的設定檔,即修改 standalone.xml,增加本機Web位址的內容。

1) 打開  standalone.xml

Window: C:\AppServ\jboss-as-7.1.1.Final\standalone\configuration\standalone.xml
Linux: /opt/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml

2) 修改如下,即可讓外部電腦流覽,但只有主機可以管理

 
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
        </interface>
        <interface name="public">
             <any-address/>
        </interface>

重新啟動JBoss,即可讓外面的使用者流覽。

 

參考:

http://www.cnblogs.com/xw-cnblogs/articles/2439969.html

http://wenku.baidu.com/view/b92437c9a1c7aa00b52acb67.html

 

MIS 發表在 痞客邦 留言(0) 人氣()