启动Hive时遭遇Socket权限错误,请求排查解决方案
Hive启动Socket权限拒绝异常排查思路
环境与问题描述
本地开发机部署Hive + Hadoop,Hive元数据存储使用MySQL。启动Hive时抛出如下异常:
C:\Users\<USER>hive SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/data-engineering/hadoop331/share/hadoop/common/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/data-engineering/hive3/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 2023-01-02 18:55:44,239 INFO conf.HiveConf: Found configuration file file:/C:/data-engineering/hive3/conf/hive-site.xml Hive Session ID = 228b9d9a-c6aa-4d61-adaa-ade6f0b1d878 2023-01-02 18:55:49,590 INFO SessionState: Hive Session ID = 228b9d9a-c6aa-4d61-adaa-ade6f0b1d878 Logging initialized using configuration in jar:file:/C:/data-engineering/hive3/lib/hive-common-3.0.0.jar!/hive-log4j2.properties Async: true 2023-01-02 18:55:49,834 INFO SessionState: Logging initialized using configuration in jar:file:/C:/data-engineering/hive3/lib/hive-common-3.0.0.jar!/hive-log4j2.properties Async: true Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Call From HHC12368/172.21.160.1 to 0.0.0.0:19000 failed on socket exception: java.net.SocketException: Permission denied: no further information; For more details see: http://wiki.apache.org/hadoop/SocketException at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:644) at org.apache.hadoop.hive.ql.session.SessionState.beginStart(SessionState.java:585) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:747) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683) 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.util.RunJar.run(RunJar.java:323) at org.apache.hadoop.util.RunJar.main(RunJar.java:236) Caused by: java.net.SocketException: Call From HHC12368/172.21.160.1 to 0.0.0.0:19000 failed on socket exception: java.net.SocketException: Permission denied: no further information; For more details see: http://wiki.apache.org/hadoop/SocketException 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:913) at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:871) at org.apache.hadoop.ipc.Client.getRpcResponse(Client.java:1577) at org.apache.hadoop.ipc.Client.call(Client.java:1519) at org.apache.hadoop.ipc.Client.call(Client.java:1416) at org.apache.hadoop.ipc.ProtobufRpcEngine2$Invoker.invoke(ProtobufRpcEngine2.java:242) at org.apache.hadoop.ipc.ProtobufRpcEngine2$Invoker.invoke(ProtobufRpcEngine2.java:129) at com.sun.proxy.$Proxy28.getFileInfo(Unknown Source) at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:965) 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:422) at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeMethod(RetryInvocationHandler.java:165) at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invoke(RetryInvocationHandler.java:157) at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeOnce(RetryInvocationHandler.java:95) at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:359) at com.sun.proxy.$Proxy29.getFileInfo(Unknown Source) at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:1731) at org.apache.hadoop.hdfs.DistributedFileSystem$29.doCall(DistributedFileSystem.java:1752) at org.apache.hadoop.hdfs.DistributedFileSystem$29.doCall(DistributedFileSystem.java:1749) at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81) at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1764) at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1760) at org.apache.hadoop.hive.ql.exec.Utilities.ensurePathIsWritable(Utilities.java:4483) at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:753) at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:694) at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:620) ... 9 more Caused by: java.net.SocketException: Permission denied: no further information at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:715) at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206) at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:586) at org.apache.hadoop.ipc.Client$Connection.setupConnection(Client.java:701) at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:822) at org.apache.hadoop.ipc.Client$Connection.access$3800(Client.java:414) at org.apache.hadoop.ipc.Client.getConnection(Client.java:1647) at org.apache.hadoop.ipc.Client.call(Client.java:1463)
当前Hadoop core-site.xml 配置:
<configuration> <property> <name>fs.default.name</name> <value>hdfs://0.0.0.0:19000</value> </property> </configuration>
排查步骤
1. 确认HDFS服务是否正常启动
- 执行
jps命令,查看输出中是否存在NameNode进程 - 若进程未启动,Windows环境下执行
start-dfs.cmd手动启动HDFS服务
2. 修正core-site.xml的地址配置
0.0.0.0是监听所有网卡的配置,但客户端连接时容易出现权限或解析问题,换成具体地址:
- 将
fs.default.name的值修改为hdfs://localhost:19000,或本机实际IP(如172.21.160.1) - 修改完成后重启HDFS服务,确保配置生效
3. 检查Windows防火墙拦截情况
Windows防火墙大概率会拦截Hadoop端口的通信:
- 打开Windows Defender防火墙,添加入站、出站规则,允许TCP 19000端口的通信
- 可临时关闭防火墙做测试,若能正常连接则说明是防火墙的问题
4. 直接验证HDFS连接可用性
先排除Hadoop自身的问题,再排查Hive:
- 执行
hdfs dfs -ls /,查看是否能正常列出HDFS根目录内容 - 若该命令同样报错,说明问题出在Hadoop配置或网络层面,与Hive无关
5. 核对Hive配置中的HDFS地址一致性
确保Hive的hive-site.xml配置与Hadoop保持一致:
- 检查
hive-site.xml中是否存在fs.defaultFS配置项,其值需与core-site.xml完全匹配 - 若未配置该项,需确保Hive能正确加载Hadoop的配置文件(即HADOOP_HOME环境变量配置正确)
6. 检查HDFS目录权限
Hive启动时需要在HDFS上创建会话目录,需确保当前用户拥有读写权限:
- 测试环境可临时执行
hdfs dfs -chmod 777 /(生产环境禁止使用该命令) - 或专门创建Hive所需目录:
hdfs dfs -mkdir -p /tmp/hive,再执行hdfs dfs -chmod 777 /tmp/hive
内容的提问来源于stack exchange,提问作者Joe Ingle
相关产品推荐
相关产品推荐

