简体   繁体   English

如何使用 Sqoop 通过 Docker 容器将导入数据从 SQL 服务器连接到 HDFS?

[英]How to connect import data from SQL Server to HDFS using Sqoop via Docker Container?

I have configured two docker containers on the google compute engine.我在谷歌计算引擎上配置了两个 docker 容器。

First container: I have loaded a database on it and it runs well when I connect it via a SQL client on the localhost/mylaptop.第一个容器:我已经在其上加载了一个数据库,当我通过 localhost/mylaptop 上的 SQL 客户端连接它时,它运行良好。 Note I am also using the --network so I can talk between two containers.注意我也在使用--network,所以我可以在两个容器之间交谈。

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

Second container: I am running a custom container that has Cloudera express installed on it.第二个容器:我正在运行一个安装了 Cloudera express 的自定义容器。

It works wells the configuration is as follows.它运行良好,配置如下。 I have configured to run this on system startup, and I have to ssh into port 122 to use the container.我已配置为在系统启动时运行它,我必须将 ssh 插入端口 122 才能使用容器。

docker run -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-h cnt7-xxx-cdh63 \
--name cnt7-xxx-cdh63 \
--network nc-de-network \
-p 122:22 \
-p 7180:7180 \
-p 8889:8889 \
-p 3306:3306 \
-p 8890:8890 \
-p 4040:4040 \
-p 18088:18088 \
-p 10000:10000 \
-p 21050:21050 \
-p 9870:9870 \
-p 9092:9092 \
-p 2181:2181 \
-p 11000:11000 \
-p 41414:41414 \
-p 8088:8088 \
--privileged=true \
-it cnt7-xxx-cdh63 /usr/sbin/init

Import from SQL Server database to HDFS.从 SQL 服务器数据库导入到 HDFS。 I tried to use the following.我尝试使用以下内容。

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

But I get the following error但我收到以下错误

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.".

How do I make this work?我该如何进行这项工作? Note: Both the containers individually work fine注意:两个容器单独工作正常

You need to use data-engr-sql-svr:1433 , not localhost as the connection string.您需要使用data-engr-sql-svr:1433 ,而不是 localhost 作为连接字符串。

Note: you don't need a whole Cloudera environment to run sqoop, and you should use docker exec rather than ssh注意:你不需要整个 Cloudera 环境来运行 sqoop,你应该使用docker exec而不是 ssh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM