hbase空间清理
hbase由于未设置TTL,导致磁盘空间占满,需要删除数据,或设置TTL。
查看磁盘空间占用情况:
$ df -m
查看磁盘空间占用情况:
$ du -sh *
最终发现是hadoop文件夹占用最高,确切说是./hadoop/tmp/dfs/data文件夹占空间最大。
根据我们自己的业务情况,容易判断出是hbase不断写入导致的问题,通过查看hdfs得到验证:
$ ./hadoop fs -du -h /
12.9 G /hbase
78.3 K /tmp
设置hbase表的TTL, 30天
$ ./hbase shell
hbase> desc 'ns1:t1'
hbase> disable 'ns1:t1'
hbase> alter 'ns1:t1', {NAME => 'n1', TTL => '2592000'}, {NAME => 'n2', TTL => '2592000'}
hbase> enable 'ns1:t1'
设置成功后,hbase自动将过期数据删除,进行合并region操作。磁盘空间得以释放。
遇到问题
Connection refused
与网上查到的问题不太一样,我碰到的问题现状是hbase shell可以正常启动,执行list命令OK,但是执行desc命令时就报错Connection refused
查看hbase日志,发现hbase-xxx-regionserver-xxx.log日志中,显示regionserver有异常。
org.apache.hadoop.ipc.RemoteException(java.io.IOException): File xxx could only be replicated to 0 nodes instead of minReplication (=1). There are 1 datanode(s) running and no node(s) are excluded in this operation.
这个异常没有仔细定位,感觉同样是因为资源占满问题导致的。查看hbase的进程,果然只有master,没有regionserver。
$ ps -aux | grep hbase
重新启动hbase,会提示master进程已存在,并继续启动regionserver进程。
$ start-hbase.sh
regionserver进程启动成功后,该问题解决,可以正常操作hbase。如果regionserver仍然报上面的异常,可先释放部分磁盘空间,再进行尝试。
其它清理方式
使用hbase shell命令,删除数据。如果按行删除,需要先查再删,而且删除速度过慢;如果删除所有,则丢失最新数据。
暴力处理hdfs文件。因为开始hbase shell命令无法正常使用,因此查阅一些暴力删除hdfs中hbase文件方式,删除data的同时,应该还要处理tmp文件等,没有进行尝试。
---------------------
作者:量子人生
来源:CSDN
原文:https://blog.csdn.net/unifirst/article/details/54977004
版权声明:本文为博主原创文章,转载请附上博文链接!