Skip to main content

JEAP 6 - 使用 Standalone 建立 Cluster

今天是我的生日,但是還是沒得休息!

早上費德勒送我一個很棒的生日禮物,他又回到了世界冠軍,
溫布頓的冠軍獎杯,一個有毅力,不放棄的人,上天是不會虧待他的!

既然這麼被激勵,那來寫寫J老闆文,
延續上次的話題,介紹了兩個不同的mode,
這兩個不同的mode也可以建立Cluster, 先來講Standalone 的方式,
(Domain mode 要抓很多圖檔,好麻煩 >x< 掙扎ing)
============================================

首先,要啓動JBoss 的Standalone 非常之簡單,簡單到你會以為我生日所以就隨便寫!

在這裡要有個觀念,在這個版本的JBoss 中,Cluster 中所有的設定都是跟ha 有關,
而Standalone 其實就是跟 ha 的設定相同。

Standalone, 如果是沒有特別給,default 的設定是抓
standalone/configuration/standalone.xml

看一下standalone/configuration/的裡面

[root@jboss1 configuration]# ls -l
總計 140
-rw-rw-r--. 1 root root   634 2012-05-30 04:49 application-roles.properties
-rw-------. 1 root root   812 2012-05-30 04:49 application-users.properties
-rw-rw-r--. 1 root root  2042 2012-05-30 04:49 logging.properties
-rw-------. 1 root root   916 2012-06-29 10:41 mgmt-users.properties
-rw-rw-r--. 1 root root 26554 2012-05-30 04:49 standalone-full-ha.xml
-rw-rw-r--. 1 root root 20672 2012-05-30 04:49 standalone-full.xml
-rw-rw-r--. 1 root root 20615 2012-05-30 04:49 standalone-ha.xml
-rw-r--r--. 1 root root 16861 2012-07-06 06:43 standalone.xml

看裡面會看到一個standalone-ha.xml的檔案,沒錯,就是改成它就好了!

啓動的script (windows 請自行帶入.bat)
./standalone.sh -c standalone-ha.xml -Djboss.node.name=NODE名稱


如果你有兩台機器,兩台這樣啟動就成功了!但若這樣真的也太無腦了!(JBoss 這個新的無腦設定真棒!!) 所以來點難度, 在同一臺機器啓動兩個JBoss Server 吧!另外,每個server, 為了讓他辨識,請各指定一個node name 給它!

所以下圖是我的設定,你可以看到其中的 JBoss One 與 JBoss Two 因為分別放在不同的Host (機器) 上,所以不需要特別的設定,直接用上方的方式就可以跑了!
但是,JBoss Three 因為在同一個機器上,沒這麼簡單,因為相同的IP 啓動的port 會衝突。



JBoss One 啟動 
./standalone.sh -c standalone-ha.xml -Djboss.node.name=node1


JBoss Two 啟動
./standalone.sh -c standalone-ha.xml -Djboss.node.name=node2


所以,我們要把衝突解決掉,因此,我們到standalone-ha.xml修改一下設定
有兩個作法, 1. 修改IP, 把這個Server binding 的位置修改,2. 修改port 
因為不是每次都有IP 可以用,所以這次我選擇修改port . 

首先,先把 standalone-ha.xml copy 一份出來 standalone-ha2.xml
打開standalone-ha.xml,修改


<interfaces>

        <interface name="management">

            <!--如果你想改IP,請這裡修改-->

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

        </interface>
        <interface name="public">
            <!--如果你想改IP,請這裡修改-->
            <inet-address value="${jboss.bind.address:127.0.0.1}"/>
        </interface>
    </interfaces>
     <!--這裡修改PORT! -->
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:400}">
        <socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/>
        <socket-binding name="ajp" port="8009"/>
        <socket-binding name="http" port="8080"/>
        <socket-binding name="https" port="8443"/>
        ............
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>

這樣每個port 都會加400, 如是 8009 就會變成 8409, 8080 就會變成8480
所以,指定它去讀取我們修改後的standalone-ha2.xml 
外,因為我偷懶,沒有另外建立一個JBoss 的Server 環境,所以還要指定它的data 位置 standalone/data2, 
請另外安裝一個JBoss 的
./standalone.sh -c standalone-ha2.xml -Djboss.node.name=node3 -Djboss.server.data.dir=standalone/data2
JBoss Three 啟動

../standalone.sh -c standalone-ha2.xml -Djboss.node.name=node3


請注意它的port 都被加了 400.可是你會發現,怎麼沒有Cluster 的感覺,
沒錯,這個版本的Cluster 是on demand被啓動的,也就是說,有需要才有,什麼時候有?
就是deploy Application 的時候囉!

如我deploy 了一個程式,上server , 
(PS, 請記得!不同的機器或是檔案路徑要自己上傳程式上去,才會各別生效噢! 我因為這個問題卡了一個晚上!)

你會看見,Cluster 開始作用!

02:58:53,639 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "sessionTest2.war"
02:58:53,953 INFO  [org.jboss.as.osgi] (MSC service thread 1-4) JBAS011907: Register module: Module "deployment.sessionTest2.war:main" from Service Module Loader
02:58:54,164 INFO  [stdout] (ChannelService lifecycle - 1) 
02:58:54,165 INFO  [stdout] (ChannelService lifecycle - 1) -------------------------------------------------------------------
02:58:54,167 INFO  [stdout] (ChannelService lifecycle - 1) GMS: address=node1/web, cluster=web, physical address=172.16.1.77:55255
02:58:54,167 INFO  [stdout] (ChannelService lifecycle - 1) -------------------------------------------------------------------
..........
02:58:59,626 INFO  [org.jboss.as.clustering] (Incoming-3,null) JBAS010225: New cluster view for partition web (id: 2, delta: 1, merge: false) : [node1/web, node3/web, node2/web]
02:58:59,626 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (Incoming-3,null) ISPN000094: Received new cluster view: [node1/web|2] [node1/web, node3/web, node2/web]

最後還會看見總共的Cluster 數量! 如果你看見!就表示成功囉!



Comments

Alex Lin said…
This comment has been removed by the author.
Alex Lin said…
Hi Christina,

想要請教一下,

我目前是下載Jboss EAP 6.1.1 安裝後,

直接照著你所寫的下去建立Cluster.

但無法啟動Cluster.

是否還有其他步驟要先做執行呢??

感謝
Alex Lin said…
Hi Christina,

我再說明一下我的問題,

我是想要在一台機器上起兩個JBoss,

也就是模擬本文的node1 和node3

所以在node3的standalone-ha.xml我只有改了port沒有更改IP

會是因為這樣所以起不來的嗎??
Christina Lin said…
無法啓動是連server 都起不來嘛?
Alex Lin said…
server是起得來,但Cluster沒有啟動

Popular posts from this blog

Fuse Integration Service - Setup JBDS and create first quickstart application

Before we go and start creating our first application, I want to show you how to setup your JBoss Developer Studio, create a small application from the quickstart example and then running it on Fuse Integration Service.

I am using JBoss Developer Studio version 9, you can find it here.
After download the

jboss-devstudio-9.0.0.GA-installer-eap.jar
double-click it, and start installing with default values.

After successful installation, we will need install the plugins for Fuse, on JBoss Central view, select software update, select enable early access.


And select JBoss Fuse Development for the plugin,


Click on install, and we are all set to go!

First thing first, we want to create a Fuse project to deploy on the base of Fuse Integration Service, which is OpenShift. If you have not installed it, please go back to my previous post for instructions. So on your JBDS, right click and start creating the project. Select new, maven project, if you have installed the plugin correctly, you should …

RHTE - Supercharge your integration services

Red Hat Tech Exchange has taken place in Vietnam, Ho Chi Minh city two weeks ago, it is a great event held by Red Hat in Asia Pacific Region. It is open to all Red Hat partners who are interested in learning what Red Hat is doing recently, see what the trend of the open source world, basically it is a great event to share your knowledge and experience, to meet other enthusiastic people.

I am very fortunate to talk in this great event, to talk about the things I have been working on and even discuss it with many. Also got lots of great ideas too. So here are the slide.

My first talk was with Thomas Qvarnström about how to handle large size data in JBoss Fuse and how JBoss Data Grid can help in the situation.

Here is the agenda of the talk, we will be talk about this in the up coming webinar on 24th Sept.

Integration often involves storing, retrieving, and transforming data. Using a traditional database in your integration is likely to becomes a bottleneck that is expensive and hard to …

Red Hat JBoss Fuse/A-MQ - Fuse and A-MQ Version 6.3 GA is released!

Fuse and A-MQ 6.3 GA has just went out. Maybe, you would think this is just only a minor version release why should I care? Hold your thoughts on that! Because they have done a lot of improvements and also added many new features into this release.

Besides various bug fixes and making sure Fuse Fabric is much more stable. There are two major change in this version update:

New Tooling in JBoss Developer Studio (JBDS) 9.1 GA. Newer Apache Camel version – Camel v2.17. I was really impressed by the work put in to make developing Camel application much simpler. First is the installation of tooling itself. Now it has a all-in-one installer so you don't need to worry about which plugins you need to check. See the videos below to see the new "Getting Started" of Fuse 6.3.



And If you notice from the above video, the presentation of camel route in JBDS has also updated. It fixed some of the miss representation of logic and making it easier to read.

Old Camel Route
New Camel Route
On …