ETL
这里使用mapreduce
1.过滤脏数据
2.解析IP
3.解析浏览器信息
4.设计rowkey
注意:如果没有数据汇总,不用写reduce
项目:
Sqoop
简介
Sqoop:将关系数据库(oracle、mysql、postgresql等)数据与hadoop数据进行转换的工具
官网:http://sqoop.apache.org/
版本:(两个版本完全不兼容,sqoop1使用最多)
sqoop1由client端直接接入hadoop,任务通过解析生成对应的maprecue执行
导入
![bdae9441576824b1c559aa497bcd347f.png](https://i-blog.csdnimg.cn/blog_migrate/d0d3e194ffeff46c1901e83c34b74234.jpeg)
导出
![6c7f2571f60616a2fc9fb7e00e4411cf.png](https://i-blog.csdnimg.cn/blog_migrate/a1df0f32f1eb09f95dd66f5e07a2769c.jpeg)
安装步骤
1、解压
2、配置环境变量
export SQOOP_HOME=/XX/sqoop.xx
source /etc/profile
3、添加数据库驱动包
cp mysql-connector-java-5.1.10.jar /sqoop-install-path/lib
4、重命名配置文件
mv sqoop-env-template.sh sqoop-env.sh
注意:/etc/profile环境变量需要
HADOOP_HOME
ZOOKEEPER_HOME
HIVE_HOME(非必须)
HBASE_HOME(非必须)
5、修改配置configure-sqoop
去掉未安装服务相关内容;例如(HBase、HCatalog、Accumulo):
#if [ ! -d "${HBASE_HOME}" ]; then
# echo "Error: $HBASE_HOME does not exist!"
# echo 'Please set $HBASE_HOME to the root of your HBase installation.'
# exit 1
6、测试
sqoop version
sqoop list-databases -connect jdbc:mysql://node3:3306/ -username root -password 123
导入导出
注意:导入导出是相对于hdfs而言
参考文档:
http://sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html#_importing_data_into_hbase
mysql导入hdfs
sqoop --options-file option1
option1
import--connectjdbc:mysql://node1:3306/test--usernameroot--password123--as-textfile--columnsid,name,msg--tablepsn--delete-target-dir--target-dir/sqoop/data-m1
hdfs导出mysql
sqoop --options-file option2
option2
export--connectjdbc:mysql://node1/test--usernameroot--password123-m1--columnsid,name,msg--export-dir/sqoop/data--tableh_psn
mysql导入hive
sqoop --options-file option3
option3
import--connectjdbc:mysql://node1/test--usernameroot--password123--as-textfile--query'select id, name, msg from psn where id like "1%" and $CONDITIONS'--delete-target-dir--target-dir/sqoop/tmp-m1--hive-home/home/hive-1.2.1--hive-import--create-hive-table--hive-tablet_test
mysql导入hbase
sqoop --options-file option4
option4
import--connectjdbc:mysql://node1/test--usernameroot--password123--as-textfile--query'select id, name, msg from psn where id like "1%" and $CONDITIONS' -m1--column-familycf1--hbase-create-table--hbase-row-keyid--hbase-tablet_psn1