Closed mattshma closed 8 years ago
上面方法有误。
对于磁盘A,其挂载在/hadoop上,若有/hadoop/dfs和/hadoop/dfs1两个目录,/hadoop/dfs用于该datanode使用,/hadoop/dfs1被NFS挂载,若现在umount nfs,不应该只是单纯的改/hadoop/dfs1的datanodeuuid,让DataNode用一块盘的两个目录。而是应该一个DN用一块盘,两个目录的数据需要进行合并,原因见 #4。
正常的做法是将数据在磁盘内做移动。然后重启datanode服务即可。
磁盘内迁移脚本如下:
#/bin/bash
for k in {0..11}
do
if [ $k -eq 0 ]; then
k=""
fi
rbwdir=dn/current/BP-1471860497-10.2.72.29-1421306158975/current/rbw
ddir=dn/current/BP-1471860497-10.2.72.29-1421306158975/current/finalized
for i in {0..64}
do
echo /hadoop$k/subdir$i
for j in {0..64}
do
# echo subdir$i
dndir=${ddir}/subdir$i
dnsdir=${dndir}/subdir$j
if [ -d /hadoop$k/dfs1/$dnsdir ] && [ "$(ls -A /hadoop$k/dfs1/$dnsdir)" ];then
if [ -d /hadoop$k/dfs/$dnsdir ];then
mv /hadoop$k/dfs1/$dnsdir/blk_* /hadoop$k/dfs/$dnsdir
else
mv /hadoop$k/dfs1/$dnsdir /hadoop$k/dfs/$dndir
fi
fi
done
if [ -d /hadoop$k/dfs1/$dndir ] && [ "$(ls -A /hadoop$k/dfs1/$dndir)" ];then
mv /hadoop$k/dfs1/$dndir/blk_* /hadoop$k/dfs/$dndir
fi
done
if [ -d /hadoop$k/dfs1/$ddir ] && [ "$(ls -A /hadoop$k/dfs1/$ddir)" ];then
mv /hadoop$k/dfs1/$ddir/blk_* /hadoop$k/dfs/$ddir
fi
if [ "$(ls -A /hadoop$k/dfs/$rbwdir)" ];then
mv /hadoop$k/dfs1/$rbwdir/* /hadoop$k/dfs/$rbwdir
fi
done
由于很早前rebalancer速度太慢,加了几个虚拟机机器,然后将datanode中磁盘使用少的机器以nfs形式挂载到虚拟机上,再做rebalancer,后来磁盘使用率够了,将nfs umount了,重新启动这几个datanode,报错如下:
看报警原因是
DatanodeUuid
不匹配导致。如下:看下HDFS-5233中storageid和datanodeuuid的定义:
即每个datanode有唯一的datanodeuuid,datanode上的每个存储有各一个唯一对应的storageid。
更多说明如下:
和
所以这里修改下VERSION中错误的datanodeuuid,然后重启cloudera-scm-agent即可。
注:注意不要删除VERSION文件,否则该VERSION同目录下的文件会在重启时被删除;另外,若修改datanodeuuid后,删除storageid的话,会因VERSION文件格式不对而启动失败。