hive shell命令
来源:互联网 发布:c语言两条竖线运算 编辑:程序博客网 时间:2024/05/01 19:06
Hive的Shell有命令行模式和交互模式。
命令行模式用起来如同“hadoop fs -ls /”这种;交互模式如同“hbase shell”进入的模式,和hbase shell不同的是hive的交互模式里每个命令后都要用分号结束。
Hive 命令行参数:
-i 从文件执行初始化HQL后进入交互模式。
-e 从命令行执行指定的HQL语句。
-f 执行HQL脚本文件。
-v 输出执行的HQL语句到控制台。
-p connect to Hive Server on port number -hiveconf x=y Use this to set hive/hadoop configuration variables.
1)从命令行执行指定的sql语句
root@debian:~# hive -e ‘create table tb1(id int, name string, age int);’
OK ########## 执行成功
Time taken: 1.915 seconds
root@debian:~# hive -v -e ‘create table tb1(id int, name string, age int);’
create table tb1(id int, name string, age int)
OK ########## 打印sql语句。执行成功
Time taken: 2.987 seconds
root@debian:~# hive -e ‘create table tb1(id int, name string, age int);’ -v >> /home/hive-1.1.0/a.txt
OK ########## 执行成功。在指定目录创建文件,保存执行的sql语句
Time taken: 3.411 seconds
root@debian:~# hive -e ‘show tables;’
OK ########## 执行成功。打印结果
tb1
Time taken: 1.801 seconds, Fetched: 2 row(s)
root@debian:~# hive -e ‘show tables;’ -v >> /home/hive-1.1.0/a.txt
OK ########## 执行成功。在指定文件保存执行的sql语句和结果
Time taken: 1.106 seconds, Fetched: 1 row(s)
root@debian:~#
2)在进入交互模式之前,执行初始化的sql语句文件
在/home/hive-1.1.0里准备一个sql文件init.sql,写入sql语句:
create table tb2(id int, name string, age int);
show tables;
然后执行:
root@debian:~# hive -v -i /home/hive-1.1.0/init.sql
create table tb2(id int, name string, age int) #这一行是因-v参数才打印的
show tables #这一行是因-v参数才打印的
tb1 #这一行是因为sql文件中的“show tables;”才打印的
3)以非交互式模式执行sql文件sql语句(未测试)
root@debian:~# hive -f /home/hive-1.1.0/script.sql
root@debian:~# hive -f -v /home/hive-1.1.0/script.sql
root@debian:~# hive -f -v /home/hive-1.1.0/script.sql >> /home/hive-1.1.0/a.txt
4)以指定的hive环境变量执行指定的sql语句(未测试)
root@debian:~# hive -e ‘select a.col from tb2 a’
-hiveconf hive.exec.scratchdir=/home/hive-1.1.0/hive_scratch
-hiveconf mapred.reduce.tasks=32
如果已经在一个终端进入hive的交互模式,在另一个终端执行hive的命令行模式会报错:
root@debian:~# hive -e ‘show tables;’
Exception in thread “main” java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
Caused by: java.lang.reflect.InvocationTargetException
Caused by: javax.jdo.JDOFatalDataStoreException: Unable to open a test connection to the given database. JDBC url = jdbc:derby:;databaseName=metastore_db;create=true, username = App. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ——
java.sql.SQLException: Failed to start database ‘metastore_db’ with class loader sun.misc.Launcher
Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database /root/metastore_db.
NestedThrowables:
java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:derby:;databaseName=metastore_db;create=true, username = App. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ——
java.sql.SQLException: Failed to start database ‘metastore_db’ with class loader sun.misc.Launcher
Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database /root/metastore_db.
Caused by: java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:derby:;databaseName=metastore_db;create=true, username = App. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ——
java.sql.SQLException: Failed to start database ‘metastore_db’ with class loader sun.misc.Launcher
Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database /root/metastore_db.
Caused by: java.sql.SQLException: Failed to start database ‘metastore_db’ with class loader sun.misc.Launcher
Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database /root/metastore_db.
- hive shell命令
- Hive shell 命令。
- hive的shell命令小结
- 14 Hive shell 命令 DML命令
- hive调用Linux的shell命令测试
- 使用shell脚本执行hive、sqoop命令
- hive-shell批量命令执行脚本
- shell命令执行hive脚本(hive交互,hive的shell编程)
- shell命令执行hive脚本(hive交互,hive的shell编程)
- shell命令执行hive脚本(hive交互,hive的shell编程)
- Hive SHELL
- Hive Shell命令之一(数据库和表的操作)
- 划重点---Hive的shell命令以及HQL
- Hive Shell 命令之二(表中数据的操作,出自Hive编程指南)
- hive变量调用 hive和shell hdfs命令交互调用 hiverc预定义初始化
- Spark-Sql整合hive,在spark-sql命令和spark-shell命令下执行sql命令和整合调用hive
- 如何在hive的shell中使用hadoop shell 和linux的命令
- hive 命令
- 欧拉函数
- 零基础学python-8.6 字典的基本操作与原处修改
- Opencv中XML文件的写入
- [BZOJ1816][Cqoi2010]扑克牌
- cocoa之高级开发RunTime高级API
- hive shell命令
- [HDU 2955 Robberies] 入门DP
- 自定义Dialog、PopupWindow、通知Notification
- iter 和生成器
- HDU5399
- Java中>> 与 >>> 的区别
- Linux内核工程导论——用户空间设备管理
- memcpy引发的C常见指针问题
- [C语言][LeetCode][35]Search Insert Position