ambari 自定义组件安装
借鑒:http://www.ibm.com/developerworks/cn/opensource/os-cn-bigdata-ambari3/index.html
Ambari 在啟動的時候,會掃描 resource 目錄下 Stack 下面的 service 配置。也就是每個 Service 的 metainfo.xml,同時會將這些配置信息放在自己的數據庫中。當用戶在 WEB 上面點擊 “Add Service”的時候,WEB 就會加載這些配置信息到具體的頁面里。在 Service 的 metainfo.xml 中,commandScript 字段就是用來配置 service check 腳本入口。如果一個 Service 的 metainfo.xml 有該字段,那么在 Service 的 Action 列表中就會出現“Run Service Check”這個命令。對于自定義的 Service,默認是沒有這些配置項的。如果一個自定義的 Service 需要某些必須的參數時,就必須創(chuàng)建 Service 的配置目錄(configuration)和對應的配置文件,讓用戶安裝的時候輸入。
在ambari的基礎上,我們想要安裝我們自己的軟件,通過查找自己做了一下:
mkdir /var/lib/ambari-server/resources/stacks/HDP/2.4/services/DAXIONG
在/var/lib/ambari-server/resources/stacks/HDP/2.4/services下面有很多service目錄,是ambari自己的安裝軟件組,我們可以自己建一個目錄,目錄名字最好大寫,我是按照目錄里寫的;在每個service下的目錄中都有metainfo.xml文件,上述也介紹了,下面是我的metainfo.xml內容;
<?xml version="1.0"?>
<metainfo>
??? <schemaVersion>2.0</schemaVersion>
??? <services>
??????? <service>
??????????? <name>DAXIONG</name>
??????????? <displayName>DAXIONG Service</displayName>
??????????? <comment>A DAXIONG Service</comment>
??????????? <version>1.0</version>
??????????? <components>
??????????????? <component>
??????????????????? <name>DAXIONG_MASTER</name>
??????????????????? <category>MASTER</category>
??????????????????? <cardinality>1</cardinality>
??????????????????? <commandScript>
??????????????????????? <script>scripts/master.py</script>
??????????????????????? <scriptType>PYTHON</scriptType>
??????????????????????? <timeout>600</timeout>
??????????????????? </commandScript>
??????????????? </component>
??????????????? <component>
??????????????????? <name>DAXIONG_SLAVE</name>
??????????????????? <category>SLAVE</category>
??????????????????? <cardinality>1+</cardinality>
??????????????????? <commandScript>
??????????????????????? <script>scripts/slave.py</script>
??????????????????????? <scriptType>PYTHON</scriptType>
??????????????????????? <timeout>600</timeout>
??????????????????? </commandScript>
??????????????? </component>
??????????????? <component>
??????????????????? <name>DAXIONG_CLIENT</name>
??????????????????? <category>CLIENT</category>
??????????????????? <cardinality>1+</cardinality>
??????????????????? <commandScript>
??????????????????????? <script>scripts/client.py</script>
??????????????????????? <scriptType>PYTHON</scriptType>
??????????????????????? <timeout>600</timeout>
??????????????????? </commandScript>
??????????????? </component>
??????????? </components>
??????????? <osSpecifics>
??????????????? <osSpecific>
??????????????????? <osFamily>any</osFamily>
??????????????? </osSpecific>
??????????? </osSpecifics>
??????? </service>
??? </services>
</metainfo>
創(chuàng)建命令腳本. 為命令腳本創(chuàng)建一個目錄?/var/lib/ambari-server/resources/stacks/HDP/2.0.6/services/DAXIONG/package/scripts
[root@master scripts]# ls
master.py? client.py? slave.py
[root@master scripts]# cat master.py
import sys
from resource_management import *
class Master(Script):
? def install(self, env):
??? print 'Install the Sample DAXIONG Master';
? def stop(self, env):
??? print 'Stop the Sample DAXIONG Master';
? def start(self, env):
??? print 'Start the Sample DAXIONG Master';
? def status(self, env):
??? print 'Status of the Sample DAXIONG Master';
? def configure(self, env):
??? print 'Configure the Sample DAXIONG Master';
if __name__ == "__main__":
? Master().execute()
[root@master scripts]# cat client.py
import sys
from resource_management import *
class Slave(Script):
? def install(self, env):
??? print 'Install the Sample DAXIONG Slave';
? def stop(self, env):
??? print 'Stop the Sample DAXIONG Slave';
? def start(self, env):
??? print 'Start the Sample DAXIONG Slave';
? def status(self, env):
??? print 'Status of the Sample DAXIONG Slave';
? def configure(self, env):
??? print 'Configure the Sample DAXIONG Slave';
if __name__ == "__main__":
? Slave().execute()
[root@master scripts]# cat slave.py
import sys
from resource_management import *
class SampleClient(Script):
? def install(self, env):
??? print 'Install the Sample DAXIONG Client';
? def configure(self, env):
??? print 'Configure the Sample DAXIONG Client';
if __name__ == "__main__":
? SampleClient().execute()
上面的配置完后需要重新啟動ambari,然后在web界面添加服務就可以了,這只是一個簡單是事例,因為最近在做這一方面,所以簡單的測試了一下。中間原來搭建的hbase出現了問題,只需要進入所在的機器(host),開啟沒有開啟的服務即可。
下面是截圖:
轉載于:https://blog.51cto.com/daxionglaiba/1828855
總結
以上是生活随笔為你收集整理的ambari 自定义组件安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到狗咬是不是生男孩
- 下一篇: 梦到蝙蝠是什么预兆