elasticsearch使用那点事

LZO表创建:

create table lzoer(id int,name string, ip string)ROW FORMAT DELIMITED

FIELDS TERMINATED BY ‘,’ STORED AS INPUTFORMAT ‘com.hadoop.mapred.DeprecatedLzoTextInputFormat’ OUTPUTFORMAT ‘org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat’;

LZO表创建索引:

hadoop jar /usr/hdp/2.2.6.0-2800/hadoop/lib/hadoop-lzo-0.6.0.2.2.6.0-2800.jar  com.hadoop.compression.lzo.DistributedLzoIndexer  hdfs://hadoop001:8020/apps/hive/warehouse/hly.db/lzo_aa/1.txt.lzo

TXT表创建:

CREATE TABLE wubai(id int,name string,ip string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’ STORED AS TEXTFILE;

ES表创建:

CREATE EXTERNAL TABLE eswubai(

id bigint,

name string,

ip string)

STORED BY ‘org.elasticsearch.hadoop.hive.EsStorageHandler’

TBLPROPERTIES(‘es.resource’ = ‘wubai/wubai’,’es.nodes’=’ip’,’es.port’=’9200′,’es.nodes.wan.only’=’true’,’es.mapping.names’=’id:esid,name:esname,ip:esage’);

LOAD数据:

load data local inpath ‘/usr/local/999.txt’ into table estest.test01_source;

LOAD DATA LOCAL INPATH ‘/usr/local/500.txt.lzo’ OVERWRITE INTO TABLE lzowubai; 

INSERT INTO 数据:

insert overwrite table eswuk select * from wuk;

insert into eser select * from wu;

insert overwrite table web select s.id, s.name, s.ip, s.time from test01_source s;

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/191290.html

(0)
上一篇 2021年11月14日
下一篇 2021年11月14日

相关推荐

发表回复

登录后才能评论