下载地址:
http://archive.cloudera.com/cloudera-labs/phoenix/parcels/latest/
CLABS_PHOENIX-4.7.0-1.clabs_phoenix1.3.0.p0.000-el7.parcel
CLABS_PHOENIX-4.7.0-1.clabs_phoenix1.3.0.p0.000-el7.parcel.sha1
manifest.json
.在线安装
点击parcel,然后点配置,添加parcel的网址,然后点击更新
http://archive.cloudera.com/cloudera-labs/phoenix/parcels/latest/
cd /opt/cloudera/parcels/CLABS_PHOENIX/bin
使用Phoenix登录HBase
./phoenix-sqlline.py
需要指定Zookeeper
./phoenix-sqlline.py node-01.flyfish:2181:/hbase
!table
create table hbase_test
(
s1 varchar not null primary key,
s2 varchar,
s3 varchar,
s4 varchar
);
hbase 的接口登录
hbase shell
upsert into hbase_test values('1','testname','testname1','testname2');
upsert into hbase_test values('2','tom','jack','harry');
删除:
delete from hbase_test where s1='1'; (删除是按rowkey)
upsert into hbase_test values('1','hadoop','hive','zookeeper');
upsert into hbase_test values('2','oozie','hue','spark');
更新数据测试,注意Phoenix中没有update语法,用upsert代替。插入多条数据需要执行多条upsert语句,没办法将所有的数据都写到一个“values”后面。
upsert into hbase_test values('1','zhangyy','hive','zookeeper');
准备 导入的 测试文件
ls -ld ithbase.csv
head -n 1 ithbase.csv
上传到hdfs
su - hdfs
hdfs dfs -mkdir /flyfish
hdfs dfs -put ithbase.csv /flyfish
hdfs dfs -ls /flyfish
create table ithbase
(
i_item_sk varchar not null primary key,
i_item_id varchar,
i_rec_start_varchar varchar,
i_rec_end_date varchar
);
执行bulkload命令导入数据
HADOOP_CLASSPATH=/opt/cloudera/parcels/CDH/lib/hbase/hbase-protocol-1.2.0-cdh5.12.1.jar:/opt/cloudera/parcels/CDH/lib/hbase/conf hadoop jar /opt/cloudera/parcels/CLABS_PHOENIX/lib/phoenix/phoenix-4.7.0-clabs-phoenix1.3.0-client.jar org.apache.phoenix.mapreduce.CsvBulkLoadTool -t ithbase -i /flyfish/ithbase.csv
select * from ithbase
cat export.pig
----
REGISTER /opt/cloudera/parcels/CLABS_PHOENIX/lib/phoenix/phoenix-4.7.0-clabs-phoenix1.3.0-client.jar;
rows = load 'hbase://query/SELECT * FROM ITHBASE' USING org.apache.phoenix.pig.PhoenixHBaseLoader('node-01.flyfish:2181');
STORE rows INTO 'flyfish1' USING PigStorage(',');
----
执行pig
pig -x mapreduce export.pig
在hdfs 上面查看文件
hdfs dfs -ls /user/hdfs/flyfish1
hdfs dfs -cat /user/hdfs/flyfish1/part-m-00000