2013年6月12日星期三

[Linux] Hbase shell

# Use for commands:
help 'command', status, list, describe 'tablename'
*The status shows the basic status of the cluster.
status 'simple'
status 'detailed'

# Create tables:
create 'tablename', {NAME=>'family 1'}, {NAME=>'family 2'}
create 'tablename', 'family1', 'family2'

# Scan table:
scan 'tablename'
*Restrict columns: {COLUMNS=>'family:'}, {COLUMNS=>['c1', 'c2']
*Restrict number of results: {LIMIT=>number}
*Restrict start / stop row: {STARTROW=>'start row key', ENDROW=>'end row key'}

# Count:
count 'tablename', 5000
*Here 5000 is means report results every 5000 rows.

# Delete:
delete 'table', 'rowkey', 'colkey(family:column)'
delete 'table', 'rowkey'
*Delete all rows in the table.
truncate 'tablename'

# Remove table:
*First you need to disable the table, and then you can drop table.
disable 'tablename'
drop 'tablename'

# Change column family:
*Must disable table first, and then change column family
alter 'tablename', {NAME=>'family', METHOD=>'delete'}

- Hbase files stored as HFiles in HDFS.
- sorted key/value pairs and an index of keys.
- /hbase/tablename/region/column-family

[Linux] Screen command

Use screen on remote machine.

screen [-AmRvx -ls -wipe] [-d name] [-h lines] [-r name] [-s] [-S name]

screen -r pid.name: recover a screen work.
screen -d -r pid.name : recover a screen work, kick off other user on this work and start.
screen -ls
screen -m : start a new screen.
screen -dm : a new screen start with detached model.
screen -p number or name

Ctrl + a + d : quit screen with process still running.
exit : quit screen.

Ctrl + a + c : create a new window.
Ctrl + a + w : list windows.
Ctrl + a + n : next window.
Ctrl + a + p : previous window.
Ctrl + a + 0 ~ 9 : switch between window 0 to 9.
Ctrl + a + K : quit current window and jump to next.