Mr·Li博客

IDEA本地配置kerberos认证

lixiaobin·2021-11-16 15:38·890 次阅读

IDEA本地配置kerberos认证

1、项目导入之后设置maven依赖之后先将scala代码文件设为source

 

2、创建resources文件夹,将配置的资源文件放入这里

 

3、设置在本地运行代码:-Dspark.master=local,并设置其他参数

 

4、在跑模型之前先读取资源文件中的配置信息进行kerberos认证

 

复制代码
def initKerberos(): Unit ={

  //kerberos权限认证

  val path = this.getClass.getClassLoader.getResource("").getPath

  val conf = new Configuration

  System.setProperty("java.security.krb5.conf", path + "krb5.conf")

  conf.addResource(new Path(path + "hdfs-site.xml"))

  conf.addResource(new Path(path + "hive-site.xml"))

  conf.set("hadoop.security.authentication", "Kerberos")

  conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem")

  conf.set("dfs.client.use.datanode.hostname", "true")

  UserGroupInformation.setConfiguration(conf)

  UserGroupInformation.loginUserFromKeytab("test001", path + "test001.keytab")

  println("login user: "+UserGroupInformation.getLoginUser())

}
复制代码

 

posted @   Mr·Li程序员  阅读(890)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
点击右上角即可分享
微信分享提示