hadoop的Linux操作
Hadoop之HDFS文件操作
sudo su - hdfs:免密,以hdfs账户登陆。可操作hdfs文件
logout
sudo su - root
hadoop fs -ls /
rm -rf 目录名
sh dvm_auto_hive_ci_test.sh 2017-11-22 2017-11-22 criteo
hadoop fs -get /report/dvm_test/script/bashScript
ls -l :查看文件权限
chmod 777mm.txt:修改文件权限
cat criteo.log:查看文件
sh dvm_auto_hive_criteoTransaction_test.sh -d "2017-11-22" -P "criteoTransaction" --input-folder "/report/dvm_test/naa" --hdfs-script "/report/dvm_test/script/etl"
hadoop fs -rmdir /tmp/out/report/dvm_test/naa/TransactionCriteo/2017/11
hadoop jar "/usr/hdp/2.6.2.0-205/hadoop-mapreduce/hadoop-streaming-2.7.3.2.6.2.0-205.jar" -input "/report/dvm_test/naa/TransactionCriteo/2017/11/22" -output "/tmp/out/report/dvm_test/naa/TransactionCriteo/2017/11/22" -mapper "python /report/dvm_test/script/etl/TransactionCriteo_naa_map.py" -reducer NONE
truncate table table_name;
DROP TABLE [IF EXISTS] table_name;
ALTER TABLE myTable DROP IF EXISTS PARTITION
(date>='date1' and date<='date2');
ALTER TABLE myTable DROP IF EXISTS PARTITION
(date>='date1' && date<='date2');
ALTER TABLE myTable DROP IF EXISTS PARTITION
(date between 'date1' and 'date2');
update partition:
ALTER TABLE logs PARTITION(year = 2012, month = 12, day = 18)
SET LOCATION 'hdfs://user/darcy/logs/2012/12/18';
drop a partition:
ALTER TABLE logs DROP IF EXISTS PARTITION(year = 2012, month = 12, day = 18);
I implemented a workaround for this issue using some shell scripts, like for instance:
for y in {2011..2014}
do
for m in {01..12}
do
echo -n "ALTER TABLE reporting.frontend DROP IF EXISTS PARTITION (year=0000,month=00,day=00,hour=00)"
for d in {01..31}
do
for h in {01..23}
do
echo -n ", PARTITION (year=$y,month=$m,day=$d,hour=$h)"
done
done
echo ";"
done
done > drop_partitions_v1.hql
The resulting .hql file can be simply executed by using the hive (or beeline) -f option.
Obviously the loops should be able to generate the range you want to drop, which might be nontrivial. In the worst case you will need to use several such shell scripts in order to drop the desired range of dates.
Further, please note that in my case the partitions had four keys (year, month, day, hour). If your dates/partitions are coded as strings (not a good idea in my opinion), you will have to 'build' your target string out of the variables y, m, d and h in the shell script, and plot the string inside the echo command. By the way, the dummy partition (containing only 0s) is just there in order to write easily by means of 3-4 loops the whole 'ALTER TABLE' command, which has a special syntax.
hadoop的Linux操作的更多相关文章
- Tutorial 01_熟悉常用的Linux操作和Hadoop操作
(一)熟悉常用的Linux 操作cd 命令:切换目录 (1) 切换到目录“/usr/local” (2) 切换到当前目录的上一级目录 (3) 切换到当前登录Linux 系统的用户的自己的主文件夹 ...
- 大数据Hadoop平台安装及Linux操作系统环境配置
配置 Linux 系统基础环境 查看服务器的IP地址 设置服务器的主机名称 hostnamectl set-hostname hadoop hostname可查看 绑定主机名与IP 地址 vim /e ...
- 云计算分布式大数据Hadoop实战高手之路第八讲Hadoop图文训练课程:Hadoop文件系统的操作实战
本讲通过实验的方式讲解Hadoop文件系统的操作. “云计算分布式大数据Hadoop实战高手之路”之完整发布目录 云计算分布式大数据实战技术Hadoop交流群:312494188,每天都会在群中发布云 ...
- Hadoop伪分布模式操作
http://blog.csdn.net/wangloveall/article/details/20195813 摘要:本文介绍Hadoop伪分布模式操作,适合于Hadoop学习.开发和调试. 关键 ...
- Linux操作系统主机名(hostname)简介
http://www.jb51.net/LINUXjishu/10938.html 摘要:本文是关于Linux操作系统主机名(hostname)的文档,对主要配置文件/etc/hosts进行简要的说明 ...
- 专家解读Linux操作系统内核中的GCC特性
专家解读Linux操作系统内核中的GCC特性 Linux内核使用GNU Compiler Collection (GCC)套件的几个特殊功能.这些功能包括提供快捷方式和简化以及向编译器提供优化提示 ...
- 【Linux操作系统分析】设备驱动处理流程
1 驱动程序,操作系统,文件系统和应用程序之间的关系 字符设备和块设备映射到操作系统中的文件系统,由文件系统向上提供给应用程序统一的接口用以访问设备. Linux把设备视为文件,称为设备文件,通过对设 ...
- Linux操作系统进程模型分析进程
Linux操作系统简介 Linux拥有现代操作系统的功能,如真正的抢先式多任务处理,支持多用户内存,保护虚拟内存,支持SMP.UP,符合POSIX 标准联网.图形用户接口和桌面环境具有快速性.稳定性等 ...
- awk、grep、sed是linux操作文本的三大利器,也是必须掌握的linux命令之一
awk.grep.sed是linux操作文本的三大利器,也是必须掌握的linux命令之一.三者的功能都是处理文本,但侧重点各不相同,其中属awk功能最强大,但也最复杂.grep更适合单纯的查找或匹配文 ...
随机推荐
- c# ref和out参数
向方法传递参的时候,对应的参数通常会用实参的拷贝来初始化.就是说随便在方法内部进行怎样的修改,都不会影响作为参数传递的变量的原始值. 通过上面的例子我们可以看出来,如果一个方法的参数是引用类型,那么使 ...
- The Little Prince-11/28
The Little Prince-11/28 Today I find some beautiful words from the book. You know -- one loves the s ...
- 怎样从外网访问内网Tomcat?
本地安装了一个Tomcat,只能在局域网内访问,怎样从外网也能访问到本地的Tomcat呢?本文将介绍具体的实现步骤. 准备工作 安装并启动Tomcat 默认安装的Tomcat端口是8080. 实现步骤 ...
- Docker学习笔记之镜像与容器
0x00 概述 镜像和容器作为 Docker 里最基础的概念,我们很有必要了解 Docker 对它们的很多定义以及其他与它们有关的知识.在这一小节里,我们就专门针对镜像与容器两个概念展开,细致的梳理与 ...
- PHP实现的自定义图像居中裁剪函数示例
图像居中裁减的大致思路: 1.首先将图像进行缩放,使得缩放后的图像能够恰好覆盖裁减区域.(imagecopyresampled ― 重采样拷贝部分图像并调整大小) 2.将缩放后的图像放置在裁减区域中间 ...
- php stomp.dll 下载地址
http://pecl.php.net/package/stomp/1.0.9/windows 查看方法,打开phpinfo
- 注册登录二合一之bootstrap
来源 https://bootsnipp.com/snippets/featured/login-and-register-tabbed-form jquery插件 需导入bootstrap插件 这个 ...
- P2336 [SCOI2012]喵星球上的点名(后缀自动机+莫队+dfs序)
P2336 [SCOI2012]喵星球上的点名 名字怎么存?显然是后缀自动机辣 询问点到多少个喵喵喵其实就是 查询后缀自动机上parent树的一个子树 于是我们考虑莫队 怎么树上莫队呢 我们用dfs序 ...
- nginx按日期分割日志
#!/bin/bash # Program:chenglee # Auto cut nginx log script. LOGS_PATH="/usr/local/nginx1.13/log ...
- centos7 install fastdfs nginx
https://github.com/judasn/Linux-Tutorial/blob/master/markdown-file/FastDFS-Nginx-Lua-GraphicsMagick. ...