ambari集成starrocks
ambari集成starrocks
创建服务目录
cd /var/lib/ambari-server/resources/stacks/HDP/3.1/services/ mkdir SERVERNAME # 服务名称目录必须大写
整体目录结构
. ├── configuration │ └── starrocks-site.xml ├── metainfo.xml ├── package # 存放操作脚本 │ └── scripts │ ├── client.py │ ├── master.py │ └── slave.py └── quicklinks # 添加ui链接 └── quicklinks.json
编写服务元描述信息
metainfo.xml
服务元描述信息,可以在文件中对服务的版本,组建,执行脚本,适用操作系统,服务间依赖关系,安装包名等进行配置。Metainfo.xml 的编写需要对它的标签进行了解。具体后续可参考添加服务中 DEMO 的metainfo 编写
<?xml version="1.0" encoding="utf-8"?> <metainfo> <schemaVersion>2.0</schemaVersion> <services> <service> <name>StarRocks</name> <displayName>StarRocks</displayName> <comment>starrocks</comment> <version>3.1.2</version> <!-- <quickLinksConfigurations-dir>quicklinks-es</quickLinksConfigurations-dir> --> <!-- 添加服务链接 --> <quickLinksConfigurations> <quickLinksConfiguration> <fileName>quicklinks.json</fileName> <default>true</default> </quickLinksConfiguration> </quickLinksConfigurations> <components> <!-- 添加服务组件 --> <component> <name>STARROCKS_MASTER</name> <displayName>StarRocks Master</displayName> <category>MASTER</category> <cardinality>1+</cardinality> <commandScript> <script>scripts/master.py</script> <scriptType>PYTHON</scriptType> <timeout>600</timeout> </commandScript> </component> <component> <name>STARROCKS_SLAVE</name> <displayName>StarRocks Slave</displayName> <category>SLAVE</category> <cardinality>1+</cardinality> <commandScript> <script>scripts/slave.py</script> <scriptType>PYTHON</scriptType> <timeout>600</timeout> </commandScript> </component> </components> </service> </services> </metainfo>
package
存放服务相关脚本模版等。Package 下面又分为 files, scripts, templates 三个文件夹。其中 scripts 主要存放脚本。也就是 metainfo.xml中用户配置的模块起停命令执行脚本。Files 存放服务需要的其它文件,例如 sh,py 都可以。Templates 存放服务模版信息。Ambari 部署服务时会调用脚本根据用户编写的模版信息生成对应配置文件。提供给服务、告警服务、监控服务使用。
master脚本
master.py
# -*- coding: utf-8 -*- import sys import os import commands from resource_management import * class Master(Script): def install(self, env): self.install_packages(env) def start(self, env): print 'start the starrocks'; val= os.system("/usr/hdp/3.1.5.0-152/starRocks-3.1.2/fe/bin/start_fe.sh --daemon") print val def configure(self, env): print 'Configure the config client'; def stop(self, env): print 'Stop the starrocks'; val= os.system("/usr/hdp/3.1.5.0-152/starRocks-3.1.2/fe/bin/stop_fe.sh --daemon") print val def status(self, env): try: return_code, output = commands.getstatusoutput("ps -ef|grep starRocks | grep -v grep | awk '{print $2}'") if return_code == 0 and output != '': print 'starRocks status online'; else: print 'ERROR, starRocks status is fail。return code:', return_code, 'pid:', output; sys.exit(4) except ValueError as e: print 'check pid is :', output print e sys.exit(4) if __name__=="__main__": Master().execute()
slave脚本
slave.py
# -*- coding: utf-8 -*- import sys import os import commands from resource_management import * class Slave(Script): def install(self, env): self.install_packages(env) def start(self, env): print 'start the starrocks'; val= os.system("/usr/hdp/3.1.5.0-152/starRocks-3.1.2/be/bin/start_be.sh --daemon") print val def configure(self, env): print 'Configure the config client'; def stop(self, env): print 'Stop the starrocks'; val= os.system("/usr/hdp/3.1.5.0-152/starRocks-3.1.2/be/bin/stop_be.sh --daemon") print val def status(self, env): try: return_code, output = commands.getstatusoutput("ps -ef|grep starRocks | grep -v grep | awk '{print $2}'") if return_code == 0 and output != '': print 'starRocks status online'; else: print 'ERROR, starRocks status is fail。return code:', return_code, 'pid:', output; sys.exit(4) except ValueError as e: print 'check pid is :', output print e sys.exit(4) if __name__=="__main__": Slave().execute()
configureation
服务配置文件存放路径。用户配置文件需要固定放到这个目录下。并且如果用户想在界面对配置文件进行操作,那么配置文件必须满足 ambari 要求的格式。也就是 xml,并且具备固定标签。例如:
starrocks-site.xml
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>starrocks</name> <description>This is a starrocks</description> </property> </configuration>
quicklinks 快速链接添加
首先,quicklinks 快速链接功能,需要在 metainfo.xml 中注册,也就是添加相关配置。
<!-- <quickLinksConfigurations-dir>quicklinks-es</quickLinksConfigurations-dir> --> <quickLinksConfigurations> <quickLinksConfiguration> <fileName>quicklinks.json</fileName> <default>true</default> </quickLinksConfiguration> </quickLinksConfigurations>
其中,quicklinks.json 所在位置,默认在服务根目录的 quicklinks 目录下。如果需要更改 quicklinks.json 文件的所在目录,则需要更改 metainfo.xml 文件的 quickLinksConfigurations-dir 属性值。
quicklinks.json 文件
{ "name": "default", # 默认 "description": "default quick links configuration", # 默认 "configuration": { "protocol": { "type": "http" #可使用https }, "links": [ { "name": "starRocks_ui", "label": "starRocks_ui", "requires_user_name": "false", #是否使用用户验证 "component_name": "STARROCKS_MASTER", #component_name 必须是正确的,组件名称是在 metainfo.xml 中指定的,否则在页面中不显示 Quick Links "url": "%@://%@:%@", "port": { "http_property": "StarRocks.port", "http_default_port": "8060" } } ] } }
重启ambir
systemctl restart ambari-server.service
分类:
bigdata
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通