hbase thrift2 (hbase 2.0.5)服务的开启以及hbase.thrift 的C_glib编译

thrift安装见上一个博客

由于项目需要,通过C传数据进Hbase,发现可以通过thrift实现

进入hbase目录开启thrift2服务(若需要,注意切换用户)

cd /home/hadoop/hbase-2.0.5/bin
[hadoop@master bin]$ hbase-daemon.sh start thrift2

出现错误,通过日志查看报错信息

vim /home/hadoop/hbase-2.0.5/logs/hbase-hadoop-thrift2-master.out

原因

Caused by: java.net.BindException: 地址已在使用

查看是哪个占用,但发现是hadoop的进程。。。。

netstat -ntlp | grep 9095
tcp6       0      0 :::9095                 :::*                 LISTEN      -

不知道该杀哪个进程,只好重新使用其他端口开启。。内部和外部通信端口都需要改(因为都被占用了 = =)

9091 外部端口(原9090被占用) 9096 内部通信端口(原9095被占用),若要重设端口hbase-daemon.sh start rest -p --infoport

[hadoop@master bin]$ hbase-daemon.sh start thrift2 -p 9091 --infoport 9096

查看进程,thriftServer进程成功启动

[hadoop@master bin]$ jps
45123 NodeManager
98866 HMaster
43863 NameNode
72630 Jps
44459 SecondaryNameNode
44877 ResourceManager
70879 ThriftServer

使用thrift 转换hbase.thrift

下载hbase 源码(和安装的版本对应hbase2.0.5):

https://www-us.apache.org/dist/hbase/2.0.5/hbase-2.0.5-src.tar.gz

解压后进入目录(源码目录)

cd /hbase-2.0.5/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2

转换为C_glib

thrift --gen c_glib hbase.thrift 

查看状态(会在当前目录下生成gen-c_glib文件夹,将这些文件移到C项目即可)

[ryan@master thrift2]$ thrift --gen c_glib hbase.thrift 
[ryan@master thrift2]$ ls
gen-c_glib  hbase.thrift

[ryan@master gen-c_glib]$ ls
hbase_types.c  hbase_types.h  t_h_base_service.c  t_h_base_service.h

Starting the HBase Thrift Server in the Background

Where is the service’s port, and is the port for the web-ui with information about the service, use the following command to start the HBase Thrift server in the background:

/usr/hdp/current/hbase-master/bin/hbase-daemon.sh start thrift -p --infoport
Where is the service’s port, and is the port for the web-ui with information about the service, use the following command to start the HBase REST server in the background:

/usr/hdp/current/hbase-master/bin/
For additional information, see the Starting and Stopping the REST Server and Thrift API and Filter Language sections of Apache HBase Reference Guide.

你可能感兴趣的:(大数据)