Apache Kyuubi (Incubating),一个分布式和多租户网关,用于在 Lakehouse 上提供无服务器 SQL。本文为kyuubi入门文章,介绍了Kyuubi基本安装与使用,并以Spark引擎为例讲述如何提交第一个Spark SQL任务。
您还可以阅读文章《Kyuubi 与 Spark ThriftServer 的全面对比分析》了解Kyuubi与Spark ThriftServer的异同点。
安装包下载
进入如下页面下载kyuubi安装包:https://kyuubi.apache.org/releases.html,下面以1.5.0-incubating版本为例。
mkdir /data && cd /data
wget https://dlcdn.apache.org/incubator/kyuubi/kyuubi-1.5.0-incubating/apache-kyuubi-1.5.0-incubating-bin.tgz
tar zxvf apache-kyuubi-1.5.0-incubating-bin.tgz
ln -s apache-kyuubi-1.5.0-incubating-bin kyuubi
由于我们这边使用的是spark引擎,所以还需要下载spark安装包
cd /data
wget https://www.apache.org/dyn/closer.lua/spark/spark-3.2.1/spark-3.2.1-bin-hadoop3.2.tgz
tar zxvf spark-3.2.1-bin-hadoop3.2.tgz
ln -s spark-3.2.1-bin-hadoop3.2 spark
修改配置文件
cd conf
cp spark-env.sh.template spark-env.sh
vim spark-env.sh
## 设置HADOOP_CONF_DIR
export HADOOP_CONF_DIR=/etc/hadoop/conf
测试spark任务是否能提交到yarn上
bin/spark-submit --master yarn --class org.apache.spark.examples.SparkPi ./examples/jars/spark-examples_2.12-3.2.1.jar
得到如下结果
配置文件修改
修改配置文件
cd /data/kyuubi
cd conf
cp kyuubi-defaults.conf.template kyuubi-defaults.conf
cp kyuubi-env.sh.template kyuubi-env.sh
cp log4j2.properties.template log4j2.properties
上述文件各项配置参数可参考:https://kyuubi.apache.org/docs/latest/deployment/settings.html
下面以HDP 3.1.4为例
kyuubi-env.sh内容如下
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64
export SPARK_HOME=/data/spark
export HADOOP_CONF_DIR=/etc/hadoop/conf
export KYUUBI_JAVA_OPTS="-Xmx6g -XX:+UnlockDiagnosticVMOptions -XX:ParGCCardsPerStrideChunk=4096 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSInitiatingOccupancyOnly -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:+UseCondCardMark -XX:MaxDirectMemorySize=1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./logs -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -Xloggc:./logs/kyuubi-server-gc-%t.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=5M -XX:NewRatio=3 -XX:MetaspaceSize=512m"
export KYUUBI_BEELINE_OPTS="-Xmx2g -XX:+UnlockDiagnosticVMOptions -XX:ParGCCardsPerStrideChunk=4096 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSInitiatingOccupancyOnly -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:+UseCondCardMark"
kyuubi-defaults.conf内容如下
kyuubi.ha.zookeeper.quorum hadoop1:2181,hadoop2:2181,hadoop3:2181
spark.master yarn
log4j2.properties文件可不修改
启动kyuubi
bin/kyuubi start
可以看到kyuubi已经启动
使用beeline连接kyuubi
bin/beeline -u "jdbc:hive2://hadoop1:2181,hadoop2:2181,hadoop3:2181/default;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi" -n hdfs
得到
查看YARN UI
提交测试任务
本文为从大数据到人工智能博主「xiaozhch5」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://lrting.top/backend/bigdata/kyuubi/4388/
从安装软件到配置文件修改最后到启动程序,博主写的都很详细清楚,亲测可用