初学hadoop之linux系统操作的hdfs的常用命令

Hadoop之HDFS文件操作

Hadoop fs命令详解

官网doc

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操作的更多相关文章

  1. Tutorial 01_熟悉常用的Linux操作和Hadoop操作

    (一)熟悉常用的Linux 操作cd 命令:切换目录 (1) 切换到目录“/usr/local” (2) 切换到当前目录的上一级目录 (3) 切换到当前登录Linux 系统的用户的自己的主文件夹  ...

  2. 大数据Hadoop平台安装及Linux操作系统环境配置

    配置 Linux 系统基础环境 查看服务器的IP地址 设置服务器的主机名称 hostnamectl set-hostname hadoop hostname可查看 绑定主机名与IP 地址 vim /e ...

  3. 云计算分布式大数据Hadoop实战高手之路第八讲Hadoop图文训练课程:Hadoop文件系统的操作实战

    本讲通过实验的方式讲解Hadoop文件系统的操作. “云计算分布式大数据Hadoop实战高手之路”之完整发布目录 云计算分布式大数据实战技术Hadoop交流群:312494188,每天都会在群中发布云 ...

  4. Hadoop伪分布模式操作

    http://blog.csdn.net/wangloveall/article/details/20195813 摘要:本文介绍Hadoop伪分布模式操作,适合于Hadoop学习.开发和调试. 关键 ...

  5. Linux操作系统主机名(hostname)简介

    http://www.jb51.net/LINUXjishu/10938.html 摘要:本文是关于Linux操作系统主机名(hostname)的文档,对主要配置文件/etc/hosts进行简要的说明 ...

  6. 专家解读Linux操作系统内核中的GCC特性

    专家解读Linux操作系统内核中的GCC特性   Linux内核使用GNU Compiler Collection (GCC)套件的几个特殊功能.这些功能包括提供快捷方式和简化以及向编译器提供优化提示 ...

  7. 【Linux操作系统分析】设备驱动处理流程

    1 驱动程序,操作系统,文件系统和应用程序之间的关系 字符设备和块设备映射到操作系统中的文件系统,由文件系统向上提供给应用程序统一的接口用以访问设备. Linux把设备视为文件,称为设备文件,通过对设 ...

  8. Linux操作系统进程模型分析进程

    Linux操作系统简介 Linux拥有现代操作系统的功能,如真正的抢先式多任务处理,支持多用户内存,保护虚拟内存,支持SMP.UP,符合POSIX 标准联网.图形用户接口和桌面环境具有快速性.稳定性等 ...

  9. awk、grep、sed是linux操作文本的三大利器,也是必须掌握的linux命令之一

    awk.grep.sed是linux操作文本的三大利器,也是必须掌握的linux命令之一.三者的功能都是处理文本,但侧重点各不相同,其中属awk功能最强大,但也最复杂.grep更适合单纯的查找或匹配文 ...

随机推荐

  1. 使用QFileDiaglog实战designer快速开发

    今天遇到一个大坑很久才解决 使用designer开发出图形界面转换为py文件后,使用QFileDialog对话框第一个参数一定要是当前窗口组件,否则程序直接奔溃(坑:能运行不报错但奔溃) def ge ...

  2. TensorFlow 1.2.0新版本完美支持Python3.6,windows在cmd中输入pip install tensorflow就能下载应用最新tensorflow

    TensorFlow 1.2.0新版本完美支持Python3.6,windows在cmd中输入pip install tensorflow就能下载应用最新tensorflow 只需在cmd中输入pip ...

  3. 2、在VM上的 CentOS 6.5 上安装mysql

    1.查看系统是否安装了MySQL     使用命令:     #rpm -qa | grep mysql 2.卸载已安装的MySQL      卸载mysql命令如下:       #rpm -e - ...

  4. win10自带虚拟机Hyper V联网

      在控制面板里打开程序和功能     打开启用或关闭windows 功能     勾选Hyper-V     在windows 管理工具打开Hyper-V 管理器   打开虚拟交换机管理器     ...

  5. API gateway 之 kong 安装

    kong安装: https://getkong.org/install/centos/ 下载指定版本rpm: wget https://bintray.com/kong/kong-community- ...

  6. python的一些遗漏用法

    一. 补充基础数据类型的相关知识点 1. str. join() 把列表变成字符串 li = ["李嘉诚", "麻花藤", "⻩海峰", & ...

  7. EditPlus配置GCC

    --GCC Compile-- 命令:D:\GCC\MinGW_RP_Green\bin\gcc.exe 参数:$(FileName) -o $(FileNameNoExt).exe 初始目录:$(F ...

  8. excel 方框打钩

    将光标定位于需要打钩的地方,选择[插入]→[符号]→[其他符号] 在弹出的符号栏里,字体一定要改成[Windings2] 然后在符号栏便可以找到现成的打钩样式,点击插入,再关闭即可 提示:如果需要打叉 ...

  9. django变量使用-在模板中使用视图函数中的变量

    DTL语言,即django template language 第一次使用时,需要修改项目的setting.py文件,将其中TEMPLATES中的DIRS修改为os.path.join(BASE_DI ...

  10. Python3 WebDriver操作cookie的方法

    Python3 WebDriver操作cookie的方法 WebDriver提供了操作Cookie的相关方法,可以读取.添加和删除cookie信息. WebDriver操作cookie的方法: get ...