CDH的大数据服务管理可以通过CM来进行操作,但是并不支持一些开源组件。若想将第三方开源服务添加到CDH上进行管理,则需要根据一系列流程规则来制作相关的parcel包、csd jar包来进行部署。
链接: 自定义CDH parcel
链接: 自定义parcel包在CM中部署
mvn -v #Apache Maven 3.6.3
为了帮助确保构建的parcel,csd是正确的,应该针对parcel和csd运行验证工具cm_ext-master。该工具提供了不同的操作粒度——它可以验证单个 json 文件、parcel 目录或 parcel 文件—因此可以在整个开发过程中使用它。
下载链接:
maven:https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
代码如下(示例):
mkdir /opt/inst
#将文件上传后解压至该目录
tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /opt/inst/
ln -s /opt/inst/apache-maven-3.6.3 /opt/inst/maven363
vi /etc/profile
#配置环境变量文件输入下面这两个内容。输入完成后wq保存
export MAVEN_HOME=/opt/inst/maven363
export PATH=$PATH:$MAVEN_HOME/bin
#对maven的jvm参数进行调整,避免JVM内存溢出
export MAVEN_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=1g"
完事刷新一下环境
source /etc/profile
mvn -v
cd $MAVEN_HOME/conf
vim settings.xml
#提示:按下/可以在文件中进行搜索
1.按下/
2.输入localRepository并回车
将下列代码贴入
/opt/jars
由于/opt/jars目录没有创建,所以要自行创建一下。
mkdir /opt/jars
根据3.1的查找方式,这里输入mirrors
alimaven
central
aliyun maven
https://maven.aliyun.com/repository/central
alimaven
aliyun maven
http://maven.aliyun.com/nexus/content/groups/public/
central
编辑完成后wq退出即可
wget https://codeload.github.com/cloudera/cm_ext/zip/refs/heads/master
cd /home/ftp #这里是你自定义存放文件的位置
unzip cm_ext-master.zip
cd cm_ext-master
mvn install
ll /home/ftp/cm_ext-master/validator/target/validator.jar
自定义parcel包想要在CM中部署,需要一个parcel包和一个CSD包。
如果自定义的parcel包是作为静态资源分发给各服务器使用的,是不需要CSD包的。
CSD包作为parcel包的控制脚本存在。
wget https://archive.apache.org/dist/incubator/kyuubi/kyuubi-1.5.1-incubating/apache-kyuubi-1.5.1-incubating-bin.tgz
parcel包目录结构 parcel包有两部分组成:meta目录和项目目录(这里使用lib)
meta目录是CM管理parcel的关键,如果没有meta,parcel包就只是一个普通的压缩包。
meta可以允许定义五个文件,分别为:
parcel.json,The Parcel Defines Script,The alternatives.json file,The permissions.json file,release-notes.txt。
正常情况下,只需要parcel.json和The Parcel Defines Script就可满足自定义parcel包的全部需求。
mkdir -p KYUUBI-1.5.1/lib
mkdir -p KYUUBI-1.5.1/meta
然后j将下载好的apache-kyuubi-1.5.1-incubating-bin.tgz解压至KYUUBI-1.5.1/lib目录下
tar -zxvf apache-kyuubi-1.5.1-incubating-bin.tgz --strip-components 1 -C KYUUBI-1.5.1/lib/
chmod +x -R KYUUBI-1.5.1/lib/bin
vi KYUUBI-1.5.1/meta/parcel.json
{
"schema_version":1,
"name":"KYUUBI",
"version":"1.5.1",
"setActiveSymlink":true,
"conflicts":"",
"provides":[
"kyuubi"
],
"scripts":{
"defines":"kyuubi_env.sh"
},
"packages":[
{
"name":"kyuubi",
"version":"1.5.1"
}
],
"components":[
{
"name":"kyuubi",
"version":"1.5.1",
"pkg_version":"1.5.1",
"pkg_release":"1.5.1"
}
],
"users":{},
"groups":[ ]
}
vi KYUUBI-1.5.1/meta/kyuubi_env.sh
export KYUUBI_DIRNAME=${KYUUBI_DIRNAME:-"KYUUBI"}
export DEMO_HOME=$PARCELS_ROOT/$KYUUBI_DIRNAME/lib
mkdir parcels
tar -zcvf KYUUBI-1.5.1-el7.parcel KYUUBI-1.5.1 && mv KYUUBI-1.5.1-el7.parcel parcels/
java -jar /home/ftp/cm_ext-master/validator/target/validator.jar -f parcels/KYUUBI-1.5.1-el7.parcel
创建KYUUBI-1.5.1-el7.parcel.sha文件
sha1sum parcels/KYUUBI-1.5.1-el7.parcel |awk '{print$1}' > parcels/KYUUBI-1.5.1-el7.parcel.sha
官方文档:https://link.juejin.cn/?target=https%3A%2F%2Fgithub.com%2Fcloudera%2Fcm_ext%2Fwiki%2FThe-Structure-of-a-CSD
命名规则:[name]-[version].jar
创建descriptor、scripts、images
mkdir -p kyuubi_csd/descriptor && mkdir -p kyuubi_csd/images && mkdir -p kyuubi_csd/scripts
vi kyuubi_csd/descriptor/service.sdl
{
"name": "KYUUBI",
"label": "Kyuubi",
"description": "kyuubi server",
"version": "1.5.1",
"runAs": {
"user": "root",
"group": "root"
},
"parcel": {
"requiredTags": [
"kyuubi"]
},
"compatibility": {
"generation": 1
},
"icon": "images/kyuubi.png",
"parameters": [
{
"name": "HADOOP_CONF_DIR",
"label": "hadoop_conf_dir",
"description": "core-site.xml's location",
"configName": "HADOOP_CONF_DIR",
"required": true,
"configurableInWizard": true,
"type": "string",
"default": "/etc/hadoop/conf"
},{
"name": "JAVA_HOME",
"label": "java_home",
"description": "java环境变量",
"configName": "JAVA_HOME",
"required": true,
"configurableInWizard": true,
"type": "string",
"default": "/usr/java/jdk"
},{
"name": "SPARK_HOME",
"label": "spark_home",
"description": "spark环境变量",
"configName": "SPARK_HOME",
"required": true,
"configurableInWizard": true,
"type": "string",
"default": "/opt/soft/spark"
},{
"name": "kyuubi-defaults",
"label": "kyuubi.defaults",
"description": "kyuubi-defaults.conf",
"configName": "kyuubi-defaults",
"required": true,
"configurableInWizard": true,
"type": "string_array",
"default": [
"spark.master=yarn",
"spark.submit.deployMode=cluster",
"kyuubi.engine.share.level=USER",
"kyuubi.engine.pool.size=3",
"kyuubi.session.engine.idle.timeout=PT10H",
"kyuubi.ha.enabled=true",
"kyuubi.ha.zookeeper.acl.enabled=flase",
"kyuubi.ha.zookeeper.quorum=cdh1,cdh2,cdh3",
"kyuubi.zookeeper.embedded.client.port=2181"
],
"separator":"&"
}
],
"roles": [{
"name": "KYUUBI_SERVER",
"label": "kyuubi Server",
"pluralLabel": "kyuubi Servers",
"startRunner": {
"program": "scripts/control.sh",
"args": ["start"],
"environmentVariables": {
"JAVA_HOME":"${JAVA_HOME}",
"HADOOP_CONF_DIR":"${HADOOP_CONF_DIR}",
"SPARK_HOME":"${SPARK_HOME}",
"kyuubi-defaults":"${kyuubi-defaults}"
}
},"stopRunner": {
"timeout": "40000",
"runner": {
"program": "scripts/control.sh",
"args": [
"stop"
]
}
},
"configWriter": {
"generators": [
{
"filename": "kyuubi-defaults.conf",
"includedParams": [
"kyuubi-defaults"
],
"configFormat": "properties"
},
{
"filename": "kyuubi-env.sh",
"includedParams": [
"JAVA_HOME",
"SPARK_HOME",
"HADOOP_CONF_DIR"
],
"configFormat": "properties"
}
]
},
"logging": {
"dir": "/var/log/kyuubi",
"modifiable": true,
"filename": "kyuubi-server.log",
"loggingType": "log4j"
}
}]
}
vi kyuubi_csd/scripts/control.sh
#!/bin/bash
# Time marker for both stderr and stdout
date; date 1>&2
cmd=$1
timestamp=$(date)
export KYUUBI_HOME=$PARCELS_ROOT/$KYUUBI_DIRNAME/lib
echo $KYUUBI_HOME/bin/kyuubi
KYUUBI_CONF_NAME="kyuubi-defaults"
KYUUBI_LOG_HOME="/var/log/kyuubi/kyuubi-server.log"
KYUUBI_PID_DIR="/tmp"
if [ "start" = "$cmd" ]; then
echo "$timestamp Starting Server"
echo $CONF_DIR
echo $CONF_DIR/${KYUUBI_CONF_NAME}.conf |sed "s/${KYUUBI_CONF_NAME}=//g"|tr "&" "\n" > $PARCELS_ROOT/$KYUUBI_DIRNAME/lib/conf/${KYUUBI_CONF_NAME}.conf
cat $CONF_DIR/${KYUUBI_CONF_NAME}.conf |sed "s/${KYUUBI_CONF_NAME}=//g"|tr "&" "\n" > $PARCELS_ROOT/$KYUUBI_DIRNAME/lib/conf/${KYUUBI_CONF_NAME}.conf
awk '{print "export "$0}' $CONF_DIR/kyuubi-env.sh > $PARCELS_ROOT/$KYUUBI_DIRNAME/lib/conf/kyuubi-env.sh
echo "exec $KYUUBI_HOME/bin/kyuubi "
$KYUUBI_HOME/bin/kyuubi run > $KYUUBI_LOG_HOME
elif [ "stop" = "$cmd" ]; then
echo "$timestamp Stopping Server"
else
echo "$timestamp Don't understand [$cmd]"
fi
验证service.sdl文件
java -jar cm_ext-master/validator/target/validator.jar -s kyuubi_csd/descriptor/service.sdl
cd kyuubi_csd && jar -cvf KYUUBI-1.5.1.jar * && cd ..
分别将步骤五与步骤六中得到的parcel包与csd包传到cm-server下指定目录并且重启cloudera-server
cp parcels/* /opt/cloudera/parcel-repo/ && cp kyuubi_csd/KYUUBI-1.5.1.jar /opt/cloudera/csd/
systemctl restart cloudera-scm-server
在主页面点击 主机>Parcel
点击检查新parcel > 分配 > 激活
激活成功后回到主页添加服务 > 选择kyuubi server > 分配主机
根据实际情况修改配置文件
beeline -u"jdbc:hive2://cdh1:10009" -nhadoop
1.在CM客户端中单击图标parcel按钮
2.点击停用按钮,当此动作完成,此时按钮变为已分配, 已激活
3.点击选择从服务器中移除按钮,当此动作完成,parcel状态变为已下载
4.点击删除按钮,将从cm-server的/opt/cloudera/cloudera-repo中删除该parcel。
5.在cm-sever服务器的/opt/cloudera/csd路径下,删除csd文件jar包。
6.所有的cm-agent服务器中,在/opt/cloudera/parcel-cache路径下,删除服务的.torrent文件(未经核实,不清楚不删可不可以,保证万一,最好删除)。
7.最为重要的,所有的cm-agent服务器中,在/opt/cloudera/cloudera-repo路径下,有一个隐藏文件夹.flood,其中会有parcel包和.torrent文件,一定要删除。否则,如果之后有同名parcel包,分发时不会从server服务器的/opt/cloudera/cloudera-repo路径中下载,而是从本地.flood中获取。从而导致使用的是之前的parcel。
rm -f /opt/cloudera/csd/KYUUBI*
rm -f /opt/clodera/parcel-repo/KYUUBI*
rm -rf /opt/cloudera/parcels/.flood/KYUUBI-1.5.1-el7.parcel*