Docker 安装Hadoop HDFS命令行操作
网上拉取Docker模板,使用singlarities/hadoop镜像
[root@localhost /]# docker pull singularities/hadoop
查看:
[root@localhost /]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/singularities/hadoop latest e213c9ae1b36 months ago 1.19 GB
创建docker-compose.yml文件,内容:
version: "" services:
namenode:
image: singularities/hadoop
command: start-hadoop namenode
hostname: namenode
environment:
HDFS_USER: hdfsuser
ports:
- "8020:8020"
- "14000:14000"
- "50070:50070"
- "50075:50075"
- "10020:10020"
- "13562:13562"
- "19888:19888"
datanode:
image: singularities/hadoop
command: start-hadoop datanode namenode
environment:
HDFS_USER: hdfsuser
links:
- namenode
执行:
[root@localhost hadoop]# docker-compose up -d
Creating network "hadoop_default" with the default driver
Creating hadoop_namenode_1 ... done
Creating hadoop_datanode_1 ... done
4个datanode:
[root@localhost hadoop]# docker-compose scale datanode=
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
Starting hadoop_datanode_1 ... done
Creating hadoop_datanode_2 ... done
Creating hadoop_datanode_3 ... done
[root@localhost hadoop]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
19f9685e286f singularities/hadoop "start-hadoop data..." seconds ago Up seconds /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp hadoop_datanode_3
e96b395f56e3 singularities/hadoop "start-hadoop data..." seconds ago Up seconds /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp hadoop_datanode_2
5a26b1069dbb singularities/hadoop "start-hadoop data..." minutes ago Up minutes /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp, /tcp hadoop_datanode_1
a8656de09ecc singularities/hadoop "start-hadoop name..." minutes ago Up minutes 0.0.0.0:->/tcp, 0.0.0.0:->/tcp, 0.0.0.0:->/tcp, 0.0.0.0:->/tcp, /tcp, /tcp, 0.0.0.0:->/tcp, 0.0.0.0:->/tcp, /tcp, /tcp, /tcp, 0.0.0.0:->/tcp, /tcp hadoop_namenode_1
[root@localhost hadoop]#
效果图;
hdfs基础命令:
1、创建目录
hadoop fs -mkdir /hdfs #在根目录下创建hdfs文件夹
2、查看目录
>hadoop fs -ls / #列出跟目录下的文件列表
drwxr-xr-x - root supergroup -- : /hdfs
3、级联创建目录
>hadoop fs -mkdir -p /hdfs/d1/d2
4、级联列出目录
>hadoop fs -ls -R /
drwxr-xr-x - root supergroup -- : /hdfs
drwxr-xr-x - root supergroup -- : /hdfs/d1
drwxr-xr-x - root supergroup -- : /hdfs/d1/d2
5、上传本地文件到HDFS
>echo "hello hdfs" >>local.txt
>hadoop fs -put local.txt /hdfs/d1/d2
6、查看HDFS中文件的内容
>hadoop fs -cat /hdfs/d1/d2/local.txt
hello hdfs
7、下载hdfs上文件的内容
>hadoop fs -get /hdfs/d1/d2/local.txt
8、删除hdfs文件
>hadoop fs -rm /hdfs/d1/d2/local.txt
Deleted /hdfs/d1/d2/local.txt
9、删除hdfs中目录
>hadoop fs -rmdir /hdfs/d1/d2
10、修改文件的权限
>hadoop fs -ls /hdfs
drwxr-xr-x - root supergroup -- : /hdfs/d1 #注意文件的权限
>hadoop fs -chmod /hdfs/d1
drwxrwxrwx - root supergroup -- : /hdfs/d1 #修改后
11、修改文件所属的用户
>hadoop fs -chown admin /hdfs/d1 #修改文件所属用户为admin
>hadoop fs -ls /hdfs
drwxrwxrwx - admin supergroup -- : /hdfs/d1
12、修改文件的用户组
>hadoop fs -chgrp admin /hdfs/d1
>hadoop fs -ls /hdfs
drwxrwxrwx - admin admin -- : /hdfs/d1
查看所有命令方式:
root@master:/# hadoop fs
Usage: hadoop fs [generic options]
[-appendToFile <localsrc> ... <dst>]
[-cat [-ignoreCrc] <src> ...]
[-checksum <src> ...]
[-chgrp [-R] GROUP PATH...]
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]
[-chown [-R] [OWNER][:[GROUP]] PATH...]
[-copyFromLocal [-f] [-p] [-l] [-d] <localsrc> ... <dst>]
[-copyToLocal [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-count [-q] [-h] [-v] [-t [<storage type>]] [-u] [-x] <path> ...]
[-cp [-f] [-p | -p[topax]] [-d] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> ...]]
[-du [-s] [-h] [-x] <path> ...]
[-expunge]
[-find <path> ... <expression> ...]
[-get [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-getfacl [-R] <path>]
[-getfattr [-R] {-n name | -d} [-e en] <path>]
[-getmerge [-nl] [-skip-empty-file] <src> <localdst>]
[-help [cmd ...]]
[-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [<path> ...]]
[-mkdir [-p] <path> ...]
[-moveFromLocal <localsrc> ... <dst>]
[-moveToLocal <src> <localdst>]
[-mv <src> ... <dst>]
[-put [-f] [-p] [-l] [-d] <localsrc> ... <dst>]
[-renameSnapshot <snapshotDir> <oldName> <newName>]
[-rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ...]
[-rmdir [--ignore-fail-on-non-empty] <dir> ...]
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]
[-setfattr {-n name [-v value] | -x name} <path>]
[-setrep [-R] [-w] <rep> <path> ...]
[-stat [format] <path> ...]
[-tail [-f] <file>]
[-test -[defsz] <path>]
[-text [-ignoreCrc] <src> ...]
[-touchz <path> ...]
[-truncate [-w] <length> <path> ...]
[-usage [cmd ...]] Generic options supported are
-conf <configuration file> specify an application configuration file
-D <property=value> use value for given property
-fs <file:///|hdfs://namenode:port> specify default filesystem URL to use, overrides 'fs.defaultFS' property from configurations.
-jt <local|resourcemanager:port> specify a ResourceManager
-files <comma separated list of files> specify comma separated files to be copied to the map reduce cluster
-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.
-archives <comma separated list of archives> specify comma separated archives to be unarchived on the compute machines. The general command line syntax is
command [genericOptions] [commandOptions]
进入一个容器内部进行上述操作,再进入其他的容器,可以发现数据同步了,另外一个节点的操作其他节点也可以看见。
参考:
https://github.com/SingularitiesCR/hadoop-docker
http://www.tianshouzhi.com/api/tutorials/hadoop/129
Docker 安装Hadoop HDFS命令行操作的更多相关文章
- 小记---------有关hadoop的HDFS命令行操作
HDFS命令操作 首先需要在xshell启动hadoop start-all.sh or start-hdfs.sh hadoop fs -ls / (显示当前目录下所有文件) h ...
- HDFS命令行操作
启动后可通过命令行使用hadoop. (1)所有命令 (先将$HADOOP_HOME/bin加入到.bashrc的$PATH变量中) [html] view plaincopy [hadoop@nod ...
- Git入门(安装及基础命令行操作)
一.安装 1.Mac 在Mac中安装Git的方法不止一种.最简单的要数通过Xcode命令行工具.对于Mavericks(10.9)或更高版本的操作系统,当你第一次尝试在终端执行git命令时,系统会自动 ...
- hadoop hdfs 命令行 设置文件夹大小的上限 quota:配额
>bin/hdfs dfs -put readme.txt /finance >bin/hdfs dfs -du -s /finance > /finance >bin/hdf ...
- Hadoop系列006-HDFS概念及命令行操作
本人微信公众号,欢迎扫码关注! HDFS概念及命令行操作 一.HDFS概念 1.1 概念 HDFS,它是一个文件系统,用于存储文件,通过目录树来定位文件:其次,它是分布式的,由很多服务器联合起来实现其 ...
- HDFS分布式文件系统的常用命令行操作
一.HDFS的客户端种类 1.网页形式 =>用于测试 网址为你的namenode节点的ip+50070的端口号,如: 192.168.50.128:50070 2.命令行形式 =>用于测 ...
- HDFS命令行及JAVA API操作
查看进程 jps 访问hdfs: hadoop-root:50070 hdfs bash命令: hdfs dfs <1> -help: 显示命令的帮助的信息 <2> - ...
- kafka工作流程| 命令行操作
1. 概述 数据层:结构化数据+非结构化数据+日志信息(大部分为结构化) 传输层:flume(采集日志--->存储性框架(如HDFS.kafka.Hive.Hbase))+sqoop(关系型数 ...
- docker安装hadoop集群
docker安装hadoop集群?图啥呢?不图啥,就是图好玩.本篇博客主要是来教大家如何搭建一个docker的hadoop集群.不要问 为什么我要做这么无聊的事情,答案你也许知道,因为没有女票.... ...
随机推荐
- hive-drop-import-delims选项对oracle的clob无效
工作过程中发现了用sqoop将oracle中的数据导入到hive时,会因为oracle中类型为clob的字段中存在换行时,会造成hive的数据错位.即使加上了 --hive-drop-import-d ...
- c#Lock学习笔记
转自 http://www.cnblogs.com/tianma3798/p/6290158.html 参考官网 https://docs.microsoft.com/zh-cn/dotnet/cs ...
- ABC2
OpenCV http://www.cnblogs.com/skyfsm/p/7263773.html http://www.cnblogs.com/skyfsm/p/7613314.html SQL ...
- leetCodelinked-list-cycle-ii找到链表的环
题目 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. N ...
- jQuery选择器--:selected和:checked
:selected 概述 匹配所有选中的option元素 <!DOCTYPE html> <html> <head> <meta charset=" ...
- android手机平板如何使用usb有线网卡
最近有个项目需要在android平板上使用usb有线网卡,所以做了一部分工作,在这里简单总结一下. 我在TB上购买了一个micro-usb接口的android免驱有线网卡,这个网上很多,随便买一个符合 ...
- 【JavaScript 6连载】四、apply和call的用法
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- QPointer,QSharedPointer,QWeakPointer的区别
QPointer,QSharedPointer,QWeakPointer的区别与使用例子(QSharedPointer类似Delphi里的引用计数,是强引用,而QWeakPointer是弱引用,不影响 ...
- scala语言中的case关键字在spark中的一个奇特使用
package com.spark.demo import com.spark.demo.util.SparkUtil import org.apache.spark.rdd.RDD import s ...
- 全球最大的3D数据集公开了!标记好的10800张全景图
Middlebury数据集 http://vision.middlebury.edu/stereo/data/ KITTI数据集简介与使用 https://blog.csdn.net/solomon1 ...