公司用HBase,學習了Phoenix。記錄一些問題html
create view "test1"( pk VARCHAR PRIMARY KEY, "i"."name" VARCHAR, "i"."age" VARCHAR);
create table "test1"( pk VARCHAR PRIMARY KEY, "i"."name" VARCHAR, "i"."age" VARCHAR) column_encoded_bytes=0;
表名和列族以及列名須要用雙引號括起來,由於HBase是區分大小寫的,若是不用雙引號括起來的話Phoenix在建立表的時候會自動將小寫轉換爲大寫字母mysql
能夠參考 http://phoenix.apache.org/columnencoding.htmlsql
sqoop import --connect jdbc:mysql://localhost/test --username xxx --password xxx --table mytable --hbase-create-table --hbase-table mytable --column-family cf --hbase-row-key id --split-by id -m 10 --columns id,insert_time,info
sqoop import --connect jdbc:mysql://localhost/test --username root -P --verbose --query "SELECT rowid,name FROM employee WHERE \$CONDITIONS" --target-dir /tmp/employee --phoenix-table EMP --phoenix-column-mapping "rowid;ID,name;NAME" --phoenix-bulkload Arguments: --phoenix-table : Required . The phoenix table --phoenix-column-mapping: Optional. This property should be specified if the column names between sqoop table and phoenix table differ. --phoenix-bulkload Optional . Bulk loads data onto the phoenix table.
參考:https://issues.apache.org/jira/browse/PHOENIX-763apache
<property> <name>hbase.regionserver.wal.codec</name><value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value></property> <property> <name>hbase.region.server.rpc.scheduler.factory.class</name><value>org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory</value><description>Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates</description> </property> <property> <name>hbase.rpc.controllerfactory.class</name><value>org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory</value> <description>Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates</description> </property>
SELECT v2 FROM my_table WHERE v1 = 'foo'
這樣查詢,要用上索引,須要v1,v2一塊兒建索引。若是查詢結果中字段有多的,將用不上索引。查詢結果是rowkey的話,能夠不要INCLUDE。bash
CREATE INDEX my_index ON my_table (v1) INCLUDE (v2)
英文好的,請直接看官方文檔:http://phoenix.apache.org/secondary_indexing.htmloracle