当使用 beeline 连接 Spark Thrift Server 时,可能遇到以下错误提示:
Error: Could not open client transport with JDBC Uri: jdbc:hive2://:/: Peer indicated failure: Unsupported mechanism type PLAIN. If the mechanism type is not SASL, then the peer may not be a HiveServer2. (state=08S01,code=0)
解决方法如下:
1.打开 Spark Thrift Server 的配置文件,一般位于 Spark 安装目录下的conf
文件夹下。
cd /path/to/spark/conf/
nano hive-site.xml
2.在配置文件中添加以下内容:
hive.server2.authentication
NONE
Authentication type. Values are:
NONE
LDAP
KERBEROS
CUSTOM
3.保存并关闭配置文件。
4.重新启动 Spark Thrift Server。
cd /path/to/spark/
./sbin/start-thriftserver.sh
5.使用 beeline 连接 Spark Thrift Server,输入以下命令进行连接:
beeline -u jdbc:hive2://:/
其中
是 Spark Thrift Server 所在的服务器地址,
是 Spark Thrift Server 使用的端口号,
是需要连接的数据库。
6.输入用户名和密码进行认证即可成功连接 Spark Thrift Server。