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

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

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


# 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

第二个容器:我正在运行一个安装了cloudera express的自定义容器。
它的工作原理如下。我已经配置好在系统启动时运行它,并且我必须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

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

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

但我得到以下错误

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

相关问题