纪念一下,之前几天想模拟公司将mysql中的数据导到数据平台的操作,看似很简单的操作,可能因为是版本问题出了很多少见的bug,google和stackover都没有解决,最后的安装成功的hadoop版本为2.6.3, HIve版本为1.2.1 sqoop版本为1.4.6,ubuntu14.04.接下去准备系统的学习下。加油!
安装参考的教程http://wenku.baidu.com/link?url=yzhKK4TT19qs6dm06NMTGw8poTgydLly5GLZ6tjCRgNuO7yvuf3SOT_alxLa3KTI7pI__NzK1_RpK9TsAXiU9zLNF5vo9LdbsGp1TyT8WoO
出现什么奇怪的bug的话可以试着按http://www.powerxing.com/install-hadoop/再安装hadoop一遍,都是java项目,以jar方式工作,修改下配置文件和系统PATH即可。
hadoop,hive,sqoop使用教程谷歌搜索很多。
如果出现一些之后按http://www.powerxing.com/install-hadoop/的
hive创建表:
create external table s_coupon(
id int,
uid int,
pay_order_id int,
status int,
template_id int,
received_ts bigint,
expire_ts bigint,
gmt_create timestamp,
gmt_update timestamp
)
row Format delimited fields terminated by '\001'
stored as textfile
location '/dw/s_coupon';
使用sqoop往hdfs导数据
sqoop import --connect jdbc:mysql://localhost:3306/buybuybuy --username root --password 123456 --table coupon --verbose --target-dir hdfs://127.0.0.1:9000/dw/s_coupon_tmp --fields-terminated-by '\001' --hive-drop-import-delims
移动到指定目录
hadoop fs -mv hdfs://127.0.0.1:9000/dw/s_coupon_tmp hdfs://127.0.0.1:9000/dw/s_coupon