ambari 自定义组件安装
借鑒:http://www.ibm.com/developerworks/cn/opensource/os-cn-bigdata-ambari3/index.html
Ambari 在啟動的時(shí)候,會掃描 resource 目錄下 Stack 下面的 service 配置。也就是每個(gè) Service 的 metainfo.xml,同時(shí)會將這些配置信息放在自己的數(shù)據(jù)庫中。當(dāng)用戶在 WEB 上面點(diǎn)擊 “Add Service”的時(shí)候,WEB 就會加載這些配置信息到具體的頁面里。在 Service 的 metainfo.xml 中,commandScript 字段就是用來配置 service check 腳本入口。如果一個(gè) Service 的 metainfo.xml 有該字段,那么在 Service 的 Action 列表中就會出現(xiàn)“Run Service Check”這個(gè)命令。對于自定義的 Service,默認(rèn)是沒有這些配置項(xiàng)的。如果一個(gè)自定義的 Service 需要某些必須的參數(shù)時(shí),就必須創(chuàng)建 Service 的配置目錄(configuration)和對應(yīng)的配置文件,讓用戶安裝的時(shí)候輸入。
在ambari的基礎(chǔ)上,我們想要安裝我們自己的軟件,通過查找自己做了一下:
mkdir /var/lib/ambari-server/resources/stacks/HDP/2.4/services/DAXIONG
在/var/lib/ambari-server/resources/stacks/HDP/2.4/services下面有很多service目錄,是ambari自己的安裝軟件組,我們可以自己建一個(gè)目錄,目錄名字最好大寫,我是按照目錄里寫的;在每個(gè)service下的目錄中都有metainfo.xml文件,上述也介紹了,下面是我的metainfo.xml內(nèi)容;
<?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)建一個(gè)目錄?/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界面添加服務(wù)就可以了,這只是一個(gè)簡單是事例,因?yàn)樽罱谧鲞@一方面,所以簡單的測試了一下。中間原來搭建的hbase出現(xiàn)了問題,只需要進(jìn)入所在的機(jī)器(host),開啟沒有開啟的服務(wù)即可。
下面是截圖:
轉(zhuǎn)載于:https://blog.51cto.com/daxionglaiba/1828855
總結(jié)
以上是生活随笔為你收集整理的ambari 自定义组件安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到狗咬是不是生男孩
- 下一篇: android 双向滑动 seekbar