hbase balance命令相关

  • Post author:
  • Post category:其他


balance主要有四个命令

balance_switch  balancer  balancer_enabled  balance_rsgroup(如果开启了rsgroup)



1. balance_switch

hbase帮助信息:

hbase(main):001:0> help ‘balance_switch’

Enable/Disable balancer. Returns previous balancer state.

Examples:

hbase> balance_switch true

hbase> balance_switch false

开启或关闭自动 balance, 返回的是之前的状态, 切记, 切记, 返回的是之前的状态, 我就是想当然的以为是当前状态, 结果闹了好多笑话.

这里面还需要注意的一点就是, 帮助信息里面只有 true 和 false, 而自己敲命令的时候, 写完 balance_switch 再随便跟个字母, tab键提示的时候会有一堆命令, 我就用了其中一个命令 balance_switch status, 还以为是查看balance当前状态的, 结果就搞笑了,  一会儿true, 一会儿false

balance_switch status 经测试, 这个命令的意思是将balance状态强制转换为false, 无论之前是true还是false,

返回

的是之前的状态, 所以一会儿true, 一会儿false, 所以这个命令很鸡肋, 别乱用, 查看当前状态的命令是balancer_enabled, 后面说



2. balancer

hbase帮助信息:

hbase(main):027:0* help ‘balancer’

Trigger the cluster balancer. Returns true if balancer ran and was able to

tell the region servers to unassign all the regions to balance  (the re-assignment itself is async).

Otherwise false (Will not run if regions in transition).

这个命令是手动执行一次整个集群的balance, 如果执行成功了就会返回true, 如果因为某些原因没执行成功, 返回false



3. balancer_enabled

hbase(main):032:0* help ‘balancer_enabled’

Query the balancer’s state.

Examples:

hbase> balancer_enabled

查看当前balancer的状态, 这个命令才是真正查询balancer状态的.



4. balance_rsgroup(如果)

这个命令只有开启了rsgroup才会有

hbase帮助信息:

hbase(main):033:0> help ‘balance_rsgroup’

Balance a RegionServer group

Example:

hbase> balance_rsgroup ‘my_group’

应该是手动balance一次分组



总结

对于自动balance来说, 只需要关注三个命令:

balance_switch true   开启自动balance

balance_switch false  关闭自动balance

balancer_enabled      查看自动balance当前状态