thrift的使用及遇到的問題


centos 系統安裝官方文檔:http://thrift.apache.org/docs/install/centos

一、按該文檔安裝出現了一系列的問題,記錄如下:

1.安裝thrift時./bootstrap.sh出錯,然后安裝libevent問題解決
(首先:git gc,清除./configure 和make錯誤的信息)
# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz

# tar zxvf libevent-1.2.tar.gz
# cd libevent-1.2
# ./configure –prefix=/usr
# make
# make install

2.安裝thrift到make步驟時出現如下錯誤:

  g++: error: /usr/lib64/libboost_unit_test_framework.a: No such file or directory

3.../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evutil_make_socket_closeonexec'

  ../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evbuffer_get_length'

  ../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evbuffer_pullup'

  collect2: error: ld returned 1 exit status

4.automake --add-missing”時出錯及解決辦法:

a. configure.ac: error: no proper invocaction of AM_INIT_AUTOMAKE was found.
b. Makefile.am: error: required file './NEWS' not found
    Makefile.am: error: required file './README' not found
    Makefile.am: error: required file './AUTHORS' not found
    Makefile.am: error: required file './ChangeLog' not found
    使用命令:automake --add-missing --copy --foreign
c. required file `config.h.in' not found 
  解決:在執行automake --add-missing之前執行autoheader,生成config.h.in
d. Libtool library used but `LIBTOOL' is undefined?
  解決:重裝libtool 然后再運行
  try run “libtoolize” in that directory first, and then re-run autoreconf
e. /usr/share/automake-1.14/am/depend2.am: error: am__fastdepCXX does not appear in AM_CONDITIONAL
  在configure.ac 中加入
AC_INIT
AM_INIT_AUTOMAKE

dnl add this
AC_PROG_CXX

AC_PROG_LIBTOOL

  本人安裝thrift遇到了各種各樣的坑,真是一波三折,差點放棄,希望thrift能把安裝過程完善一下,讓使用者投入更多的時間在使用上而不是安裝上。

二、Thrift python使用過程遇到的錯誤:

No handlers could be found for logger "thrift.server.TServer"

參考網址:http://blog.csdn.net/mantoureganmian/article/details/48340215

  thrift框架做的很好,封裝的也很好,不僅僅有代碼生成功能,而且還有錯誤處理機制。這種錯誤處理機制處理過程是:當Handler類中的出現錯誤時,一律提示:“No handlers could be found for logger "thrift.server.TServer"”。換句話說,當變量拼寫錯誤時,不會提示某個變量未命名,而提示“No handlers could be found for logger "thrift.server.TServer"”,這樣無疑增加了改錯難度,坑啊!!!

   對於此,比較好的解決方案是:使用try....except  Exception as e:模塊來手動打印錯誤。try模塊代碼示例如下:

try:  
    a=b  
except Exception as  e:  
    print e  

  我代碼出錯的原因是:server端返回給了client端字符串為漢字,改成拼音問題解決。

  thrift整體來說還是很好用的,特別是支持跨多種語言,減少了開發者間的通信難度。

  本人菜鳥一枚,但不會在菜鳥的路上越走越遠,thrift遇到問題還會持續更新。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM