📅  最后修改于: 2020-11-30 04:59:00             🧑  作者: Mango
在前面的章节中,我们已经看到了使用cloudera及其架构来安装Impala。
本章介绍如何启动Impala Shell以及Shell的各种选项。
Impala shell的命令分为通用命令,查询特定选项以及表和数据库特定选项,如下所述。
打开cloudera终端,以超级用户身份登录,然后如下所示输入cloudera作为密码。
[cloudera@quickstart ~]$ su
Password: cloudera
[root@quickstart cloudera]#
通过键入以下命令来启动Impala shell-
[root@quickstart cloudera] # impala-shell
Starting Impala Shell without Kerberos authentication
Connected to quickstart.cloudera:21000
Server version: impalad version 2.3.0-cdh5.5.0 RELEASE
(build 0c891d79aa38f297d244855a32f1e17280e2129b)
*********************************************************************
Welcome to the Impala shell. Copyright (c) 2015 Cloudera, Inc. All rights reserved.
(Impala Shell v2.3.0-cdh5.5.0 (0c891d7) built on Mon Nov 9 12:18:12 PST 2015)
Want to know what version of Impala you're connected to? Run the VERSION command to
find out!
*********************************************************************
[quickstart.cloudera:21000] >
下面解释了Impala的通用命令-
Impala shell的help命令为您提供了Impala中可用命令的列表-
[quickstart.cloudera:21000] > help;
Documented commands (type help ):
========================================================
compute describe insert set unset with version
connect explain quit show values use
exit history profile select shell tip
Undocumented commands:
=========================================
alter create desc drop help load summary
version命令为您提供了Impala的当前版本,如下所示。
[quickstart.cloudera:21000] > version;
Shell version: Impala Shell v2.3.0-cdh5.5.0 (0c891d7) built on Mon Nov 9
12:18:12 PST 2015
Server version: impalad version 2.3.0-cdh5.5.0 RELEASE (build
0c891d79aa38f297d244855a32f1e17280e2129b)
Impala的history命令显示在shell中执行的最后10条命令。以下是history命令的示例。在这里,我们执行了5个命令,分别是版本,帮助,显示,使用和历史。
[quickstart.cloudera:21000] > history;
[1]:version;
[2]:help;
[3]:show databases;
[4]:use my_db;
[5]:history;
您可以使用quit或exit命令退出Impala shell,如下所示。
[quickstart.cloudera:21000] > exit;
Goodbye cloudera
connect命令用于连接到Impala的给定实例。如果您未指定任何实例,则它将连接到默认端口21000 ,如下所示。
[quickstart.cloudera:21000] > connect;
Connected to quickstart.cloudera:21000
Server version: impalad version 2.3.0-cdh5.5.0 RELEASE (build
0c891d79aa38f297d244855a32f1e17280e2129b)
Impala的查询特定命令接受查询。它们在下面解释-
说明命令返回给定查询的执行计划。
[quickstart.cloudera:21000] > explain select * from sample;
Query: explain select * from sample
+------------------------------------------------------------------------------------+
| Explain String |
+------------------------------------------------------------------------------------+
| Estimated Per-Host Requirements: Memory = 48.00MB VCores = 1 |
| WARNING: The following tables are missing relevant table and/or column statistics. |
| my_db.customers |
| 01:EXCHANGE [UNPARTITIONED] |
| 00:SCAN HDFS [my_db.customers] |
| partitions = 1/1 files = 6 size = 148B |
+------------------------------------------------------------------------------------+
Fetched 7 row(s) in 0.17s
profile命令显示有关最近查询的低级信息。此命令用于诊断查询和调整性能。以下是profile命令的示例。在这种情况下, profile命令返回说明查询的低级信息。
[quickstart.cloudera:21000] > profile;
Query Runtime Profile:
Query (id=164b1294a1049189:a67598a6699e3ab6):
Summary:
Session ID: e74927207cd752b5:65ca61e630ad3ad
Session Type: BEESWAX
Start Time: 2016-04-17 23:49:26.08148000 End Time: 2016-04-17 23:49:26.2404000
Query Type: EXPLAIN
Query State: FINISHED
Query Status: OK
Impala Version: impalad version 2.3.0-cdh5.5.0 RELEASE (build 0c891d77280e2129b)
User: cloudera
Connected User: cloudera
Delegated User:
Network Address:10.0.2.15:43870
Default Db: my_db
Sql Statement: explain select * from sample
Coordinator: quickstart.cloudera:22000
: 0ns
Query Timeline: 167.304ms
- Start execution: 41.292us (41.292us) - Planning finished: 56.42ms (56.386ms)
- Rows available: 58.247ms (1.819ms)
- First row fetched: 160.72ms (101.824ms)
- Unregister query: 166.325ms (6.253ms)
ImpalaServer:
- ClientFetchWaitTimer: 107.969ms
- RowMaterializationTimer: 0ns
下表列出了Impala中的表和特定于数据的选项。
Sr.No | Command & Explanation |
---|---|
1 |
Alter The alter command is used to change the structure and name of a table in Impala. |
2 |
Describe The describe command of Impala gives the metadata of a table. It contains the information like columns and their data types. The describe command has desc as a short cut. |
3 |
Drop The drop command is used to remove a construct from Impala, where a construct can be a table, a view, or a database function. |
4 |
insert The insert command of Impala is used to,
|
5 |
select The select statement is used to perform a desired operation on a particular dataset. It specifies the dataset on which to complete some action. You can print or store (in a file) the result of the select statement. |
6 |
show The show statement of Impala is used to display the metastore of various constructs such as tables, databases, and tables. |
7 |
use The use statement of Impala is used to change the current context to the desired database. |