Hive的服务

Hive的服务
 

1.Hive shell
<1>执行HiveQL语句hive>select * from userinfo;
<2>设置和查看临时变量hive>set fs.default.name=hdfs://192.168.1.10:9000
<3>导入jar包hive>add jar hivejar.jar
<4>创建函数hive>create temporary function udfTest as 'com.cstore.udfExample'

也可以使用本地系统的命令去执行Hive的shell
hive -e 'select * from userinfo'执行HiveQL语句
hive -config /hive-0.7.1/conf重新载入新的配置文件
hive -service hiveserver启动服务
2.JDBC/ODBC
<1>JDBC
Hive的jar包中"org.apache.hadoop.hive.jdbc.HiveDriver"负责提供JDBC接口
当Hive在指定的端口启动了hiveserver服务后,客户端通过java的Thrift和Hive服务器进行通行,具体过程如下:
1.开启hiveserver服务hive --service hiveserver 50000
2.建立与Hive的连接Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
Connection con = DriverManager.getConnection("jdbc:hive://localhost:50000/default","hive","123456");

认只能连接到default
<2>ODBC
与JDBC类似
JDBC和ODBC都不是很成熟
3.Thrif服务
Hive的Thrif是一种跨语言服务的可伸缩软件框架
4.web接口
Hive Web Interface 简称hwi 是hive提供的web接口 
首先把hwi服务的主机地址和监听端口配置到hive-site.xml中
 

<property>
                <name>hive.hwi.listen.host</name>
                <value>0.0.0.0</value>
                <description>This is the host address the Hive Web Interface will listen on</description>
 </property>
<property>
                <name>hive.hwi.listen.port</name>
                <value>9999</value>
                <description>This is the port the Hive Web Interface will listen on</description>
</property>

 
开启Hive的Web服务需要引入ant的jar包,命令如下:
export ANT_LIB=$ANT_HOME/lib
hive --service hwi
完成上述操作后在浏览器中键入http://localhost:9999/hwi 即可进入Hive的web界面
5.源数据服务
Hive的源数据中保存了表的属性和服务信息,为查询操作提供依据,默认的源数据库是内嵌的Deby,这种情况下metastore和其他Hive服务运行在统一个java虚拟机里。
只能允许建立单个会话,要实现多用户多会话支持,需要配置一个独立的源数据库,提供源数据服务。Hive的元数据服务可以把metastore共享给其他客户端。

猜你喜欢

转载自oaksun.iteye.com/blog/1943187
今日推荐