小项目里一些之前没讲过的

1.欲知一串url的意思,可以搜urldecode

2.mysql文本文件想执行,在mysql里source /home/hadoop/data/product_info.sql;

3.jps -m可以看具体跑的jar

4.get_json_object
这样的数据1 product1 {"product_status":1}
取json里的值 get_json_object(json_txt,path) json_txt是第三个字段extend_info,path是’product_status’,前面要加$.,不然取出的会是null.

性能低,慎用。
自定义解析JSON的UDF函数 <== 使用Java开发Hive的UDF函数来搞定

5.row_number函数
写在select里

row_number() over(partition by area order by click_count desc) rank

row_number 用于分组排序,partition这个后面是按什么分组,order by 按什么排序,默认降序 ,rank是分组的别名
另rank=3,相当于取各组前三个。

join/group by/row_number 容易产生数据倾斜。

6.hive 脚本shell

不需要进入hive,在控制台就可执行,在shell文件里用这个

hive -e

7.指定时间执行一个shell脚本
crontab命令

crontab -l #查看你的任务
crontab-e#编辑你的任务
crontab-r#删除用户的crontab的内容
启动cron进程的方法:/etc/init.d/crond start
开机就启动cron进程的设置命令:chkconfig --add crond

8.reduce task

这个数量要严格控制,不能过大、不能过小,有多少reduce,产生多少个文件。

为什么hadoop不怕文件大,怕小文件多?
元数据记录在namenode,大文件和小文件元数据差不多。

猜你喜欢

转载自blog.csdn.net/qq_36459386/article/details/84134386