hadoop集群安装与配置--c#调用hive的thrift服务

1.在hadoop.client上开始运行hive的thrift服务,命令如下

bin/hive --service hiveserver

2.通过NuGet安装hive的c#客户端,项目地址如下

https://bitbucket.org/vadim/hive-sharp/

3.c#调用服务demo代码

int port = 10000;//注意hadoop.client服务器上防火墙一定打开10000端口
var socket = new TSocket("hadoop.client的ip", port);
var transport = new TBufferedTransport(socket);
var proto = new TBinaryProtocol(transport);
//以上代码为thrift架构通信公用
var client = new ThriftHive.Client(proto);//此处代码需要使用thrift生成
transport.Open();//公用         
client.execute("select * from show1 limit 2");//hive逻辑
var rows2 = client.fetchAll();
transport.Close();//公用