hbase的常见运维操作
1、处理hbase的master宕机
操作命令:
./hbase-daemon.sh start master
./hbase-daemon.sh start zookeeper//可选
2、处理hbase的regionserver宕机
操作命令:
./hbase-daemon.sh start regionserver
./hbase-deamon.sh start zookeeper//可选
3、hbase集群间数据迁移方法总结
一、需要在hbase集群停掉的情况下迁移
步骤:
(1)执行hadoop distcp -f filelist "hdfs://new cluster ip:9000/hbasetest"
(2)在new cluster执行./hbase org.jruby.main add_table.rb /hbase/table20111222,将拷贝来的表加入到.meat.中(会出现region的数目不一致的问题,这个需要重启hase才能解决)
说明:(1)filelist为hdfs上的列表文件,内容如下:
/hbase/table20111222
/hbase/table20120131
(2)如果两个集群的hadoop版本不一致,需要在new cluster上执行hadoop distcp,否则会出现读写异常;
二、在集群运行的时候进行数据迁移
1、replication:这个是动态的备份(可以理解为实时备份)
步骤:(1)在old cluster将需要迁移的表属性进行修改:
disable "your_table"
alter "your_table", {name => "family_name", replication_scope => "1"}
enable "your_table"
(2)打开new cluster集群的replication,修改hbase-site.xml
hbase.replication
true
(3)添加peer,在new cluster的hbase shell中执行:add_peer "1","old cluster ip:2181:/hbase",启动replication,执行start_replication
说明:需要两个集群的hadoop版本一致,否则出现读写错误
2、copytable:可以在本集群中拷贝一张表,也可以将表拷贝到其他的集群中。
命令:./hbase org.apache.hadoop.hbase.mapreduce.copytable --peer.adr=new cluster ip:2181:/hbase zy_test
说明:(1)拷贝完成,不需要重启机器,在new cluster中就可以看到该表;
(2)稳定性还需要考虑,测试过程中遇到一个问题,拷贝过程中始终都停留在这里lookedup root region location, 查看日志没有什么错误和相关的信息。
3、export and import
步骤:(1)在old cluster上执行:./hbase org.apache.hadoop.hbase.mapreduce.export test hdfs://new cluster ip:9000/zhuangyang/test
(2)在new cluster上执行:./hbase org.apache.hadoop.hbase.mapreduce.import test hdfs://new cluster ip:9000/zhongyao/test
说明:(1)一定要写全路径,不能写相对路劲;
(2)在import前,需要将表事先在new cluster中创建好.
以上都是在old cluster和new cluster网络相通的情况下实现数据迁移的办法。
如果两个集群网络不通,只能先将old cluster中的数据都下载到本地或者其他的地方,然后在人工的转移到new cluster上了
13.不重启namenode可以使配置文件生效
hadoop dfsadmin -refreshnodes