0. FuseESB作为系统服务
(1) Generating a Service Wrapper
首先安装Wrapper Profile:
FuseESB:karaf@root> features:install wrapper
验证安装结果:
FuseESB:karaf@root> wrapper:install --help
生成Service Wrapper:
FuseESB:karaf@root> wrapper -n FuseESB -D FuseESB -D "Fuse ESB Route Container"
系统日志:
Creating file: /usr/customize/fuse-esb-7.0.0.fuse-061/bin/FuseESB-wrapper Creating file: /usr/customize/fuse-esb-7.0.0.fuse-061/bin/FuseESB-service Creating file: /usr/customize/fuse-esb-7.0.0.fuse-061/etc/FuseESB-wrapper.conf Creating file: /usr/customize/fuse-esb-7.0.0.fuse-061/lib/libwrapper.so Creating file: /usr/customize/fuse-esb-7.0.0.fuse-061/lib/karaf-wrapper.jar Creating file: /usr/customize/fuse-esb-7.0.0.fuse-061/lib/karaf-wrapper-main.jar Setup complete. You may wish to tweak the JVM properties in the wrapper configuration file: /usr/customize/fuse-esb-7.0.0.fuse-061/etc/FuseESB-wrapper.conf before installing and starting the service. The way the service is installed depends upon your flavor of Linux. On Redhat/Fedora/CentOS Systems: To install the service: $ ln -s /usr/customize/fuse-esb-7.0.0.fuse-061/bin/FuseESB-service /etc/init.d/ $ chkconfig FuseESB-service --add To start the service when the machine is rebooted: $ chkconfig FuseESB-service on To disable starting the service when the machine is rebooted: $ chkconfig FuseESB-service off To start the service: $ service FuseESB-service start To stop the service: $ service FuseESB-service stop To uninstall the service : $ chkconfig FuseESB-service --del $ rm /etc/init.d/FuseESB-service On Ubuntu/Debian Systems: To install the service: $ ln -s /usr/customize/fuse-esb-7.0.0.fuse-061/bin/FuseESB-service /etc/init.d/ To start the service when the machine is rebooted: $ update-rc.d FuseESB-service defaults To disable starting the service when the machine is rebooted: $ update-rc.d -f FuseESB-service remove To start the service: $ /etc/init.d/FuseESB-service start To stop the service: $ /etc/init.d/FuseESB-service stop To uninstall the service : $ rm /etc/init.d/FuseESB-service
(2) Configuring a Aservice Wrapper
配置文件位于:/usr/customize/fuse-esb-7.0.0.fuse-061/etc/FuseESB-wrapper.conf.
(3) Install and Start Service
参照上述生成服务时系统生成的日志进行安装。
1. FuseESB启动关闭:
参考:http://springsfeng.iteye.com/admin/blogs/1386565
2. 配置FuseESB远程实例
在InstallDir/etc/org.apache.karaf.shell.cfg 文件中配置sshPort和sshHost指定可被远程访问的主机和端口,
如:
sshPort=8101
sshHost=192.168.1.101
3. 连接远程Instance
(1) 使用ssh:ssh语法连接:ssh:ssh {-l username} {-P password} {-p port} { hostname },如:
karaf@root>ssh:ssh -l smx -P smx -p 8101 192.168.1.101
默认用户名密码是:smx/smx
(2) 关闭远程连接:
执行命令:logout或Ctrl+d
(3) 确认远程连接成功
执行命令:shell:info ,输出结果:
Karaf
Karaf version 2.2.5.fuse-7-061
Karaf home /usr/customize/fuse-esb-7.0.0.fuse-061
Karaf base /usr/customize/fuse-esb-7.0.0.fuse-061
OSGi Framework org.apache.felix.framework - 4.0.3.fuse-7-061
JVM
Java Virtual Machine Java HotSpot(TM) Server VM version 20.0-b11
Version 1.6.0_25
Vendor Sun Microsystems Inc.
Uptime 6 minutes
......
(4) 使用fabric:container-connect命令链接
fabric:container-connect {-u username} {-p password} {containerName},例如:
karaf@root>fabric:container-connect -u admin -p admin containerName
默认用户名密码是:admin/admin
关闭远程连接:
执行命令:logout或Ctrl+d
4. 使用命令行连接本地或远程Instance
使用InstallDir/bin目录下的client命令,例如:
(1) 若本机启动在server模式下,使用下面的命令连接:
fdc@FDC:/usr/customize/fuse-esb-7.0.0.fuse-061/bin$ ./client -u smx -p smx
针对Standalone Container: 账户密码是:smx/smx;
针对Fabric Container:账户密码是:admin/admin.
(2) 查看client 参数信息:
./client --help
5. 关闭远程Instance
(1)使用stop script:stop [-a port] {-h hostname} {-u username} {-p password}
针对Standalone Container: 账户密码是:smx/smx;
针对Fabric Container:账户密码是:admin/admin.
(2) 使用fabric:container-stop控制台命令,比如关闭容器child1:karaf@root> fabric:container-stop child1
(3) 如果是连接至远程控制台,使用osgi:shutdown关闭,而如果在远程控制台中执行Ctrl+d则只会关闭远
程链接。
6. 管理Child Instance
(1) Child Instances—Standalone
创建Child Instance:
FuseESB:karaf@root> admin:create esbone
Creating new instance on SSH port 8102 and RMI ports 1100/44445 at: /usr/customize/fuse-esb-7.0.0.
fuse-061/instances/esbone
说明:系统将在当前运行的环境中的instances/instanceName目录下创建esbone实例,并修改:
instance.properties文件。
1. 改变Child nstance 的端口(Child Instance需在Stop状态下):
admin:change-port {instanceName} {portNumber}
2. 启动Child instance:
admin:start instanceName
3. 显示系统中当前左右的Child nstance:admin:list
4. 连接至一个Child instance:
admin:connect { instanceName } {-u username} {-p password}
默认的账户密码:smx/smx
5. 停止Child instance:
admin:stop instanceName
6. 销毁Child instance:
admin:destroy instanceName
7. 使用InstallDir/bin下的admin脚本:
功能与Console中的命令类似,显示系统中所有的ESB Instance :
./admin list
(2) Child Instances—Fabric
创建Child Instance:karaf@root> fabric:container-create-child parent child [number]
说明:parnet:是当前fabric中的容器的名字,child是新创建的子容器的名字,而number是指一次可以创建
多个子实例,如:
karaf@root> fabric:container-create-child root child 2
The following containers have been created successfully:
child1
child2
1. 显示所有的container instances:
karaf@root> fabric:container-list
2. Assigning a profile to a child instance: 例如分配example-camel给child1:
karaf@root> fabric:container-change-profile child1 example-camel
3. Connecting to a child instance:
karaf@root> fabric:container-connect -u admin -p admin child1
4. Start 一个Child Instance
karaf@root> fabric:container-start child1
该命令将启动Child Instanve 在一个单独的JVM中,与父容器的JVM是分开的。
5. Stopping a child instance
karaf@root> fabric:container-stop child1
6. Destroying a child instance
首先执行Child Inatcen 所在主机的JVM,在执行:
karaf@root> fabric:container-delete child1