Hbase study notes - operation task

本文介绍了HBase中节点的增加与移除流程,包括如何停启RegionServer、使用负载均衡器、执行滚动重启等操作。同时,还详细阐述了数据导入导出工具、表复制工具及批量加载数据的方法。
[color=red][size=medium]Node Decommissioning[/size][/color]
1 $ ./bin/hbase-daemon.sh stop regionserver
Disabling the Load Balancer Before Decommissioning a Node
hbase(main):001:0> balance_switch false
hbase(main):002:0> balance_switch true
2 $ ./bin/graceful_stop.sh HOSTNAME
where HOSTNAME is the host carrying the region server you want to decommission

[color=red][size=medium]Rolling Restarts[/size][/color]
1. Unpack your release, make sure of its configuration, and then rsync it across
the cluster. If you are using version 0.90.2, patch it with HBASE-3744 and
HBASE-3756.
2. Run hbck to ensure the cluster is consistent:
$ ./bin/hbase hbck
Effect repairs if inconsistent.
3. Restart the master:
$ ./bin/hbase-daemon.sh stop master; ./bin/hbase-daemon.sh start master
4. Disable the region balancer:
$ echo "balance_switch false" | ./bin/hbase shell
5. Run the graceful_stop.sh script per region server. For example:
$ for i in `cat conf/regionservers|sort`; do ./bin/graceful_stop.sh \
--restart --reload --debug $i; done &> /tmp/log.txt &
If you are running Thrift or REST servers on the region server, pass the --thrift
or --rest option, as per the script’s usage instructions, shown earlier (i.e., run it
without any commandline options to get the instructions).
6. Restart the master again. This will clear out the dead servers list and reenable the
balancer.
7. Run hbck to ensure the cluster is consistent.

[color=red][size=large]Pseudodistributed mode[/size]
[/color]
[color=red][size=medium]Adding Servers[/size][/color]
Starting a local backup master process is accomplished by
using the local-master-backup.sh script in the bin directory, like so:
$ ./bin/local-master-backup.sh start 1
The number at the end of the command signifies an offset that is added to the default ports of 60000 for RPC and 60010 for the web-based UI. In this example, a new master process would be started that reads the same configuration files as usual, but would listen on ports 60001 and 60011, respectively.

$./bin/local-master-backup.sh start 1 3 5
This starts three backup masters on ports 60001, 60003, and 60005 for RPC, plus 60011, 60013, and 60015 for the web UIs.

Stopping the backup master(s) involves the same command, but replacing the start command with the aptly named stop, like so:
$ ./bin/local-master-backup.sh stop 1


[color=red][size=medium]Adding a local region server.[/size][/color]
$ ./bin/local-regionservers.sh start 1
This command will start an additional region server using port 60201 for RPC, and 60301 for the web UI.
Starting more than one region server is accomplished by adding more offsets:
$ ./bin/local-regionservers.sh start 1 2 3
Stopping any additional region server involves replacing the start command with the stop command:
$ ./bin/local-regionservers.sh stop 1

[color=red][size=large]Fully distributed cluster[/size][/color]

[color=red][size=medium]Adding a backup master.[/size][/color]

The master process uses ZooKeeper to negotiate which is the currently active master:
there is a dedicated ZooKeeper znode that all master processes race to create, and the first one to create it wins. This happens at startup and the winning process moves on to become the current master. All other machines simply loop around the znode check
and wait for it to disappear—triggering the race again.
The /hbase/master znode is ephemeral, and is the same kind the region servers use to
report their presence. When the master process that created the znode fails, ZooKeeper will notice the end of the session with that server and remove the znode accordingly, triggering the election process.
Starting a server on multiple machines requires that it is configured just like the rest of the HBase cluster (see “Configuration” on page 63 for details). The master servers
usually share the same configuration with the other servers in the cluster. Once you
have confirmed that this is set up appropriately, you can run the following command
on a server that is supposed to host the backup master:
$ ./bin/hbase-daemon.sh start master
Assuming you already had a master running, this command will bring up the new master to the point where it waits for the znode to be removed.* If you want to start many masters in an automated fashion and dedicate a specific server to host the current one, while all the others are considered backup masters, you can add the --backup
switch like so:
$ ./bin/hbase-daemon.sh start master --backup

Since HBase 0.90.x, there is also the option of creating a backup-masters file in the conf directory. This is akin to the regionservers file, listing one hostname per line that is supposed to start a backup master. For the example in “Example Configuration”
on page 65, we could assume that we have three backup masters running on the ZooKeeper servers. In that case, the conf/backup-masters, would contain these entries:
zk1.foo.com
zk2.foo.com
zk3.foo.com

[color=red][size=medium]Adding a region server.[/size][/color]
The first thing you should do is to edit the regionservers
file in the conf directory, to enable the launcher scripts to automat the server start and stop procedure.‡ Simply add a new line to the file specifying the hostname to add.

Then you have a few choices to start the new region server process. One option is to run the start-hbase.sh script on the master machine.

Another option is to use the launcher script directly on the new server. This is done like so:
$ ./bin/hbase-daemon.sh start regionserver

[color=red][size=large]Data Tasks[/size][/color]
[color=red][size=medium]Import and Export Tools[/size][/color]
HBase ships with a handful of useful tools, two of which are the Import and Export
MapReduce jobs. They can be used to write subsets, or an entire table, to files in HDFS,
and subsequently load them again. They are contained in the HBase JAR file and you
need the hadoop jar command to get a list of the tools:
$ hadoop jar $HBASE_HOME/hbase-0.91.0-SNAPSHOT.jar
Adding the export program name then displays the options for its usage:
$ hadoop jar $HBASE_HOME/hbase-0.91.0-SNAPSHOT.jar export
You do need to specify the parameters from left to right, and you cannot omit any inbetween.

Running the command will start the MapReduce job and print out the progress:
$ hadoop jar $HBASE_HOME/hbase-0.91.0-SNAPSHOT.jar export \
testtable /user/larsgeorge/backup-testtable

Once the job is complete, you can check the filesystem for the exported data. Use the
hadoop dfs command (the lines have been shortened to fit horizontally):
$ hadoop dfs -lsr /user/larsgeorge/backup-testtable

Importing the data is the reverse operation. First we can get the usage details by invoking
the command without any parameters, and then we can start the job with the table name and inputdir (the directory containing the exported files):
$ hadoop jar $HBASE_HOME/hbase-0.91.0-SNAPSHOT.jar import
ERROR: Wrong number of arguments: 0
Usage: Import <tablename> <inputdir>

$ hadoop jar $HBASE_HOME/hbase-0.91.0-SNAPSHOT.jar import \
testtable /user/larsgeorge/backup-testtable

[color=red][size=medium]CopyTable Tool[/size][/color]
Another supplied tool is CopyTable, which is primarily designed to bootstrap cluster replication.You can use is it to make a copy of an existing table from the master cluster to the slave cluster. Here are its command-line options:
$ hadoop jar $HBASE_HOME/hbase-0.91.0-SNAPSHOT.jar copytable
Examples:
To copy 'TestTable' to a cluster that uses replication for a 1 hour window:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable \
--rs.class=org.apache.hadoop.hbase.ipc.ReplicationRegionInterface
--rs.impl=org.apache.hadoop.hbase.regionserver.replication.ReplicationRegionServer
--starttime=1265875194289 --endtime=1265878794289
--peer.adr=server1,server2,server3:2181:/hbase TestTable

[color=red][size=medium]Bulk Import[/size][/color]
Bulk load procedure
The HBase bulk load process consists of two main steps:
Preparation of data
Load data

[color=red][size=medium]Using the importtsv tool[/size][/color]

[color=red][size=medium]Using the completebulkload Tool[/size][/color]
<think>嗯,用户遇到了一个Java程序运行时的错误,具体是执行`java -jar hbase-manager-admin-2.0.9.jar`时提示无法访问jar文件。首先,我需要分析可能的原因。 用户给出的路径是`~/software/hbase-manager-2.0.8-hbase-2.x/`,但尝试运行的jar文件版本是2.0.9,而目录名是2.0.8。这可能是一个版本不匹配的问题,用户可能下载了不同版本的jar文件,或者目录名没有更新。这时候需要检查文件名是否正确,是否存在拼写错误或者版本号不一致的情况。 接下来,用户执行命令的当前目录是否正确?用户显示的路径是在`hbase-manager-2.0.8-hbase-2.x`目录下,但可能该目录下并没有hbase-manager-admin-2.0.9.jar文件。这时候需要使用`ls`命令来确认该文件是否存在,或者是否有权限问题。 另外,文件权限也是一个常见的问题。如果jar文件没有可读权限,Java无法读取它,导致错误。这时候需要检查文件的权限设置,使用`ls -l`查看,并用`chmod`修改权限。 还有可能是文件损坏,虽然可能性较低,但如果用户下载过程中出现问题,可能导致jar文件不完整。这时候可以重新下载文件,或者检查文件的哈希值是否匹配。 综合这些可能性,我应该分步骤引导用户检查文件名、路径、权限以及文件完整性。同时,提醒用户注意版本号和目录结构的一致性,避免因路径错误导致的问题。需要确保用户能够逐步排查,找到具体原因,并给出相应的解决命令,比如ls、pwd、chmod等,帮助用户自己解决问题。</think>你遇到的错误信息 `Error: Unable to access jarfile hbase-manager-admin-2.0.9.jar` 表示 Java 无法找到或访问指定的 JAR 文件。以下是逐步排查和解决的建议: --- ### **1. 检查文件名和路径** - **现象分析**: 当前目录是 `hbase-manager-2.0.8-hbase-2.x`,但尝试运行的 JAR 文件版本为 `2.0.9`,可能存在文件名或路径不匹配。 - **操作步骤**: 在终端输入以下命令,确认 JAR 文件是否存在: ```bash ls -l hbase-manager-admin-*.jar ``` - 如果输出为空,说明文件不存在。 - 如果文件名是 `hbase-manager-admin-2.0.8.jar`,需修改命令中的版本号。 --- ### **2. 确认当前工作目录** - **现象分析**: 错误可能源于未在 JAR 文件所在目录下执行命令。 - **操作步骤**: 输入 `pwd` 确认当前目录是否为 `~/software/hbase-manager-2.0.8-hbase-2.x`。 如果不是,需切换到正确目录: ```bash cd ~/software/hbase-manager-2.0.8-hbase-2.x ``` --- ### **3. 检查文件权限** - **现象分析**: 如果 JAR 文件权限不足,Java 无法读取。 - **操作步骤**: 赋予文件可读权限: ```bash chmod +r hbase-manager-admin-2.0.9.jar ``` --- ### **4. 验证文件完整性** - **现象分析**: 文件可能因下载不完整或损坏导致无法访问。 - **操作步骤**: 重新下载 JAR 文件,或通过校验哈希值(如 MD5/SHA1)验证文件完整性。 --- ### **5. 指定绝对路径运行(备用方案)** 如果上述步骤无效,可尝试直接指定 JAR 文件的绝对路径: ```bash java -jar ~/software/hbase-manager-2.0.8-hbase-2.x/hbase-manager-admin-2.0.9.jar ``` --- ### **总结** 常见原因优先级排序: 1. **文件名或路径错误**(如版本号 `2.0.8` vs `2.0.9`) 2. **文件未正确下载或缺失** 3. **权限不足** 请按顺序排查,通常可解决问题。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值