hadoop hive python 笔记

本文介绍如何在Ubuntu系统中安装PyHS2,以便使用Python访问Hive。此外还提供了几种将远程数据写入HDFS/Hive的方法,包括通过SSH连接、直接从数据生成节点上传文件等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在ubuntu中安装pyhs2,用于使用python访问hive 


使用pip安装pyhs2之前,需要先安装python-dev 、 libsasl2-dev和gcc 

apt-get install python-dev libsasl2-dev gcc 


CentOS/RHEL中使用yum(见pyhs2的github主页wiki):

yum install gcc-c++ python-devel.x86_64 cyrus-sasl-devel.x86_64


远程数据写入HDFS/Hive方案:

1. 

1) copy the file to the master node's local disk:

scp test.txt username@masternode:/folderName/
I have already setup SSH connection using keys. So no password is needed to do this.

2) I can use ssh to remotely execute the hadoop put command:

ssh username@masternode "hadoop dfs -put /folderName/test.txt hadoopFolderName/"

2. 

Try this (untested):

cat test.txt | ssh username@masternode "hadoop dfs -put - hadoopFoldername/"
I've used similar tricks to copy directories around:

tar cf - . | ssh remote "(cd /destination && tar xvf -)"
This sends the output of local-tar into the input of remote-tar.

3. 

The node where you have generated the data on, is this able to reach each of your cluster nodes (the name node and all the datanodes).

If you do have data connectivity then you can just execute the hadoop fs -put command from the machine where the data is generated (assuming you have the hadoop binaries installed there too):

#> hadoop fs -fs masternode:8020 -put test.bin hadoopFolderName/

4.

Hadoop provides a couple of REST interfaces. Check Hoop and WebHDFS. You should be able to copy the file without copying the file to the master using them from non-Hadoop environments

5.

sqoop


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值