jmeter ssh command方式执行hive指令
Hive命令执行
打开任意一个安装了hive的服务器,进入hive bin 路径,可以看到存在以下文件(仅展示部分):
-rwxr-xr-x 1 root root 1297 Jun 28 14:29 beeline
-rwxr-xr-x 1 root root 2487 Jun 28 14:29 beeline.cmd
-rwxr-xr-x 1 root root 9627 Nov 18 11:21 hive
-rwxr-xr-x 1 root root 8365 Jun 28 14:29 hive.cmd
-rwxr-xr-x 1 root root 1523 Jun 28 14:29 hive-config.cmd
-rwxr-xr-x 1 root root 1958 Nov 18 11:21 hive-config.sh
-rwxr-xr-x 1 root root 885 Jun 28 14:29 hiveserver2
-rwxr-xr-x 1 root root 546 Nov 18 11:21 hiveserver2-listener.sh
-rwxr-xr-x 1 root root 1030 Jun 28 14:29 hplsql
-rwxr-xr-x 1 root root 2220 Jun 28 14:29 hplsql.cmd
-rwxr-xr-x 1 root root 543 Nov 18 11:21 metastore-listener.sh
-rwxr-xr-x 1 root root 832 Jun 28 14:29 metatool
-rwxr-xr-x 1 root root 884 Jun 28 14:29 schematool
要连接hive执行sql主要使用hive和beeline,Beeline主要是开发来与新服务器进行交互。Hive CLI是基于 Apache Thrift的客户端,而Beeline是基于SQLLine CLI的JDBC客户端。Hive CLI使用HiveServer1使用Thrift协议连接到远程Hiveserver1实例。Beeline使用JDBC连接到远程HiveServer2实例。以下围绕hive和beeline展开介绍。
交互执行
直接使用 Hive 命令,不加任何参数,即可进入交互式命令行。本次案例主要围绕非交互进行介绍,交互式在此不再介绍。
非交互执行
Hive
路径下hive是一个shell工具,它可以用来运行于交互或批处理方式配置单元查询。Hive指令可以用./hive –H查看。
-d,--define <key=value> Variable subsitution to apply to hive
commands. e.g. -d A=B or --define A=B
--database <databasename> Specify the database to use -- 指定使用的数据库
-e <quoted-query-string> SQL from command line -- 执行指定的 SQL
-f <filename> SQL from files --执行 SQL 脚本
-H,--help Print help information -- 打印帮助信息
--hiveconf <property=value> Use value for given property --自定义配置
--hivevar <key=value> Variable subsitution to apply to hive --自定义变量
commands. e.g. --hivevar A=B
-i <filename> Initialization SQL file --在进入交互模式之前运行初始化脚本
-S,--silent Silent mode in interactive shell --静默模式
-v,--verbose Verbose mode (echo executed SQL to the console) --详细模式
使用hive无需输入用户名和密码即可连接执行sql语句,bin执行命令。
l 指定数据库并查询当前数据库下的表
|
./hive --database tpcds_database_parquet_100 -e "show tables" |
l 执行sql语句
|
./hive -e "show databases;" |
l 执行单个sql脚本
|
./hive --database tpcds_database_parquet_100 -v -f "/home/hive-testbench-hive14/sample-queries-tpcds/query12.sql" Sql脚本可以是hdfs文件,./hive -f hdfs://SERVICE-HADOOP-admin/tmp/simple.sql; |
l 运行结果写入文件
|
./hive --database tpcds_database_parquet_100 -v -e "show tables;" > ./a.txt |
说明:-e 与 -f 不能同时使用。-i 能够与任意参数同时使用。多个 –i 的实例可以用来执行多个初始化脚本
beeline
Hive 内置了 HiveServer 和 HiveServer2 服务,两者都允许客户端使用多种编程语言进行连接,但是 HiveServer 不能处理多个客户端的并发请求,所以产生了HiveServer2, 支持多客户端并发访问和身份验证。HiveServer2 拥有自己的 CLI(Beeline),Beeline 是一个基于 SQLLine 的 JDBC 客户端。在 Hive CLI 中支持的参数,Beeline 都支持。./beeline -help查看beeline语法规则:
-u <database url> the JDBC URL to connect to
-r reconnect to last saved connect url (in conjunction with !save)
-n <username> the username to connect as
-p <password> the password to connect as
-d <driver class> the driver class to use
-i <init file> script file for initialization
-e <query> query that should be executed
-f <exec file> script file that should be executed
-w (or) --password-file <password file> the password file to read password from
--hiveconf property=value Use value for given property
--hivevar name=value hive variable name and value
This is Hive specific settings in which variables
can be set at session level and referenced in Hive
commands or queries.
--property-file=<property-file> the file to read connection properties (url, driver, user, password) from
--color=[true/false] control whether color is used for display
--showHeader=[true/false] show column names in query results
--headerInterval=ROWS; the interval between which heades are displayed
--fastConnect=[true/false] skip building table/column list for tab-completion
--autoCommit=[true/false] enable/disable automatic transaction commit
--verbose=[true/false] show verbose error messages and debug info
--showWarnings=[true/false] display connection warnings
--showDbInPrompt=[true/false] display the current database name in the prompt
--showNestedErrs=[true/false] display nested errors
--numberFormat=[pattern] format numbers using DecimalFormat pattern
--force=[true/false] continue running script even after errors
--maxWidth=MAXWIDTH the maximum width of the terminal
--maxColumnWidth=MAXCOLWIDTH the maximum width to use when displaying columns
--silent=[true/false] be more silent
--autosave=[true/false] automatically save preferences
--outputformat=[table/vertical/csv2/tsv2/dsv/csv/tsv] format mode for result display
Note that csv, and tsv are deprecated - use csv2, tsv2 instead
--incremental=[true/false] Defaults to false. When set to false, the entire result set
is fetched and buffered before being displayed, yielding optimal
display column sizing. When set to true, result rows are displayed
immediately as they are fetched, yielding lower latency and
memory usage at the price of extra display column padding.
Setting --incremental=true is recommended if you encounter an OutOfMemory
on the client side (due to the fetched result set size being large).
Only applicable if --outputformat=table.
--incrementalBufferRows=NUMROWS the number of rows to buffer when printing rows on stdout,
defaults to 1000; only applicable if --incremental=true
and --outputformat=table
--truncateTable=[true/false] truncate table column when it exceeds length
--delimiterForDSV=DELIMITER specify the delimiter for delimiter-separated values output format (default: |)
--isolation=LEVEL set the transaction isolation level
--nullemptystring=[true/false] set to true to get historic behavior of printing null as empty string
--showConnectedUrl=[true/false] Prompt HiveServer2s URI to which this beeline connected.
Only works for HiveServer2 cluster mode.
--maxHistoryRows=MAXHISTORYROWS The maximum number of rows to store beeline history.
--convertBinaryArrayToString=[true/false] display binary column data as string or as byte array
--help display this message
Example:
1. Connect using simple authentication to HiveServer2 on localhost:10000
$ beeline -u jdbc:hive2://localhost:10000 username password
2. Connect using simple authentication to HiveServer2 on hs.local:10000 using -n for username and -p for password
$ beeline -n username -p password -u jdbc:hive2://hs2.local:10012
3. Connect using Kerberos authentication with hive/localhost@mydomain.com as HiveServer2 principal
$ beeline -u "jdbc:hive2://hs2.local:10013/default;principal=hive/localhost@mydomain.com
4. Connect using SSL connection to HiveServer2 on localhost at 10000
$ beeline jdbc:hive2://localhost:10000/default;ssl=true;sslTrustStore=/usr/local/truststore;trustStorePassword=mytruststorepassword
5. Connect using LDAP authentication
$ beeline -u jdbc:hive2://hs2.local:10013/default <ldap-username> <ldap-password>
参数详解
|
选项 |
描述 |
|
-u <database URL> |
用于JDBC URL连接。用例:beeline -u db_URL |
|
-r |
重新连接到最近使用过的URL(如果用户有预先使过的用的,用!connect生成URL,用!save 生成beeline.properties.file)。 用例: beeline -r Version: 2.1.0 |
|
-n <username> |
连接时使用的用户名。用例: beeline -n valid_user |
|
-p <password> |
连接时使用的密码。用例: beeline -p valid_password 可选的密码模式: 从Hive 2.2.0开始参数-p选项是可选的。 用例 : beeline -p [valid_password] 如果密码不是在-p之后提供的,Beeline将在初始化连接时提示输入密码。当密码提供后Beeline会用它来初始化连接而不提示。 |
|
-d <driver class> |
配置使用的驱动类 用例: beeline -d driver_class |
|
-e <query> |
应该执行的查询。查询语句两端用单引号和双引号。这个选项被使用多次。用例: beeline -e "query_string" |
|
-f <file> |
需要被执行的脚本文件。用例: beeline |
|
-i (or) --init <file |
初始化需要的初始文件。用例: beeline -i |
|
-w (or) --password-file <password |
从文件中读取密码。Version: 1.2.0 |
|
-a (or) --authType <auth |
jdbc的认证类型是一个身份认证属性。Version: 0.13.0 |
|
--property-file <file> |
读取配置属性的文件用例: beeline --property-file Version: |
|
--hiveconf property=value |
为给定的配置属性赋值。 在hive.conf.restricted.list列表中的属性不能通过hiveconf的方式重置。 用例: beeline |
|
--hivevar name=value |
Hive的变量名和变量值。这是一个Hive指定的设置,在这变量能够在会话级别被设置和被Hive命令和查询引用。 用例: beeline --hivevar |
|
--color=[true/false] |
制颜色是否被用来展示。默认是false 用例: beeline --color=true (不支持分隔的值输出方式) |
|
--showHeader=[true/false] |
展示列名是否在查询结果中。默认是true。用例: beeline --showHeader=false |
|
--headerInterval=ROWS |
当输出为表格时,重新显示列头时他们之间的间隔,用行数计算。默认值为100 用例: beeline --headerInterval=50 |
|
--fastConnect=[true/false] |
连接时,跳过为HiveQL语法的tab键自动补全功能而构建所有表和列的清单,默认为true不构建该列表。 用例: beeline |
|
--autoCommit=[true/false] |
允许或者禁止自动事务执行。默认是false 用例: beeline |
|
--verbose=[true/false] |
展示冗长的报错信息和调试信息(true)或者不展示(false),默认是false 用例: beeline --verbose=true |
|
--showWarnings=[true/false] |
Default |
|
--showDbInPrompt=[true/false] |
在提示符里面展示当前数据库名字。默认是false。用例: beeline |
|
--showNestedErrs=[true/false] |
展示内部错误,默认是false。用例: beeline --showNestedErrs=true |
|
--numberFormat=[pattern] |
用一个小数格式的模板来格式化数字。用例: beeline |
|
--force=[true/false] |
出错后继续运行脚本(true),或者不运行(false)。默认是false。用例: beeline--force=true |
|
--maxWidth=MAXWIDTH |
当输出格式是表格时,在截断数据前展示的最大宽度。默认是查询时的终端的当前宽度,然后回到80。用例: beeline --maxWidth=150 |
|
--maxColumnWidth=MAXCOLWIDTH |
当输出是表格时,最大列宽,Hive 2.2.0以后默认是50,之前的版本是15。用例: beeline |
|
--silent=[true/false] |
是(true)否(false)减少展示的信息量。它也会停止展示HiveServer2(Hive 0.14及之后的版本)的查询和命令(Hive 1.2.0及之后的版本)日志信息,默认是false。用例: beeline --silent=true |
|
--autosave=[true/false] |
自动保存参数选择(true)或者不保存(false)。默认是false。用例: beeline |
|
--outputformat=[table/vertical/csv/tsv/dsv/csv2/tsv2] |
结果展示的模式。默认是表格。查阅下方的Separated-Value |
|
--truncateTable=[true/false] |
如果是true,那么当表格超出终端显示宽度时,截断表格的列在终端上展示。 |
|
--delimiterForDSV= DELIMITER |
用于输出格式中划分值的界定符。默认是‘|’ |
|
--isolation=LEVEL |
设置事务隔离级别为TRANSACTION_READ_COMMITTED或者TRANSACTION_SERIALIZABLE. 可以查阅Java连接文档中“Field Detail”那一章节。 用例: beeline |
|
--nullemptystring=[true/false] |
使用历史的打印空字符null的形式(true)还是使用当前打印空值的方式(false),默认是false。 用例: beeline |
|
--incremental=[true/false] |
从Hive 2.3版本往后默认是true,在它之前是默认为false。当设置为false时,为了最佳的展示列宽,完整的结果集会在展示之前被收集然后缓存起来。当设置为true时,结果集一旦被抓取到就会立即展示, 为了在展示列的填充额外消耗更少的延迟和内存。当你在客户端遭遇一个内存溢出时,推荐设置--incremental=true (因为抓取到的结果集非常大)。 |
|
--incrementalBufferRows=NUMROWS |
当打印行到标准输出时,保存在缓存中的行数,默认是1000。只有当 --incremental=true 和 --outputformat=table才适用。 用例: beeline |
|
--maxHistoryRows=NUMROWS |
存储Beeline 历史记录的最大行数。 |
|
--delimiter=; |
设置Beeline的查询语句分隔符。允许用多个字符的分隔符,但是引号,斜杠和--是不允许的,默认是分号; 用例: beeline |
|
--convertBinaryArrayToString=[true/false] |
展示二进制列数据为字符串或者位矩阵。用例: beeline |
|
--help |
展示一个帮助信息。用例: beeline --help |
l 连接hive
|
./beeline -u jdbc:hive2://ip:10000 -n 或者 ./beeline -n admin -p hhh12345+ -d |
l 执行sql语句
|
./beeline -u jdbc:hive2://ip:10000 -n |
l 执行sql脚本
|
./beeline -u |
Jmeter hive sql执行
以上hive语句均可以在jmeter ssh command中执行。
jmeter ssh command方式执行hive指令的更多相关文章
- linux ssh 登录同时执行其他指令
目的:懒的敲一些重复的指令,比如登录后cd到某个目录. 咋办: ssh -t user@xxx.xxx.xxx.xxx "cd /directory_wanted ; bash" ...
- watch---周期性的方式执行给定的指令
watch命令以周期性的方式执行给定的指令,指令输出以全屏方式显示. 选项 -n:指定指令执行的间隔时间(秒): -d:高亮显示指令输出信息不同之处: -t:不显示标题.
- 通过 SSH 隧道方式图形化连接 AIX 服务器
跳转到主要内容 登录 (或注册) 中文 [userid] IBM ID: 密码: 保持登录. 单击提交则表示您同意developerWorks 的条款和条件. 查看条款和条件. 需要一个 IBM ID ...
- vagrant启动报错The following SSH command responded with a no
vagrant package打包生成box,以这个box为基础模板,打造vagrant环境,启动vagrant报错 angel:vagrant $ vagrant up Bringing machi ...
- ssh连接远程主机执行脚本的环境变量问题
近日在使用ssh命令ssh user@remote ~/myscript.sh登陆到远程机器remote上执行脚本时,遇到一个奇怪的问题: ~/myscript.sh: line n: app: co ...
- [ 转载 ] ssh连接远程主机执行脚本的环境变量问题
近日在使用ssh命令ssh user@remote ~/myscript.sh登陆到远程机器remote上执行脚本时,遇到一个奇怪的问题: ~/myscript.sh: line n: app: co ...
- 解决SSH登录用户执行的命令部分环境变量参数不生效的问题
问题概况 linux机器在/etc/profile配置完成环境变量后,SSH到目标机器执行命令,但是获取不到已配置的环境变量值. 例如场景: 在/etc/profile配置了http代理 export ...
- hive的shell用法(脑子糊涂了,对着脚本第一行是 #!/bin/sh 疯狂执行hive -f 结果报错)
hive脚本的执行方式 hive脚本的执行方式大致有三种: hive控制台执行: hive -e "SQL"执行: hive -f SQL文件执行:参考hive用法: usage: ...
- C++中执行windows指令
执行windows指令: BOOL ExecDosCmd(]) { SECURITY_ATTRIBUTES sa; HANDLE hRead,hWrite; sa.nLength = sizeof(S ...
随机推荐
- 2020.10.23-vj个人赛补题
B - B Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consistin ...
- OGG-如何只同步最近某个时间范围的数据
一.需求,某客户希望使用OGG只同步时间大于2021-02-01日期之后的数据变换 需求如标题所示,如何使用OGG进行配置? 客户环境需要同步的表有几百G,表数据太大了;如果同步所有数据,目标库空间存 ...
- Upload-labs通关指南(下) 11-20
承接上篇,这次我们继续做下半部分. 有些题目有其他做法是针对于windows系统特性的,并不能在linux上奏效,因此不在考虑范围之内. Pass-11 制作图片马直接上传 copy a.jpg /a ...
- C++ 与 Visual Studio 2019 和 WSL
Visual Studio 使用 C++ 的 Linux 开发(WSL) https://devblogs.microsoft.com/cppblog/c-with-visual-studio-201 ...
- 3 Implementation: The Big Picture 实现:蓝图
三.Implementation: The Big Picture 实现:蓝图 3.1 Layering of a .NET Solution .Net解决方案的分层 The picture belo ...
- java的加载与执行原理剖析
到目前为止,我们接触过的重点术语,总结一下: Java体系的技术被划分为三大块: JavaSE:标准版 JavaEE:企业版 JavaME:微型版 安装JDK之后: JDK:java开发工具箱 JRE ...
- 欧姆龙PLC HostLink协议整理
欧姆龙PLC HostLink协议整理 1.常用的存储器功能区 CIO: 输入继电器 272 点(17 CH) 0.00-16.15 输出继电器 272 点(17 CH) 100.00-116.1 ...
- 第二次Alpha Scrum Meeting
本次会议为Alpha阶段第二次Scrum Meeting会议 会议概要 会议时间:2021年4月24日 会议地点:线上会议 会议时长:30min 会议内容简介:本次会议主要由每个人展示自己目前完成的工 ...
- Scrum Meeting 0425
零.说明 日期:2021-4-25 任务:简要汇报两日内已完成任务,计划后两日完成任务 一.进度情况 组员 负责 两日内已完成的任务 后两日计划完成的任务 qsy PM&前端 完成登录.注册A ...
- spring cloud config 结合 spring cloud bus实现配置自定的刷新
在线上环境中,有时候我们希望系统中的某些配置参数在修改后,可以立即生效而不用重新启动服务.由上一节我们知道,我们可以把配置文件统一放到配置服务中进行管理,这一节我们在配置中心中整合spring clo ...