使用直线连接到hive

bjg7j2ky  于 2021-05-30  发布在  Hadoop
关注(0)|答案(7)|浏览(555)

我正在尝试通过beeline客户端连接到安装在我机器上的配置单元。当我发出“beeline”命令并连接到hive时,客户机请求用户名和密码

!connect jdbc:hive2://localhost:10000/default

我不知道我应该给什么用户名和密码。我是否必须在某些配置文件中添加凭据(用户名和密码)?

eiee3dmh

eiee3dmh1#

使用启用kerberos安全性的beeline-to-hive服务器

beeline -u "jdbc:hive2://<Server Ip>:<port>/sample;principal=<hive user>/<Server Ip>@<relam>;retries=3"

例子

beeline -u "jdbc:hive2://10.10.10.10:8071/sample;principal=hive/10.10.10.10@abc.com;retries=3"
to94eoyn

to94eoyn2#

没有用户名和密码。

!connect jdbc:hive2://localhost:10000/default

  Enter username for jdbc:hive2://localhost:10000/default: <press Enter>
  Enter password for jdbc:hive2://localhost:10000/default: <press Enter>

只需按回车键。这对我很有用。
或者试试这个。

!connect jdbc:hive2://localhost:10000/default "" "" ""
nxowjjhe

nxowjjhe3#

它是用于登录到集群的用户id和密码。有时,用于登录服务器的是边缘节点凭据。避免这种情况的最好方法是使用下面的命令

beeline -u jdbc:hive2://localhost:10000/default

如果您已经通过putty登录到某个节点,则不会提示您输入任何用户id或密码。
编辑
诀窍:为了避免重复键入整个直线字符串,最好在bash\u概要文件中创建一个别名。
只需在bash概要文件中添加以下行(使用@harsimranjitsingh kler建议的kerberos安全性) beeline -u jdbc:hive2://<hostname>:10000/default;principal=hive/<hostname>@<realm>;ssl=true; 以及bashèu的资料来源( source .bash_profile )你就完了。下一次就打字吧 beeline 它将连接到hive2服务器

nzk0hqpo

nzk0hqpo4#

•在一个命令中加载beeline、url并提供用户名和密码:


**beeline -u jdbc:hive2:// silver-server-hive.app.google.com:10000\ 

-n <yourname> -p <yourpassword> --incremental=true**
p1iqtdky

p1iqtdky5#

您可以使用@sravan提到的空白用户名和密码。这将以运行hiveserver2进程的用户身份执行查询。
但是,如果您设置了 hive.server2.enable.doAs 属性,或者在运行hiveserver2时将其放在hiveconf中,然后您可以选择通过提示符传递用户名和密码。在这种情况下,hive将使用给定的密码作为传递的用户名执行查询。这里的用户名是系统用户名。
在某些情况下,这是必需的—假设您以用户“hive”的身份运行hiveserver2进程,但是您有一个用hdfs path/user/alex/table1定义的外部表,该表由用户“alex”拥有,并且没有其他用户对此位置具有读/写访问权限。在这种情况下,将查询作为“配置单元”运行(通过输入空用户名和密码)将不起作用,因为它将无法访问目录并引发权限拒绝异常。

0ve6wy6x

0ve6wy6x6#

通过直线访问Hive:

启动beeline客户端

beeline --incremental=true

注意:命令行选项“-incremental=true”是可选的,但是它会延长您可以保持空闲并且不中断连接的时间。

连接到hive2服务器

!connect jdbc:hive2://silver-server-
hive.app.google.com:10000/default

注意:系统将提示您输入用户名和密码。使用用户名和密码

beeline> !connect jdbc:hive2:// silver-server-hive.app.google.com:10000/default
scan complete in 3ms
Connecting to jdbc:hive2:// silver-server-hive.app.google.com:10000/default
Enter username for jdbc:hive2:// silver-server-hive.app.google.com:10000/default:suman
Enter password for jdbc:hive2:// silver-server-hive.app.google.com:10000/default:*********

设置队列(如果有)

set mapred.job.queue.name=<your queue name>;

注意:您需要设置一个队列才能运行查询。

设置数据库

USE google_map_data;

注意:执行查询时应在数据库中。

重新连接非活动会话

!reconnect jdbc:hive2:// silver-server-hive.app.google.com:10000/default;

退出beeline客户端

!quit

笔记:
在一个命令中加载beeline、url并提供用户名和密码:

beeline -u jdbc:hive2:// silver-server-hive.app.google.com:10000\ 
-n <yourname> -p <yourpassword> --incremental=true**

基本直线查询

beeline支持一组丰富的sql查询函数。

获取有关数据的信息

SHOW DATABASES;
USE <database>;

SHOW TABLES;
DESC <table>;
DESC FORMATTED <table>;

简单有限选择语句

SELECT * FROM google_map_city limit 25;
sbdsn5lh

sbdsn5lh7#

是的,您可以在中设置用户名和密码 hive-site.xml tge中的文件 conf 文件夹。默认凭据为 APP / mine .
如何在配置单元中获取数据库用户名和密码

相关问题