让karaf随ubuntu开机启动

前端之家收集整理的这篇文章主要介绍了让karaf随ubuntu开机启动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

最近帮助一个客户部署了一个Apache Servicemix环境。
客户提出,能不能让Servicemix开机启动。这样,如果机器出现了什么问题,重启一下就好了。不需要让运维人员知道如何操作Servicemix。
当然可以。需求合理,没有拒绝的理由。

但是实际操作的时候,试过在init.d目录下加脚本,在rc.local中加命令行。在网上也找了好几个方法,均告失败,也没看到任何错误。原以为设置个开机启动,和玩似的,结果被机器玩了。

不过,功夫不负有心人,终于还是找到了办法。

因为servicemix其实就是一个开源大礼包,把几个apache的开源软件组装在一起拼凑而成。运行时环境是Karaf。所以,第一眼在karaf下看到官方的开机启动方案时,眼前一亮。觉得这个方法应该可行。结果一试,果然可以。

操作步骤也非常简单,摘抄如下(不过,还是去官网看一下更靠谱,网址:https://karaf.apache.org/manu...):

  1. Installation
  2. Apache Karaf Service Wrapper is an optional feature. You have to install the "Service Wrapper" installer first.
  3.  
  4. In the console:
  5.  
  6. karaf@root()> feature:install service-wrapper
  7. Now,you have the wrapper:install command,to "register" Apache Karaf as service/daemon on your system:
  8.  
  9. karaf@root()> wrapper:install --help
  10. DESCRIPTION
  11. wrapper:install
  12.  
  13. Install the container as a system service in the OS.
  14.  
  15. Syntax
  16. wrapper:install [options]
  17.  
  18. OPTIONS
  19. -d,--display
  20. The display name of the service.
  21. (defaults to karaf)
  22. --help
  23. Display this help message
  24. -s,--start-type
  25. Mode in which the service is installed. AUTO_START or DEMAND_START (Default: AUTO_START)
  26. (defaults to AUTO_START)
  27. -n,--name
  28. The service name that will be used when installing the service. (Default: karaf)
  29. (defaults to karaf)
  30. -D,--description
  31. The description of the service.
  32. (defaults to )
  33. The wrapper:install command detects the running Operating Service and provide the service/daemon ready to be integrated in your system.
  34.  
  35. For instance,on a Ubuntu/Debian Linux system:
  36.  
  37. karaf@root()> wrapper:install
  38. Creating file: /opt/apache-karaf-4.0.0/bin/karaf-wrapper
  39. Creating file: /opt/apache-karaf-4.0.0/bin/karaf-service
  40. Creating file: /opt/apache-karaf-4.0.0/etc/karaf-wrapper.conf
  41. Creating missing directory: /opt/apache-karaf-4.0.0/lib/wrapper
  42. Creating file: /opt/apache-karaf-4.0.0/lib/wrapper/libwrapper.so
  43. Creating file: /opt/apache-karaf-4.0.0/lib/wrapper/karaf-wrapper.jar
  44. Creating file: /opt/apache-karaf-4.0.0/lib/wrapper/karaf-wrapper-main.jar
  45.  
  46. Setup complete. You may wish to tweak the JVM properties in the wrapper configuration file:
  47. /opt/apache-karaf-4.0.0/etc/karaf-wrapper.conf
  48. before installing and starting the service.
  49.  
  50.  
  51. Ubuntu/Debian Linux system detected:
  52. To install the service:
  53. $ ln -s /opt/apache-karaf-4.0.0/bin/karaf-service /etc/init.d/
  54.  
  55. To start the service when the machine is rebooted:
  56. $ update-rc.d karaf-service defaults
  57.  
  58. To disable starting the service when the machine is rebooted:
  59. $ update-rc.d -f karaf-service remove
  60.  
  61. To start the service:
  62. $ /etc/init.d/karaf-service start
  63.  
  64. To stop the service:
  65. $ /etc/init.d/karaf-service stop
  66.  
  67. To uninstall the service :
  68. $ rm /etc/init.d/karaf-service

猜你在找的Ubuntu相关文章