Hive--hbase--spark

mac2024-03-25  31

hive创建hbase表

create external table events.hb_train( row_key string, user_id string, event_id string, invited string, time_stamp string, interested string ) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties('hbase.columns.mapping' = ':key,eu:user,eu:event,eu:invited,eu:time_stamp,eu:interested') tblproperties('hbase.table.name' = 'db:train') 使用HQL语句创建一个指向HBase的Hive表,同时导入hbase表中的数据到hive表 CREATE TABLE hbase_table_1(key int, value string) //Hive中的表名hbase_table_1 STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' //指定存储处理器 WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val") //声明列族,列名 TBLPROPERTIES ("hbase.table.name" = "xyz", "hbase.mapred.output.outputtable" = "xyz"); //hbase.table.name声明HBase表名,为可选属性默认与Hive的表名相同, //hbase.mapred.output.outputtable指定插入数据时写入的表,如果以后需要往该表插入数据就需要指定该值 //创建按列存储的表 create table events.events stored as ORC as //orc 按列存储 select * from events.hb_events

配置spark on hive — 这个地方我记得我们当初配的是hive on MapReduce

在Spark客户端安装包下spark-2.2.0/conf中创建文件hive-site.xml: 配置hive的metastore路径 <configuration> <property> <name>hive.metastore.uris</name> <value>thrift://node1:9083</value> </property> </configuration> 后台启动metastore: nohup hive --service metastore -p 9083 1>/opt/hive-2.3.2/hiveserver.log 2>/opt/hive-2.3.2/hiveserver.err &
最新回复(0)