如何使用sqoop通过docker容器将导入数据从sqlserver连接到hdfs?

igsr9ssn  于 2021-07-13  发布在  Hadoop
关注(0)|答案(1)|浏览(634)

我在google计算引擎上配置了两个docker容器。
第一个容器:我在它上面加载了一个数据库,当我通过localhost/mylaptop上的sql客户机连接它时,它运行良好。注意,我还使用了--网络,以便可以在两个容器之间进行通信。

  1. # Run the docker container
  2. sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=mypassword" \
  3. -p 1433:1433 --name data-engr-sql-svr -h data-engr-sql-svr \
  4. --network nc-de-network \
  5. -d mcr.microsoft.com/mssql/server:2019-latest

第二个容器:我正在运行一个安装了cloudera express的自定义容器。
它的工作原理如下。我已经配置好在系统启动时运行它,并且我必须ssh到端口122才能使用容器。

  1. docker run -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
  2. -h cnt7-xxx-cdh63 \
  3. --name cnt7-xxx-cdh63 \
  4. --network nc-de-network \
  5. -p 122:22 \
  6. -p 7180:7180 \
  7. -p 8889:8889 \
  8. -p 3306:3306 \
  9. -p 8890:8890 \
  10. -p 4040:4040 \
  11. -p 18088:18088 \
  12. -p 10000:10000 \
  13. -p 21050:21050 \
  14. -p 9870:9870 \
  15. -p 9092:9092 \
  16. -p 2181:2181 \
  17. -p 11000:11000 \
  18. -p 41414:41414 \
  19. -p 8088:8088 \
  20. --privileged=true \
  21. -it cnt7-xxx-cdh63 /usr/sbin/init

从sql server数据库导入到hdfs。我试着用下面的方法。

  1. sudo -u hdfs sqoop list-databases \
  2. --connect "jdbc:sqlserver://localhost:1433;instanceName=data-engr-sql-svr;databaseName=AdventureWorks2019" \
  3. --username sa \
  4. --password pwd

但我得到以下错误

  1. com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

我该怎么做?注意:两个容器单独工作正常

lmvvr0a8

lmvvr0a81#

你需要使用 data-engr-sql-svr:1433 ,而不是localhost作为连接字符串。
注意:运行sqoop不需要整个cloudera环境,应该使用 docker exec 而不是ssh

相关问题