无法从 sql(oracle) sqoop 数据

Unable to sqoop the data from sql(oracle)

我正在尝试将 table 从 oracle 导入到 hdfs(hive table)。但是我无法完成导入。这是我正在使用的命令:

sqoop import --hive-import --connect jdbc:oracle:thin:@hostname:port/servicename --table sql_schema.table --username uname --password pwd --hive-table hive_schema.table --num-mappers 1 --verbose

这是我遇到的错误

15/10/12 15:17:21 INFO mapreduce.Job:  map 100% reduce 0%
15/10/12 15:17:21 INFO mapreduce.Job: Task Id : attempt_1444407202506_0022_m_000000_1, Status : FAILED
Error: java.lang.RuntimeException: java.lang.RuntimeException: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
        at org.apache.sqoop.mapreduce.db.DBInputFormat.setConf(DBInputFormat.java:167)
        at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:76)
        at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:136)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:749)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
        at org.apache.hadoop.mapred.YarnChild.run(YarnChild.java:164)
        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:1657)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
Caused by: java.lang.RuntimeException: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
        at org.apache.sqoop.mapreduce.db.DBInputFormat.getConnection(DBInputFormat.java:220)
        at org.apache.sqoop.mapreduce.db.DBInputFormat.setConf(DBInputFormat.java:165)
        ... 9 more
Caused by: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at org.apache.sqoop.mapreduce.db.DBConfiguration.getConnection(DBConfiguration.java:302)
        at org.apache.sqoop.mapreduce.db.DBInputFormat.getConnection(DBInputFormat.java:213)
        ... 10 more
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
        at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:439)
        at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:454)
        at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:693)
        at oracle.net.ns.NSProtocol.connect(NSProtocol.java:251)
        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)
        ... 18 more
Caused by: java.net.SocketTimeoutException: connect timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:149)
        at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
        at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:405)
        ... 23 more

我尝试从同一台机器连接到 oracle,我成功了并且能够从服务器访问 tables 但我不确定为什么我会看到这个 IO 错误:网络适​​配器无法建立连接 错误。

非常感谢这方面的任何帮助。

您确定可以从您尝试使用 sqoop 命令的服务器访问数据库吗?

你能在那个端口上 ping thr oracle hostnsme 吗?

我最后遇到了同样的问题week.my 问题是 oracle 运行 的端口号在 hadoop 集群的网关节点上被阻塞了。

问题已解决!问题出在 DSCP 标记上。为所有数据节点启用 DSCP 标记后,连接已成功建立!