Connecting to the Hive Data warehouse via remote JDBC

Source: Internet
Author: User

1. Start the HIVESERVER2 server, the listening port is 10000, the boot name order: Hive--service Hiveserver2 &;//put it in the background to run, to determine whether the success of the flag is: JPS, whether there is a runjar process, or Netstat-anop |grep 10000 see if Port 10000 is connected
, if you can connect, then you can use Beeline through $>hive service hiveserver2 This command to connect in
2. Connect to Hiveserver2 via Beeline command line, you can write $>beeline equivalent to: $>hive--service Beeline, connecting to database: $beeline >! Connect JDBC:HIVE2://LOCALHOST/MYDB1 to the database hive database mydb1
3.!help, print out help summary
4.beeline the following command:! Tables

Hive command
//创建表$hive>create table if not exists t1(name string) comment ‘xx‘ row format delimited fields terminated by ‘,‘ stored as textfile;//创建外部表

$hive >create External table if not exists T1 (name string) Comment ' xx ' row format delimited fields terminated by ', ' St ORed as Textfile;
View data
$hive >desc T2;
$hive >desc formatted T2;
$hive >load data local inpath '/home/centos/customers.txt ' into table t2;//upload to hive table from local file, local is uploading file,
Copying tables
$mysql >create Table TT as SELECT * from users; Copy tables, carry data and table structure
$mysql >create table TT like users; Copy table, carry only table structure, without data

hive>create table tt as select * from users;hive>create table tt  like users ;hive>select count(*) from users;    //这个需要转成mr进行处理,count(*) 查询要转成mr查询hive>select id,name from t2 order by id desc ;//order by是全排序,要转成mr,以内需要进行聚合
Partition table
hive的优化手段之一:创建分区表在hive中数据库是目录,表是目录,分区表还是目录,表下的分区仍然是目录,从目录层面控制搜索数据的范围创建分区表$hive>create table t3(id int,name string ,age int) partitioned by (year int,month int) row format delimited fields terminated by ","//显示分区表的分区信息hive>show partitions t5;//添加分区修改表$hive>altertable t3 add partition (year=2014,month=1) partition(year =2015,month=2);hdfs -lsr /;//添加完成之后查看目录//加载数据到指定分区$hive>load data local inpath ‘/home/centos/customers.txt‘ into table t5 partition(year=2015,month=3);

Connecting to the Hive Data warehouse via remote JDBC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.