一、 首先要安装thrift和fb303的安装
1、首先安装一个最新版本的autoconf,否则后面编译的时候会出问题(提示说autoconf版本要2.65以上才行)
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar xvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --bindir=/usr/bin
make && make install
2、更新依赖库(安装过程中会提示找不到安装包,你需要自己下载最新的安装包)
yum install libevent libevent-develpython-devel
yum install gcc-c++
yum install libtool
yum install automake
yum install byacc flex
3、安装boost(推荐选择1.45版本,否则后面会碰到问题,折腾)
wget http://jaist.dl.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.gz
tar -xf boost_1_45_0.tar.gz
cd boost_1_45_0
./bootstrap.sh
./bjam install --prefix=/usr/local/bootstrap
4、安装thrift
wget --no-check-certificate https://dist.apache.org/repos/dist/release/thrift/0.8.0/thrift-0.8.0.tar.gz
tar xzf thrift-0.8.0.tar.gz
cd thrift-0.8.0
--with-php-config=/usr/local/php/bin/php-config
./configure --with-boost=/usr/local/bootstrap/ --with-java --prefix=/usr/local/thrift
make && make install
5、安装fb303(注意,fb303是thrift的一个子目录,在thrift-0.8.0里面)
cd thrift-0.8.0/contrib/fb303
./bootstrap.sh --prefix=/usr/local/thrift/fb303 --with-boost=/usr/local/bootstrap/ --with-thriftpath=/usr/local/thrift/
./configure --prefix=/usr/local/thrift/fb303 --with-boost=/usr/local/bootstrap/ --with-thriftpath=/usr/local/thrift/ CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H"
6、thrift的lib包加入python的lib下
$:cd .../thrift-0.8.0/lib/py/build/lib.linux-x86_64-2.7
cp -r thrift/ /usr/lib/python2.7/site-packages/
7、在使用Python连接hive之前需要将hive中的文件拷贝到python的sys.path中
cp -r $HIVE_PATH/lib/py /usr/local/lib/python2.6/site-packages
8、启动hive服务 hive --service hiveserver -v -p 10000
9、启动matestore hive --service metastore
二、编写python代码
三、结果