1.启动Hadoop :start-all.sh
2.启动metastore和hiveserver2)
Hive 2.x以上版本,要先启动这两个服务,否则会报错:FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
编写脚本 启动:hiveservices.sh start ( jps显示两个 RunJar)
3.启动hive窗口:
(1)hive
(2)beeline -u jdbc:hive2://hadoop001:10000 -n lpy -p123
退出hive窗口:exit quit
4.创建库
show databases; 执行查看hive库
create database db_bi; 创建库
5. 创建表
use db_bi;使用刚刚创建的库
create table ods_test01(id int ,name String) row format delimited fields terminated by ','; 指定文件存储格式创建表
导入数据:load data local inpath "/wenjian/constellation.txt" into table person;
6.查询表
select * from ods_test01;
7.删除表
drop table ods_test01;
8.上传文件
在Hadoop下执行命令:hadoop fs -put aa.txt /user/hive/warehouse/db_bi.db/ods_test01