hadoop hive 2.1.1 将Hive启动为服务
我們之前使用的Shell方式與Hive交互只是Hive交互方式中的一種,還有一種就是將Hive啟動(dòng)為服務(wù),然后運(yùn)行在一個(gè)節(jié)點(diǎn)上,那么剩下的節(jié)點(diǎn)就可以使用客戶端來連接它,從而也可以使用Hive的數(shù)據(jù)分析服務(wù)。
前臺(tái)模式
可以使用下面的命令來將Hive啟動(dòng)為服務(wù)。
/root/apps/hive-1.2.1/bin/hiveserver2后臺(tái)模式
也可以用下面的命令在后臺(tái)啟動(dòng)Hive服務(wù)。
nohup bin/hiveserver2 1>/var/log/hiveserver.log 2>/var/log/hiveserver.err &使用beeline連接Hive
用 lsof -i:10000 查看一下 服務(wù)是否已經(jīng)啟動(dòng)起來我們就在amaster上使用Hive自帶的beeline來連接Hive。
/root/apps/hive-1.2.1/bin/beenline命令提示行變成如下的樣子:
Beeline version 1.2.1 by Apache Hive beeline>使用下面的命令連接服務(wù)端:
!connect jdbc:hive2://localhost:10000默認(rèn)使用啟動(dòng)Hive的用戶名我這里是root,密碼為空,連上了。
0: jdbc:hive2://localhost:10000>嘗試執(zhí)行幾個(gè)命令:
show databases;
0: jdbc:hive2://localhost:10000> show databases; +----------------+--+ | database_name | +----------------+--+ | default | | test_db | +----------------+--+ 2 rows selected (1.651 seconds)select * from t_test;
0: jdbc:hive2://localhost:10000> select * from t_test; +------------+--------------+--+ | t_test.id | t_test.name | +------------+--------------+--+ | 1 | 張三 | | 2 | 李四 | | 3 | 風(fēng)凌 | | 4 | 三少 | | 5 | 月關(guān) | | 6 | abc | +------------+--------------+--+ LF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Connecting to jdbc:hive2://localhost:10000/default
Enter username for jdbc:hive2://localhost:10000/default: root
Enter password for jdbc:hive2://localhost:10000/default: ******
Error: Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): User: root is not allowed to impersonate root (state=,code=0)
解決方案:在hadoop>etc>hadoop>core-site.xml 中添加如下部分,重啟服務(wù)即可:
<property><name>hadoop.proxyuser.root.hosts</name><value>*</value></property><property><name>hadoop.proxyuser.root.groups</name><value>*</value> </property>
?HIVE2 :beeline連接設(shè)置用戶名和密碼注意問題
eeline connect有幾種方式,見hive-site.xml,缺省為NONE。
?<property><name>hive.server2.authentication</name><value>NONE</value><description>Expects one of [nosasl, none, ldap, kerberos, pam, custom].Client authentication types.NONE: no authentication checkLDAP: LDAP/AD based authenticationKERBEROS: Kerberos/GSSAPI authenticationCUSTOM: Custom authentication provider(Use with property hive.server2.custom.authentication.class)PAM: Pluggable authentication moduleNOSASL:? Raw transport</description></property>
設(shè)置相應(yīng)用戶名和密碼
<property>??? <name>hive.server2.thrift.client.user</name>
??? <value>root</value>
??? <description>Username to use against thrift client</description>
? </property>
? <property>
??? <name>hive.server2.thrift.client.password</name>
??? <value>123456</value>
??? <description>Password to use against thrift client</description>
? </property>
注意這里設(shè)置的用戶要求對(duì)inode="/tmp/hive" 有執(zhí)行權(quán)限,否則會(huì)出現(xiàn)下列問題:
Connecting to jdbc:hive2://localhost:10000/default Enter username for jdbc:hive2://localhost:10000/default: hive Enter password for jdbc:hive2://localhost:10000/default: ** Error: Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.security.AccessControlException: Permission denied: user=hive, access=EXECUTE, inode="/tmp/hive":root:supergroup:drwxrwx---at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:319)at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkTraverse(FSPermissionChecker.java:259)at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:205)at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:190)at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1698)at org.apache.hadoop.hdfs.server.namenode.FSDirStatAndListingOp.getFileInfo(FSDirStatAndListingOp.java:108)at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getFileInfo(FSNamesystem.java:3817)at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.getFileInfo(NameNodeRpcServer.java:1005)at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.getFileInfo(ClientNamenodeProtocolServerSideTranslatorPB.java:843)
總結(jié)
以上是生活随笔為你收集整理的hadoop hive 2.1.1 将Hive启动为服务的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hive2.1.1、Hadoop2.7.
- 下一篇: Hiv:SQuirrel连接hive配置