一、Apache 和 Apache 集群间数据拷贝
1)scp 实现两个远程主机之间的文件复制
scp -r hello.txt root@hadoop103:/user/atguigu/hello.txt // 推 push
scp -r root@hadoop103:/user/atguigu/hello.txt hello.txt // 拉 pull
scp -r root@hadoop103:/user/atguigu/hello.txt root@hadoop104:/user/atguigu //是通过本地主机中转实现两个远程主机的文件复制;如果在两个远程主机之间 ssh 没有配置的情况下可以使用该方式。
2)采用 distcp 命令实现两个 Hadoop 集群之间的递归数据复制
[atguigu@hadoop102 hadoop-3.1.3]$ bin/hadoop distcp
hdfs://hadoop102:8020/user/atguigu/hello.txt
hdfs://hadoop105:8020/user/atguigu/hello.txt
二、MapReduce 生产经验
1、MapReduce 跑的慢的原因
MapReduce 程序效率的瓶颈在于两点:
1)计算机性能
CPU、内存、磁盘、网络
2)I/O 操作优化
(1)数据倾斜
(2)Map 运行时间太长,导致 Reduce 等待过久
(3)小文件过多
2、MapReduce 常用调优参数
MapReduce优化(上)
3、MapReduce 数据倾斜问题
1)数据倾斜现象
数据频率倾斜——某一个区域的数据量要远远大于其他区域。
数据大小倾斜——部分记录的大小远远大于平均值。
2)减少数据倾斜的方法
(1)首先检查是否空值过多造成的数据倾斜
生产环境,可以直接过滤掉空值;如果想保留空值,就自定义分区,将空值加随机数打散。最后再二次聚合。