Skip to main content

Red Hat JBoss Fuse/A-MQ - Fabric 建立與設定。

因為一些關係,這幾天花了一些些時間看JBoss Fuse, 然後那個Data Grid 只好往後延了~科科 (現在排隊的TODO 清單實在是太多了..,有人要來幫我的忙嗎?不然我都沒空去逛街,都快變成黃臉婆了.. )!

基本上Fuse 的架構病不複雜,Fuse 的底層並不是大家熟悉的EE, JBoss Fuse 基本上就是等於一個ESB. JBoss Fuse 為了最輕量化,所以底層使用OSGI 模組化的Container,而不是Java EE 這種大的,整包的Container.

Fuse 的架構比較特別的是它上面有個叫做Fabric的元件。特別對它研究了一下。 之後再慢慢補上Camel 還有 A-MQ 的部分。

Fabric 是啥鬼?Fabric 是拿來管理用的。所以也適用A-MQ. 根據定義,這時,首先到腦子裡的,就是為啥要管理,有什麼好管理的呢?在Fuse 上,你可以啓動Camel 和 A-MQ 的instance, 想當然爾,就會有很多"設定",因為Fabric 統一管理了上面的設定,所以它就可以幫助橫向擴展的部署你的Fuse 或是 A-MQ 的Container(容器)了,像是遠端安裝,開啓,分配Container(容器) 的設定,負載平衡(Load balance),容錯(Failover)甚至可以讓你做到程式版本上線rollout. 所以一個Fabric就是一個管理範圍的定義。



以上的設定,就以註冊的方式被納入管理,Fabric 是透過Apache 的ZooKeeper 做到可以再分散的環境記錄所有叢集跟分散的設定內容,讓你可以橫跨網路去部署跟建置整個環境。它在Fuse 與 A-MQ 裡面就叫做Registry.



以上講的註冊只是儲存資料內容,那由誰去負責提供這些資料出去給整個Fabric 管理範圍裡面的Container 容器呢?就是 Fabric 伺服器 (server) ,每個Fabric 伺服器都有自己獨立的一套註冊的內容,他們之間會自動互相的同步修改的內容,一個Fabric 管理範圍,通常Fabric 伺服器都是要單數的,因為Fabric 計算是用 quorum-based 的計算公式方式。通常在一個正式環境,Fabric server 的數量最少最少都要三台來備援。


以上所有的設定啊,管理什麼的,都是為了真正可執行的程式來準備的,而真正跑這些應用程式的環境,就叫做 Fabric 容器(被管理容器) 。 它上面可以裝A-MQ 的Broker, ESB 啊等等的。每一個 Fabric 容器都是一個獨立的JVM.

那應用程式要怎麼樣部署在Container 上面呢??!!會透過Fuse Fabric 這個特別的管理機制,我想啦~(不負責任中..)~是為了配合OSGi 的關係,因為OSGi 是把應用程式與應用程式之間的關係,變成Bundle, 透過設定把互相的依賴性建立起來。不像早期寫程式的時候,一般使用者會不管3721的把認識的不認識的Lib jar 全部一股腦放進來 (這台灣許多專案非常常見。。。。)OSGi 的概念有點像是模組化,要執行的時候就會把需要的程式讀取進來。所以要部署在OSGi 這個容器上,部署就像疊樂高一樣。同樣的,因為我們的底層是Karaf ,所以一樣有許多Feature, 這也像是樂高的其中一個積木吧。(只是讀取,設定的方式不同。)把需要用到的Bundle ,Feature 還有依賴的程式疊一疊,放在Fabric 的Container 上就可以跑了。 去定義樂高積木般會用到的Bundle, Feature還有程式等等,就叫做Profile。至於Feature 怎麼樣去設定,以後有機會再寫。(Fuse 內建已經有幾個Feature 與Profile 了。) 重要的是,Profile 也可以去繼承某個Profile。


好啦~講了阿裡阿咂,一大堆,我相信看到這裡應該頭都暈了吧.. 先來實作個Fabric 的小環境吧。

這次我想要做的事是這樣滴~:


  1. 建立一個Fabric 的管理環境,一台Fabric 伺服器。
  2. 建立三個Fabric 容器
    • mgtConsole - 安裝網頁的GUI 管理畫面
    • child1- 安裝A-MQ環境
    • child2 - 安裝有 JMS 的 Camel環境
  3. 把child1 與 child2 加入Fabric 管理環境中。

如下圖:




1. 廢話不多說,請先去下載JBoss Fuse 6.0 (6.1 現在正在Beta, 聽說他有更好的網路管理畫面,hawtio, 請期待我的分享。) 老樣子,請解壓縮到電腦裡面的某目錄。



2. 把使用者與密碼設定上去,請到$FUSE/etc/users.properties 在裡面新增一個admin 的使用者,
USER=PASSWORD,ROLE1,ROLE2,...
最簡單就是把 #admin=admin,admin 這段的#拿掉。然後儲存。


3. 啓動FUSE, 到$FUSE/bin/ 下,執行 fuse, 或是 fuse.bat (如果你是windows環境)


4. 定義一個Fabric 管理環境,

JBossFuse:karaf@root> fabric:create --zookeeper-password admin
Using specified zookeeper password:admin
5. 建立一個叫做mgtConsole 的Fabric 容器,
JBossFuse:karaf@root> fabric:container-create-child root mgtConsole
The following containers have been created successfully:
Container: mgtConsole.

容器裡面放fmc 內建的Profile, 這個Profile 就是Web GUI 界面。
JBossFuse:karaf@root> fabric:container-add-profile mgtConsole fmc

Web GUI 的界面需要定義一個Port 給它。
JBossFuse:karaf@root> fabric:profile-edit -p org.ops4j.pax.web/org.osgi.service.http.port=8182 fmc

幫這個容器安裝Fabric Agent feature,所以Fabric 伺服器才可以透過Agent 設定,分配安裝。
JBossFuse:karaf@root> fabric:profile-edit --features fabric-agent/0.0.0 fmc

把fmc Profile 的明細印出來看一下。
JBossFuse:karaf@root> fabric:profile-display fmc
Profile id: fmc
Version   : 1.0
Attributes: 
parents: default
Containers: mgtConsole

Container settings
----------------------------
Repositories : 
mvn:org.apache.karaf.assemblies.features/enterprise/2.3.0.redhat-60024/xml/features
mvn:org.apache.karaf.assemblies.features/standard/2.3.0.redhat-60024/xml/features
mvn:org.fusesource.fabric/fuse-fabric/7.2.0.redhat-024/xml/features
mvn:org.jclouds.karaf/jclouds-karaf/1.5.7/xml/features

Features : 
fabric-webui
fabric-jclouds
war
fabric-agent/0.0.0
fabric-rest


Configuration details
----------------------------
PID: org.ops4j.pax.web
  org.osgi.service.http.port 8182


Configuration details
----------------------------
PID: org.ops4j.pax.web
  org.osgi.service.http.port 8281

重新啓動mgtConsole 容器。
JBossFuse:karaf@root> fabric:container-stop mgtConsole 
JBossFuse:karaf@root> fabric:container-start mgtConsole 

在瀏覽器中,去 http://localhost 8182, 請用admin/admin 登入。


這時你可以看到裡面有兩個建好的Containers 。


5. 建立child1 與 child2 的Fabric 容器, 輸入Fabric 的 ID與密碼, admin/admin.

JBossFuse:karaf@root> fabric:container-create-child root child1
Jmx Login for root: admin
Jmx Password for root: 
The following containers have been created successfully:
Container: child1.
JBossFuse:karaf@root> fabric:container-create-child root child2
The following containers have been created successfully:
Container: child2.

印出Fabric 管理範圍內的容器。
JBossFuse:karaf@root> fabric:container-list 
[id]                           [version] [alive] [profiles]                     [provision status]
root*                          1.0       true    fabric, fabric-ensemble-0000-1, jboss-fuse-full success
  mgtConsole                   1.0       true    fmc, default                   success
  child1                       1.0       true    default                        success
  child2                       1.0       true    default                        success
  
6. 建立兩個Profile, 一個繼承A-MQ, 一個繼承有JMS 的 Camel.

JBossFuse:karaf@root> fabric:profile-create --parents a-mq  myAMQ
JBossFuse:karaf@root> fabric:profile-create --parents camel-jms  myCamel

一樣幫兩個容器安裝Fabric Agent feature
JBossFuse:karaf@root> fabric:profile-edit --features fabric-agent/0.0.0 myAMQ 
JBossFuse:karaf@root> fabric:profile-edit --features fabric-agent/0.0.0 myCamel 

在兩個容器裡,分別安裝剛剛建的兩個Profile
JBossFuse:karaf@root> fabric:container-add-profile child1 myAMQ 
JBossFuse:karaf@root> fabric:container-add-profile child2 myCamel 

印出Fabric 管理範圍內的容器跟內容。
JBossFuse:karaf@root> fabric:container-list 
[id]                           [version] [alive] [profiles]                     [provision status]
root*                          1.0       true    fabric, fabric-ensemble-0000-1, jboss-fuse-full success
  mgtConsole                   1.0       true    fmc, default                   success
  child1                       1.0       true    myAMQ, default                 finalizing
  child2                       1.0       true    myCamel, default               success

7. 最後一步,把兩個容器,child1 還有 child2 加入這個Fabric 管理環境內。
JBossFuse:karaf@root> fabric:join --zookeeper-password admin localhost child1
You are about to change the container name. This action will restart the container.
The local shell will automatically restart, but ssh connections will be terminated.
The container will automatically join: localhost the cluster after it restarts.
Do you wish to proceed (yes/no):
JBossFuse:karaf@root> fabric:join --zookeeper-password admin localhost child2
A container with the name: child1 is already member of the cluster. You can specify a different name as an argument.You are about to change the container name. This action will restart the container.
The local shell will automatically restart, but ssh connections will be terminated.
The container will automatically join: localhost the cluster after it restarts.
Do you wish to proceed (yes/no):

JBossFuse:karaf@root> config:edit org.fusesource.fabric.zookeeper
JBossFuse:karaf@root> config:proplist
   service.pid = org.fusesource.fabric.zookeeper
   zookeeper.password = admin
   zookeeper.url = ChristinatekiMacBook-Air.local:2181
   fabric.zookeeper.pid = org.fusesource.fabric.zookeeper
JBossFuse:karaf@root> config:cancel

管理畫面大概是這樣。有四個Container, 其中每個Profile 安裝的 feature.



以上,設定完成了,如果有興趣玩得更深,請參考原廠文件囉~:原廠文件

Comments

littlehoi said…
nice, amqp 有心跳等, 連結硬件,是不是一定要有運行OS, client等?

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 …

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 …

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 …