Hive学习

us.apache.org/dist/hive/hive-2.1.1/ 官方文档:https://cwiki.apache.org/confluence/display/Hive/GettingStarted

修改以下属性:

配置全局变量:

运行:

异常: Relative path in absolute URI: ${system:user.name%7D Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D

解决方法: 在hive-site.xml中加入:

https://cwiki.apache.org/confluence/display/Hive/HiveWebInterface HWI is only available in Hive releases prior to 2.2.0. It was removed by HIVE-15622.

配置失败

官网:http://sqoop.apache.org

下载地址: http://www-eu.apache.org/dist/sqoop/1.99.7/ 官方文档: http://sqoop.apache.org/docs/1.99.7/

查看分隔符:desc formatted stations; 默认:\1(SOH) 修改HIVE序列化存储分隔符: alter table tablename set SERDEPROPERTIES('field.delim'=',');

导入到HDFS: ./sqoop import --connect jdbc:mysql://127.0.0.1:3306/test --username root --password l --table stations --target-dir '/sqoop/stations'

导入到HIVE: ./sqoop import --hive-import --connect jdbc:mysql://127.0.0.1:3306/test --username root --password l --table stations

自定义表名,添加筛选条件: ./sqoop import --hive-import --connect jdbc:mysql://127.0.0.1:3306/test --username root --password l --table stations --hive-table stations_bj --where 'fchar like "%bj%"'

使用query查询语句: 使用--query,不能包含--table参数,必须包含--target-dir和--split-by 条件中必须有 $CONDITIONS ./sqoop import --hive-import --connect jdbc:mysql://127.0.0.1:3306/test --username root --password l --hive-table stations_q --query 'select * from stations where fchar="bj" and $CONDITIONS' --target-dir '/sqoop/stations_q' --split-by 'id'

导出到MYSQL: 必须先在MYSQL中创建此表,且对应列关系 ./sqoop export --connect jdbc:mysql://127.0.0.1:3306/test --username root --password l -m 1 --table stations_bj --export-dir '/user/hive/warehouse/stations_q'

注意

示例代码:

你可能感兴趣的:(Hive学习)