wgzhao / Addax

Addax is a versatile open-source ETL tool that can seamlessly transfer data between various RDBMS and NoSQL databases, making it an ideal solution for data migration.
https://wgzhao.github.io/Addax/
Apache License 2.0
1.2k stars 304 forks source link

[Bug]: 使用hdfswriter时kerberos认证不成功 #1061

Closed laixueyong closed 4 months ago

laixueyong commented 4 months ago

What happened?

我使用了hive.keytab和hdfs.keytab的方式去认证Kerberos都不成功 强制nn/_HOST@ 以nn开头

Version

4.1.3 (Default)

OS Type

No response

Java JDK Version

Oracle JDK 1.8.0

Relevant log output

n: java.io.IOException: DestHost:destPort cdhtest01:8020 , LocalHost:localPort cdhtest02/10.96.119.182:0. Failed on local exception: java.io.IOException: Couldn't set up IO streams: java.lang.IllegalArgumentException: Server has invalid Kerberos principal: hdfs/cdhtest01@PEC.COM.CN, expecting: nn/cdhtest01@PEC.COM.CN
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.hadoop.net.NetUtils.wrapWithMessage(NetUtils.java:842)
        at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:817)
        at org.apache.hadoop.ipc.Client.getRpcResponse(Client.java:1616)
        at org.apache.hadoop.ipc.Client.call(Client.java:1558)
        at org.apache.hadoop.ipc.Client.call(Client.java:1455)
        at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:231)
        at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:118)
        at com.sun.proxy.$Proxy18.getFileInfo(Unknown Source)
        at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:910)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:433)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeMethod(RetryInvocationHandler.java:166)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invoke(RetryInvocationHandler.java:158)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeOnce(RetryInvocationHandler.java:96)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:362)
        at com.sun.proxy.$Proxy19.getFileInfo(Unknown Source)
        at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:1679)
        at org.apache.hadoop.hdfs.DistributedFileSystem$29.doCall(DistributedFileSystem.java:1602)
        at org.apache.hadoop.hdfs.DistributedFileSystem$29.doCall(DistributedFileSystem.java:1599)
        at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
        at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1614)
        at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1690)
        at com.wgzhao.addax.plugin.writer.hdfswriter.HdfsHelper.isPathExists(HdfsHelper.java:387)
        at com.wgzhao.addax.plugin.writer.hdfswriter.HdfsWriter$Job.buildTmpFilePath(HdfsWriter.java:306)
        at com.wgzhao.addax.plugin.writer.hdfswriter.HdfsWriter$Job.prepare(HdfsWriter.java:205)
        at com.wgzhao.addax.core.job.JobContainer.prepareJobWriter(JobContainer.java:626)
        at com.wgzhao.addax.core.job.JobContainer.prepare(JobContainer.java:271)
        at com.wgzhao.addax.core.job.JobContainer.start(JobContainer.java:124)
        at com.wgzhao.addax.core.Engine.start(Engine.java:62)
        at com.wgzhao.addax.core.Engine.entry(Engine.java:113)
        at com.wgzhao.addax.core.Engine.main(Engine.java:139)
Caused by: java.io.IOException: Couldn't set up IO streams: java.lang.IllegalArgumentException: Server has invalid Kerberos principal: hdfs/cdhtest01@PEC.COM.CN, expecting: nn/cdhtest01@PEC.COM.CN
        at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:894)
        at org.apache.hadoop.ipc.Client$Connection.access$3800(Client.java:414)
        at org.apache.hadoop.ipc.Client.getConnection(Client.java:1677)
        at org.apache.hadoop.ipc.Client.call(Client.java:1502)
        ... 30 more
Caused by: java.lang.IllegalArgumentException: Server has invalid Kerberos principal: hdfs/cdhtest01@PEC.COM.CN, expecting: nn/cdhtest01@PEC.COM.CN
        at org.apache.hadoop.security.SaslRpcClient.getServerPrincipal(SaslRpcClient.java:337)
        at org.apache.hadoop.security.SaslRpcClient.createSaslClient(SaslRpcClient.java:234)
        at org.apache.hadoop.security.SaslRpcClient.selectSaslClient(SaslRpcClient.java:160)
        at org.apache.hadoop.security.SaslRpcClient.saslConnect(SaslRpcClient.java:390)
        at org.apache.hadoop.ipc.Client$Connection.setupSaslConnection(Client.java:623)
        at org.apache.hadoop.ipc.Client$Connection.access$2300(Client.java:414)
        at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:843)
        at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:839)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1762)
        at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:839)
        ... 33 more

        at com.wgzhao.addax.common.exception.AddaxException.asAddaxException(AddaxException.java:66)
        at com.wgzhao.addax.plugin.writer.hdfswriter.HdfsHelper.isPathExists(HdfsHelper.java:390)
        at com.wgzhao.addax.plugin.writer.hdfswriter.HdfsWriter$Job.buildTmpFilePath(HdfsWriter.java:306)
        at com.wgzhao.addax.plugin.writer.hdfswriter.HdfsWriter$Job.prepare(HdfsWriter.java:205)
        at com.wgzhao.addax.core.job.JobContainer.prepareJobWriter(JobContainer.java:626)
        at com.wgzhao.addax.core.job.JobContainer.prepare(JobContainer.java:271)
        at com.wgzhao.addax.core.job.JobContainer.start(JobContainer.java:124)
        at com.wgzhao.addax.core.Engine.start(Engine.java:62)
        at com.wgzhao.addax.core.Engine.entry(Engine.java:113)
        at com.wgzhao.addax.core.Engine.main(Engine.java:139)
Caused by: java.io.IOException: DestHost:destPort cdhtest01:8020 , LocalHost:localPort cdhtest02/10.96.119.182:0. Failed on local exception: java.io.IOException: Couldn't set up IO streams: java.lang.IllegalArgumentException: Server has invalid Kerberos principal: hdfs/cdhtest01@PEC.COM.CN, expecting: nn/cdhtest01@PEC.COM.CN
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.hadoop.net.NetUtils.wrapWithMessage(NetUtils.java:842)
        at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:817)
        at org.apache.hadoop.ipc.Client.getRpcResponse(Client.java:1616)
        at org.apache.hadoop.ipc.Client.call(Client.java:1558)
        at org.apache.hadoop.ipc.Client.call(Client.java:1455)
        at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:231)
        at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:118)
        at com.sun.proxy.$Proxy18.getFileInfo(Unknown Source)
        at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:910)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:433)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeMethod(RetryInvocationHandler.java:166)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invoke(RetryInvocationHandler.java:158)
        at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeOnce(RetryInvocationHandler.java:96)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:362)
        at com.sun.proxy.$Proxy19.getFileInfo(Unknown Source)
        at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:1679)
        at org.apache.hadoop.hdfs.DistributedFileSystem$29.doCall(DistributedFileSystem.java:1602)
        at org.apache.hadoop.hdfs.DistributedFileSystem$29.doCall(DistributedFileSystem.java:1599)
        at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
        at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1614)
        at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1690)
        at com.wgzhao.addax.plugin.writer.hdfswriter.HdfsHelper.isPathExists(HdfsHelper.java:387)
        ... 8 more
Caused by: java.io.IOException: Couldn't set up IO streams: java.lang.IllegalArgumentException: Server has invalid Kerberos principal: hdfs/cdhtest01@PEC.COM.CN, expecting: nn/cdhtest01@PEC.COM.CN
        at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:894)
        at org.apache.hadoop.ipc.Client$Connection.access$3800(Client.java:414)
        at org.apache.hadoop.ipc.Client.getConnection(Client.java:1677)
        at org.apache.hadoop.ipc.Client.call(Client.java:1502)
        ... 30 more
Caused by: java.lang.IllegalArgumentException: Server has invalid Kerberos principal: hdfs/cdhtest01@PEC.COM.CN, expecting: nn/cdhtest01@PEC.COM.CN
        at org.apache.hadoop.security.SaslRpcClient.getServerPrincipal(SaslRpcClient.java:337)
        at org.apache.hadoop.security.SaslRpcClient.createSaslClient(SaslRpcClient.java:234)
        at org.apache.hadoop.security.SaslRpcClient.selectSaslClient(SaslRpcClient.java:160)
        at org.apache.hadoop.security.SaslRpcClient.saslConnect(SaslRpcClient.java:390)
        at org.apache.hadoop.ipc.Client$Connection.setupSaslConnection(Client.java:623)
        at org.apache.hadoop.ipc.Client$Connection.access$2300(Client.java:414)
        at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:843)
        at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:839)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1762)
        at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:839)
        ... 33 more
laixueyong commented 4 months ago

"writer": { "name": "hdfswriter", "parameter": { "defaultFS": "hdfs://cdhtest01:8020", "fileType": "parquet", "path": "/user/hive/warehouse/px3", "fileName": "px", "column": [ { "name": "sku", "type": "string" }, { "name": "sku_name", "type": "string" }, { "name": "com_name", "type": "string" } ], "hadoopConfig": { "dfs.nameservices": "nameservice1", "dfs.ha.namenodes.nameservice1": "namenode67,namenode103", "dfs.namenode.rpc-address.nameservice1.namenode67": "cdhtest01:8020", "dfs.namenode.rpc-address.nameservice1.namenode103": "cdhtest05:8020", "dfs.client.failover.proxy.provider.nameservice1": "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" }, "haveKerberos": true, "kerberosKeytabFilePath": "/home/extimp/lxy_work/datax_format/datax/keytab/hive.keytab", "kerberosPrincipal": "hive/cdhtest01@PEC.COM.CN", "writeMode": "append", "fieldDelimiter": "\u0001", "compress": "SNAPPY" } }

laixueyong commented 4 months ago

已经解决了