왜 사용 하둡
대량의 데이터를, 필요에 따라 계산 (CPU 집약적) 및 고속 처리 결과는 종래의 실시를 사용하여 얻어진 (예컨대 단일 노드 스레드 빠른 결과를 얻을 수없는 동시에 실행은 전체 CPU 사용률을 달성 할 수있다)이 여러 프로세스를 사용해야하고 여러 노드에 분산 될 때, 그래서 다수의 CPU는 달성하기 위해 수행하는 연산 (집중 CPU)와 빠른 처리 목적.
이 문제를 해결하려면
HDFS (하둡 분산 파일 시스템, 하둡 분산 파일 시스템) : 각 노드에 저장된 많은 양의 데이터
맵리 듀스 (분산 데이터 분석 모델) : 쓰기에 모델 프로그램, 원사에 다음 스케줄러는 스케줄링은 모든 노드에 이루어집니다
원사 (관리 리소스 예약) : 항아리 패키지에 각 노드에 할당하고, 항아리를 실행 (컨테이너라고 함) 자원의 일부 리소스를 적용
특정 응용 프로그램 기능 시나리오 :
분석을위한 대규모 로그 파일
도 HDFS 데이터 기록 과정 :
네임 노드는 : 관리 노드, 위치 정보는 데이터 노드에있는 파일에 저장됩니다
데이터 노드는 : 분할 각 파일 저장 후, 노드 작업
봄 부팅 작업 HDFS 도구 (출처 주소 : https://gitee.com/SnailPu/springBootDemo ) :
/**
* 在对hdfs进行操作时,因为Windows下的用户原因,发生异常(org.apache.hadoop.security.AccessControlException),需要对hdfs权限设置
* 参考文章:https://blog.csdn.net/wang7807564/article/details/74627138
*/
@Component
public class HdfsUtils {
@Value("${hdfs.path}")
private String hdfsPath;
@Value("${hdfs.username}")
private String hdfsUsername;
private static final int bufferSize = 1024 * 1024 * 64;
/**
* 获取HDFS配置信息
*/
private Configuration getConfiguration() {
Configuration configuration = new Configuration();
//使用Hadoop的core-site中的fs.defaultFS参数,防止...file///...错误的出现
configuration.set("fs.defaultFS", hdfsPath);
return configuration;
}
/**
* 获取HDFS文件系统对象
*/
public FileSystem getFileSystem() throws Exception {
// 客户端去操作hdfs时是有一个用户身份的,默认情况下hdfs客户端api会从jvm中获取一个参数作为自己的用户身份
// DHADOOP_USER_NAME=hadoop
// 也可以在构造客户端fs对象时,通过参数传递进去
// FileSystem fileSystem = FileSystem.get(new URI(hdfsPath), getConfiguration(), hdfsName);
FileSystem fileSystem = FileSystem.get(getConfiguration());
return fileSystem;
}
/**
* 拼接路径为hdfs中的
*
* @param path 路径参数
*/
public String pathInHdfs(String path) {
return hdfsPath + path;
}
/**
* 创建目录
*
* @param path
* @return
* @throws Exception
*/
public boolean mkdir(String path) throws Exception {
FileSystem fs = getFileSystem();
String pathInHdfs = pathInHdfs(path);
boolean b = fs.mkdirs(new Path(pathInHdfs));
return b;
}
/**
* 判断HDFS文件或目录是否存在,使用新创建的fs
*
* @param path
* @return
* @throws Exception
*/
public boolean exits(String path) throws Exception {
if (StringUtils.isEmpty(path)) {
return false;
}
FileSystem fs = getFileSystem();
try {
Path srcPath = new Path(pathInHdfs(path));
boolean isExists = fs.exists(srcPath);
return isExists;
} finally {
fs.close();
}
}
/**
* 判断HDFS文件或目录是否存在,使用外部传入的fs,不关闭,由外部方法关闭
* 重载 exits
*
* @param path
* @return
* @throws Exception
*/
public boolean exits(String path, FileSystem fs) throws Exception {
if (StringUtils.isEmpty(path)) {
return false;
}
Path srcPath = new Path(pathInHdfs(path));
boolean isExists = fs.exists(srcPath);
return isExists;
}
/**
* 删除HDFS文件或目录
*
* @param path
* @return
* @throws Exception
*/
public Boolean deleteFile(String path) throws Exception {
if (StringUtils.isEmpty(path)) {
return false;
}
FileSystem fs = getFileSystem();
if (!exits(path, fs)) {
return false;
}
try {
Path srcPath = new Path(pathInHdfs(path));
boolean isOk = fs.deleteOnExit(srcPath);
return isOk;
} finally {
fs.close();
}
}
}
일반적인 프로세스 파일 시스템의 소스를 가져옵니다 :
작업 제출 워크 플로우의 맵리 듀스 :
-
ResourceManger : 클러스터 리소스 및 작업 일정, 등록 등의 관리에 대한 책임
-
NodeManger : ResourceManger에 모니터 리소스 사용 실행 작업 컨테이너 및 보고서
- yarn在的集群中有resourceManger和nodeManger进程,负责完成对资源的调度分配(container硬件资源,文件资源)。yarn这样的设计,是为了承载更多的运算方式,如MapReduce,spark,strom。
- MapReduce负责程序的具体运行,MRAppMaster决定不同的机器运行完成map或者reduce任务
- 提交运行过程中,会依次增加RunJar,MRAppMaster,YarnChild进程
yarn资源调度器队列介绍与配置参考:http://itxw.net/article/376.html
MRAPPMaster与Map、Reduce间的关系和工作流程
(持续更新,敬请期待!!8.9)