Hypertable工具之ht_rsclient

来源:互联网 发布:mysql 存储过程 函数 编辑:程序博客网 时间:2024/04/30 14:22
命令:ht_rsclient  [rangeserver_ip:port]。
Ht_rsclient命令可连接至任意一台RangeServer,并在该台RangeServer上执行下列命令:
COMPACT ............... Schedules range compactions
CREATE SCANNER ........ Creates a scanner and displays first block of results
DESTROY SCANNER ....... Destroys a scanner
DROP RANGE ............ Drop a range
FETCH SCANBLOCK ....... Fetch the next block results of a scan
LOAD RANGE ............ Load a range
METADATA SYNC ......... Sync METADATA table with RSML data
REPLAY START .......... Start replay
REPLAY LOG ............ Replay a commit log
REPLAY COMMIT ......... Commit replay
SHUTDOWN   ............ Shutdown the RangeServer
UPDATE ................ Selects (and display) cells from a table
WAIT FOR MAINTENANCE .. Blocks until maintenance queue is empty
1. COMPACT 
COMPACT TABLE table_name
COMPACT RANGES range_type ['|' range_type ...]


range_type:
    ALL
    | ROOT
    | METADATA
    | SYSTEM
    | USER


本命令将对指定的每个Range调度执行major compaction操作。Table版本将对给定表的每个Range执行compaction,Ranges版本将对指定类型的所有Range执行compaction,不管这些Range属于哪些表。
NOTE:  Compactions scheduled by this command are spread out over time.
During each maintenance interval, which by default happens once every
60 seconds, a limited number of these compactions will get scheduled
as controlled by the following property:


  Hypertable.RangeServer.Maintenance.MoveCompactionsPerInterval


The default value for this property is 2.
1.1. COMPACT TABLE
Compact table “hyt/foo”; 执行foo表在该台RangeSever上的所有Range的compaction操作。
1.2. COMPACT RANGES
COMPACT RANGES all; //执行该台RangeServer上所有Range的compaction操作
COMPACT RANGES user //执行该台RangeServer上所有USER类型的Range的compaction操作。
2. CREATE SCANNER
CREATE SCANNER ON range_spec
    [where_clause]
    [options_spec]


range_spec:
    table_name '[' [start_row] ".." (end_row | ?? ) ']'


where_clause:
    WHERE where_predicate [AND where_predicate ...] 


where_predicate: 
    cell_predicate
    | row_predicate
    | timestamp_predicate


relop: '=' | '<' | '<=' | '>' | '>=' | '=^'


cell_spec: row_key ',' qualified_column


cell_predicate: 
    [cell_spec relop] CELL relop cell_spec
    | '(' [cell_spec relop] CELL relop cell_spec
          (OR [cell_spec relop] CELL relop cell_spec)* ')'


row_predicate: 
    [row_key relop] ROW relop row_key
    | '(' [row_key relop] ROW relop row_key
          (OR [row_key relop] ROW relop row_key)* ')'


timestamp_predicate: 
    [timestamp relop] TIMESTAMP relop timestamp


options_spec:
    (MAX_VERSIONS revision_count
    | LIMIT row_count
    | INTO FILE 'file_name'
    | DISPLAY_TIMESTAMPS
    | RETURN_DELETES
    | KEYS_ONLY
    | SCAN_AND_FILTER_ROWS)*


timestamp:
    'YYYY-MM-DD HH:MM:SS[.ss|:nanoseconds]'


本命令将创建基于一个Range的scanner。如果range_spec中缺少start_row,则意味着NULL或者改Range的开始。如果end_row指定为”??”,它将自动转换为OXff,这意味着Range的结尾。
示例: CREATE SCANNER ON “dinglicom/Test”[..??]


实验表明:
1.,语法如:ht_rsclient 172.16.23.164:38060
2.只能连接到一个Range所在的RangeServer,才能查看该Range的数据。可查询MEATDATA表获取Range的当前位置。查询MEATDATA表时,可能会看到一个Range具有多个Location,这可能是由于Range的迁移造成的,其中时间戳最新的一个即为当前Location。
3.查询Range时,需指定StartRow和EndRow。假设当METADATA结果如下时:
2013-04-15 04:57:20.861318001   2/15:key1259    StartRow
2013-04-15 04:57:20.861318004   2/15:key1259    Location        rs5
2013-04-15 04:57:20.861318005   2/15:key1541    StartRow        key1259
2013-04-15 04:04:00.309111001   2/15:key1541    StartRow
2013-04-15 04:57:21.096424001   2/15:key1541    Location        rs6
2013-04-15 04:04:00.309111004   2/15:key1541    Location        rs5
2013-04-15 04:04:00.309111005   2/15:key29      StartRow        key1541
2013-04-15 03:26:57.856186001   2/15:key29      StartRow
2013-04-15 04:04:00.415763001   2/15:key29      Location        rs7
2013-04-15 03:26:57.856186004   2/15:key29      Location        rs5
2013-04-15 04:45:45.428110001   2/15:key549     StartRow        key29
2013-04-15 04:45:45.428110004   2/15:key549     Location        rs3
2013-04-15 04:45:45.428110005   2/15:tartRow    key549
2013-04-15 03:26:57.856186005   2/15:tartRow    key29
2013-04-15 03:10:05.131263001   2/15:tartRow
2013-04-15 04:45:45.600951001   2/15:ocation    rs1
2013-04-15 03:26:58.031994001   2/15:ocation    rs3
2013-04-15 03:10:05.465607001   2/15:ocation    rs5
则在rs5上执行“create scanner on "dingli/foo" [.."key1259"];”成功;在rs1上执行“create scanner on "dingli/foo" ["key549"..??];”成功;在rs6上执行“create scanner on "dingli/foo" ["key1259"..” key1541”];”成功。
在METADATA结果如下时:
2013-04-11 03:04:43.258011001   0/1:tartRow
2013-04-11 07:40:16.784530001   0/1:ocation     rs1
2013-04-11 03:04:43.533125001   0/1:ocation     rs2
在rs1上执行CREATE SCANNER ON TableName[..??]成功。
目前除这四种查询范围外,其余皆提示失败信息“RANGE SERVER range not found”。
4.Where子句后的cell_predicate和row_predicate测试通过,其查询该Range中符合指定条件的CELL。
5. options_spec中的INTO FILE测试不成功,命令虽然执行成功,但在本地或者DFS上都不能找到导出的文件。
3. DESTROY SCANNER
DESTROY SCANNER [scanner_id]


This command will destroy a scanner previously created with
a CREATE SCANNER command.  If a scanner_id is supplied, then
the scanner corresponding to that ID will be destroyed, otherwise
the "current" or most recently created scanner will get destroyed.
4. LOAD RANGE
LOAD RANGE range_spec


range_spec:
    table_name '[' [start_row] ".." (end_row | ?? ) ']'


This command will issue a 'load range' command to the RangeServer
for the range specified with range_spec.
5. DROP RANGE
DROP RANGE range_spec


range_spec:
    table_name '[' [start_row] ".." (end_row | ?? ) ']'


该命令将发送一条删除指定Range的命令到RangeServer,即该命令虽然最终会导致一个Range的删除,但是可能会有延迟,因为删除并不是由该命令直接完成。


实验表明:
例如:当查询METADATA时,结果中出现:
2013-04-15 04:57:20.861318005   2/15:key1541    StartRow        key1259
2013-04-15 04:04:00.309111001   2/15:key1541    StartRow
2013-04-15 04:57:21.096424001   2/15:key1541    Location        rs6
2013-04-15 04:04:00.309111004   2/15:key1541    Location        rs5
则执行“drop RANGE on "dingli/foo" ["key1541".."key2166"];”,该Range将被删除。观察监控界面该表的Range Count数量将减1,并且查询该Range中的rowkey时,将在RangeServer的log中提示“Range not found”。
6. METADATA SYNC 
METADATA SYNC TABLE table_name [options_spec]
METADATA SYNC RANGES range_type ['|' range_type ...] [options_spec]


range_type:
    ALL
    | ROOT
    | METADATA
    | SYSTEM
    | USER


options_spec:
    COLUMNS=<columns>


This command re-writes columns of the METADATA table, for a set of
ranges, using data from the RSML.  The TABLE version of the command
re-writes METADATA for the ranges in the given table.  The RANGES
version of the command re-writes METADATA for all ranges of the
given type(s), regardless of what table they belong to.
6.1. METADATA SYNC TABLE
6.2. METADATA SYNC RANGES
7. SHUTDOWN

This command causes the RangeServer to shutdown.  It will
return immediately, but the RangeServer will wait for all
running requests to complete before shutting down.
8. UPDATE 
UPDATE table_name input_file


This command will read blocks of key/value pairs from input_file
and send them to the range server.  Here are some example input file
lines that illustrate the format of this file:


1189631331826108        acaleph DELETE
1189631331826202        acrostolion     apple:http://www.baseball.com/       Vilia miretur vulgus
1189631331826211        acerin  banana:http://sports.espn.go.com/       DELETE


The fields are separated by the tab character, with the following format:
<timestamp> '\t' <row-key> '\t' <column-family>[:<column-qualfier>] '\t' <value>


The string "DELETE" has special meaning.  In the first example line
above, it generates a 'delete row' for the row key 'acaleph'.  In the
third example line above, it generates a 'delete cell' for the column
'banana:http://sports.espn.go.com/' of row 'acerin'.
0 0