前言
本篇为大家带来Zeppelin连接常用大数据组件的配置方式。
环境信息
- Zeppelin 0.12.0
- Flink 1.17.2
- Spark 3.3.2
- Hive 3.1.0
sh
sh即shell解释器,可以在Zeppelin中通过shell操作主机。
非Kerberos模式无需特殊配置。
Kerberos
需要配置如下3个参数:
- zeppelin.shell.auth.type: KERBEROS
- zeppelin.shell.keytab.location: /path/to/user.keytab
- zeppelin.shell.principal: user@PAULTECH
sh解释器在启动的时候会自动kinit配置的principal。接下来再执行需要认证的操作时能够畅通无阻。
HDFS
使用File连接器,通过文件操作命令(hdfs dfs {命令})来操作HDFS。
配置参数:
- hdfs.url:webhdfs的URL。例如:
http://hdfs_namenode_hostname:50070/webhdfs/v1/ - hdfs.user:操作HDFS的用户。
- hdfs.maxlength:获取结果最多的行数
配置好之后可在notebook中运行HDFS文件操作命令。例如ls /等。
Kerberos
经测试无法直接使用,建议使用sh解释器。
参考链接:Apache Zeppelin 0.12.0 Documentation: HDFS File System Interpreter for Apache Zeppelin
HBase
可在解释器内直接执行hbase shell命令。
配置参数:
- hbase.home:HBase的安装路径。
Kerberos
建议使用sh解释器。
Spark
需要注意的是,连接JDK8版本的Spark 3.x使用,由于Zeppelin 0.12.0官方默使用JDK11编译,配置spark.submit.deployMode为client运行时出现以下错误:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
解决方法为使用JDK 1.8重新编译部署Zeppelin。
如果使用Hudi(例如0.15.0版本),$SPARK_HOME/jars需要加入:
- hudi-spark3.3-bundle_2.12-0.15.0.jar
Interpreter配置项:
- SPARK_HOME
- spark.master: yarn
- spark.submit.deployMode: client
Kerberos
除了Zeppelin本身的Kerberos(zeppelin.server.kerberos.keytab和zeppelin.server.kerberos.principal,在zeppelin-site.xml中)之外,无需其他配置。
Flink
下面以连接Flink 1.17.2为例。
$FLINK_HOME/lib不可缺少依赖为:
- flink-table-api-scala-bridge_2.12-1.17.2.jar
- flink-sql-client-1.17.2.jar
- hadoop-common-3.1.1.3.0.1.0-187.jar
- hadoop-mapreduce-client-common-3.1.1.3.0.1.0-187.jar
- hadoop-mapreduce-client-core-3.1.1.3.0.1.0-187.jar
- hadoop-mapreduce-client-jobclient-3.1.1.3.0.1.0-187.jar
flink-sql-client-1.17.2.jar可以从FLINK_HOME/opt目录复制,flink-table-api-scala-bridge_2.12-1.17.2.jar需要从Maven仓库下载。
如果使用Hudi(例如0.15.0),$FLINK_HOME/lib需要加入:
- hudi-flink1.17-bundle-0.15.0.jar
Flink Interpreter配置项:
-
FLINK_HOME:Flink安装目录 -
HADOOP_CONF_DIR:Hadoop配置文件目录,即包含hdfs-site.xml和core-site.xml配置文件的目录。 -
HIVE_CONF_DIR:Hive配置文件目录,即包含hive-site.xml的目录。 - flink.execution.mode: yarn
Kerberos
除了Zeppelin本身的Kerberos(zeppelin.server.kerberos.keytab和zeppelin.server.kerberos.principal,在zeppelin-site.xml中)之外,无需其他配置。
flink-cmd
该解释器可直接运行flink命令,即只需要提供传统shell中flink命令之后的参数。
使用之前需要在$ZEPPELIN_HOME/conf/zeppelin-env.sh加入:
export HADOOP_CLASSPATH=`hadoop classpath`
在$ZEPPELIN_HOME/local-repo/flink-cmd(默认路径,或者查看zeppelin-site.xml中的zeppelin.interpreter.localRepo配置值)中添加依赖(hadoop-client-runtime及其依赖):
- hadoop-client-api-3.1.1.jar
- hadoop-client-runtime-3.1.1.jar
接下来需要在interpreter配置页面把上面两个依赖添加到interpreter中。
Interpreter配置项:
- FLINK_HOME:Flink的安装目录
示例:
run -m yarn-cluster /opt/paultech/flink-1.17.2/examples/batch/WordCount.jar
Kerberos
配置参数和sh解释器相同,如下所示:
- zeppelin.shell.auth.type: KERBEROS
- zeppelin.shell.keytab.location: /path/to/user.keytab
- zeppelin.shell.principal: user@PAULTECH
JDBC Hive
该解释器使用JDBC方式连接Hive,可直接运行Hive SQL。
Interpreter增加配置:
- default.url: Hive的JDBC连接URL,例如:jdbc:hive2://node1:2181,node2:2181,node3:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
- default.user: hive
- default.password:
- default.driver: org.apache.hive.jdbc.HiveDriver
Interpreter配置中需要增加依赖:
- hive-jdbc-standalone.jar
- hadoop-client-api-3.1.1.jar
- hadoop-client-runtime-3.1.1.jar
执行时可能遇到报错:
ERROR [2025-08-18 16:27:36,819] ({ParallelScheduler-Worker-1} JDBCInterpreter.java[executeSql]:786) - Fail to getConnection
java.sql.SQLException: Could not open client transport for any of the Server URI's in ZooKeeper: Failed to open new session: java.lang.IllegalArgumentException: Cannot modify mapreduce.job.tags at runtime. It is not in list of params that are allowed to be modified at runtime
解决方式:
修改hive-site.xml的hive.security.authorization.sqlstd.confwhitelist为mapred.*|hive.*|mapreduce.*|spark.*|tez.*。重启Hive集群。
Kerberos
- default.url:
jdbc:hive2://node1:2181,node2:2181,node3:2181/default;principal=hive/_HOST@PAULTECH;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 - default.user: (空)
- default.password: (空)
- default.driver: org.apache.hive.jdbc.HiveDriver
- zeppelin.jdbc.auth.type: KERBEROS
- zeppelin.jdbc.keytab.location: /path/to/user.keytab
- zeppelin.jdbc.principal: user@PAULTECH
- zeppelin.jdbc.auth.kerberos.proxy.enable: false
要点解析:
- default.url中必须提供principal,必须填写
hive/_HOST@PAULTECH。 - zeppelin.jdbc.principal和kerytab使用具有Hive读写权限的用户。
- 必须设置zeppelin.jdbc.auth.kerberos.proxy.enable: false。