hbase/hadoop异常:No lease on /hbase/archive/data/... File is not open for writing

问题描述

我在进行hbase快照拷贝时报了以下错误:

./hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot "MODEL.THIRD_PARTY_KV-11211752-snapshot" -copy-from hdfs://fromIP:9000/hbase -copy-to hdfs://toIP:9000/hbase -mappers 40 -bandwidth 300


错误日志;

org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException:No lease on /hbase/archive/data/... File is not open for writing
//省略

原因及解决方法

  • 调整HDFS中配置参数dfs.datanode.max.transfer.threads,默认为4096过小。

最大传输线程数:参数是一起配置的为: dfs.datanode.max.transfer.threads对于datanode来说,就如同linux上的文件句柄的限制,当datanode 上面的连接数操作配置中的设置时,datanode就会拒绝连接。 一般都会将此参数调的很大,40000+左右。

  • 确保Linux配置正确,文件句柄数等:
$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1032730
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 655350
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1032730
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

调整参数的同时,我又减小了mapper的数量,以减少hadoop打开文件数:

./hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot "MODEL.THIRD_PARTY_KV-11211752-snapshot" -copy-from hdfs://fromIP:9000/hbase -copy-to hdfs://toIP:9000/hbase -mappers 15 -bandwidth 300

在调整了参数后,可以正常复制快照了。但是复制进度显示100%后,又报了一个错误:

2019-11-21 18:53:39,276 [ERROR] SnapshotReferenceUtil:313 Can't find hfile: 6f2f41f1cbbf466cb3d7ac1f8de29928 in the real (hdfs://IP:9000/hbase/data/MODEL/tablename/c53079e0bbaa70280301dca7e5eee1f4/0/6f2f41f1cbbf466cb3d7ac1f8de29928) or archive (hdfs://IP:9000/hbase/archive/data/MODEL/tablename/c53079e0bbaa70280301dca7e5eee1f4/0/6f2f41f1cbbf466cb3d7ac1f8de29928) directory for the primary table.

原因

该问题的原因是从源集群复制过来的文件在目标集群上不存在,检查目标集群,可发现目标集群的NameNode上有出现未找到的文件,也就是说文件原来是存在的,但过程中又被删除了。

解决办法

在快照未建立之前,HBase会定期清理archive目录下的数据。实测也正是如此,可将“org.apache.hadoop.hbase.master.cleaner.CleanerChore”的DEBUG日志打开,以观察文件被删除痕迹(修改HBase的log4j.properties)。

log4j.logger.org.apache.hadoop.hbase.master.cleaner.CleanerChore=DEBUG

CleanerChore线程清理archive目录是通过配置项hbase.master.hfilecleaner.ttl控制的,默认是5分钟(单位:毫秒),大表的文件迁移远超5分钟。将hbase.master.hfilecleaner.ttl调到两小时的足够大值后,问题消失。

发布了233 篇原创文章 · 获赞 211 · 访问量 90万+

猜你喜欢

转载自blog.csdn.net/fgyibupi/article/details/103188808