python thrift hbase安装连接
默认已装好
- hbase,我的版本是hbase-0.98.24,并运行
- python 2.7.x
步骤:
sudo apt-get install automake bison flex g++ git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config,安装这些必要的包和库,官网的是libboost1.55-all-dev,但是我是用的是ubuntu16.04 LTS好像没这么低的版本,所以使用了libboost-all-dev替代
安装boost_1_60_0.tar.gz,这一步要好长时间
- wget http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz
- tar xvf boost_1_60_0.tar.gz
- cd boost_1_60_0
- ./bootstrap.sh
- sudo ./b2 install
下载thrift,
- download 地址
- tar thrift-0.10.0.tar.gz
- cd thrift-0.10.0.tar.gz
- ./configure && make
- sudo make install
检验thrift安装
root@ubuntu:/home/wasdns/thrift# thrift -version
Thrift version 1.0.0-dev
如果出错参考 http://www.cnblogs.com/qq952693358/p/6193842.html
一般我们在Linux下执行某些外部程序的时候可能会提示找不到共享库的错误, 比如:
tmux: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory原因一般有两个, 一个是操作系统里确实没有包含该共享库(lib.so.文件)或者共享库版本不对, 遇到这种情况那就去网上下载并安装上即可.
另外一个原因就是已经安装了该共享库, 但执行需要调用该共享库的程序的时候, 程序按照默认共享库路径找不到该共享库文件.
root@ubuntu:/home/wasdns/thrift# cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf root@ubuntu:/home/wasdns/thrift# echo "/usr/local/lib" >> /etc/ld.so.conf
root@ubuntu:/home/wasdns/thrift# cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf /usr/local/lib
root@ubuntu:/home/wasdns/thrift# ldconfig
root@ubuntu:/home/wasdns/thrift# thrift -version
Thrift version 1.0.0-dev
安装完成后到hbase的目录下,找到Hbase.thrift,该文件一般在hbase目录下的src/main/resources/org/apache/hadoop/hbase/thrift。如果没有,那么下载响应的源码安装包,把其中的hbase-thrift目录下的src复制到hbase目录下。
- thrift --gen py Hbase.thrift 会生成gen-py文件夹,将其修改成hbase
- sudo pip install thrift 安装python的thrift库
- bin/hbase-daemon.sh start thrift 启动hbase的thrift服务,默认端口是9090
- 创建hbase表
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol from hbase import Hbase
from hbase.ttypes import * transport = TSocket.TSocket('localhost', 9090); transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport); client = Hbase.Client(protocol)
transport.open() contents = ColumnDescriptor(name='cf:', maxVersions=1)
client.createTable('test', [contents]) print client.getTableNames()
执行代码,成功后,进入hbase的shell,用命令list可以看到刚刚的test表已经创建成功。
python thrift hbase安装连接的更多相关文章
- 【hbase】使用thrift with python 访问HBase
HBase 版本: 0.98.6 thrift 版本: 0.9.0 使用 thrift client with python 连接 HBase 报错: Traceback (most recent ...
- ambari安装集群下python连接hbase之安装thrift
简介: python连接hbase是需要通过thrift连进行连接的,ambari安装的服务中貌似没有自带安装hbase的thrift,我是看配置hbase的配置名称里面没有thrift,cdh版本的 ...
- Hbase理论&&hbase shell&&python操作hbase&&python通过mapreduce操作hbase
一.Hbase搭建: 二.理论知识介绍: 1Hbase介绍: Hbase是分布式.面向列的开源数据库(其实准确的说是面向列族).HDFS为Hbase提供可靠的底层数据存储服务,MapReduce为Hb ...
- python操作Hbase
本地操作 启动thrift服务:./bin/hbase-daemon.sh start thrift hbase模块产生: 下载thrfit源码包:thrift-0.8.0.tar.gz 解压安装 . ...
- python 操作 hbase
python 是万能的,当然也可以通过api去操作big database 的hbase了,python是通过thrift去访问操作hbase 以下是在centos7 上安装操作,前提是hbase已经 ...
- python连接hbase
安装HBase HBase是一个构建在HDFS上的分布式列存储系统,主要用于海量结构化数据存储.这里,我们的目标只是为Python访问HBase提供一个基本的环境,故直接下载二进制包,采用单机安装.下 ...
- 【Hbase三】Java,python操作Hbase
Java,python操作Hbase 操作Hbase python操作Hbase 安装Thrift之前所需准备 安装Thrift 产生针对Python的Hbase的API 启动Thrift服务 执行p ...
- Python Thrift 简单示例
本文基于Thrift-0.10,使用Python实现服务器端,使用Java实现客户端,演示了Thrift RPC调用示例.Java客户端提供两个字符串参数,Python服务器端计算这两个字符串的相似度 ...
- python thrift使用实例
前言 Apache Thrift 是 Facebook 实现的一种高效的.支持多种编程语言的远程服务调用的框架.本文将从 Python开发人员角度简单介绍 Apache Thrift 的架构.开发和使 ...
随机推荐
- react中对props.children进行操作
之前写的更多的时候是直接使用简写 {props.children} 这样就可以了,但是当有时候需要对传入的子组件进行一些操作的时候需要用到React.Children方法 {React.Childre ...
- linux之参数实用讲解
<1>linux文件参数 在Windows下是使用 %1 %2 %3 而在Linux下是使用 $1 $2 $3 ------------------- 如: 1.某bat文件 cd ...
- [论文]Clustering-Based Ensembles as an Alternative to Stacking
Clustering-Based Ensembles as an Alternative to Stacking 作者:Anna Jurek, Yaxin Bi, Shengli Wu, and Ch ...
- Boost::thread库的使用(转)
原文转自 http://blog.csdn.net/lee353086/article/details/4673790 本文主要由线程启动.Interruption机制.线程同步.等待线程退出.Thr ...
- eclipse 同一个package 有的文件 中文乱码,有的文件中文正常
1.这是编码格式导致的. 先在对应包名上右击,选择属性,将包内所有的文件都设置为GBK格式, 然后查看每个文件,如果有乱码,则将这个文件的编码格式单独设为 UTF-8 2.有个项目使用百度语音做开发, ...
- Building MFC application with /MD[d] (CRT dll version)requires MFC shared dll version
解决方法:
- Python包管理工具pip的基本使用
1.简介 pip 是一个Python包管理工具,主要是用于安装 PyPI 上的软件包,可以替代 easy_install 工具. 2.pip安装 如果你安装的Python 2 >=2.7.9 或 ...
- Linux笔记:vim
文件搜索后显示高亮,即使退出编辑高亮依然存在.使用以下几个方法: 1)指令模式下运行:nohlsearch 2)运行set nohlsearc,可永久关闭搜索高亮 3)搜索任意不存在的字符串
- 分布式配置中心介绍--Spring Cloud学习第六天(非原创)
文章大纲 一.分布式配置中心是什么二.配置基本实现三.Spring Cloud Config服务端配置细节(一)四.Spring Cloud Config服务端配置细节(二)五.Spring Clou ...
- java.lang.NoSuchMethodError: main Exception in thread "main" ===Exception
java.lang.NoSuchMethodError: mainException in thread "main" 出现该异常是因为在之前我的项目中自定义了一个String类, ...