2015-02-24 163 views
0

我正嘗試從Windows上的Eclise RSE遠程計算機(Ubuntu)上使用Hbase,thrift和python。一切工作正常,但是當我試圖連接到本地主機我得到一個錯誤:Eclipse RSE連接到遠程計算機上的本地主機

thrift.transport.TTransport.TTransportException: Could not connect to localhost:9090 

如果我在遠程機器上運行通過SSH終端這段代碼,它完美的作品。

這裏是我的代碼:

#!/usr/bin/env python 

import sys, glob 
sys.path.append('gen-py') 
sys.path.insert(0, glob.glob('lib/py/build/lib.*')[0]) 

from thrift import Thrift 
from thrift.transport import TSocket 
from thrift.transport import TTransport 
from thrift.protocol import TBinaryProtocol 
from hbase import Hbase 

# Connect to HBase Thrift server 
transport = TTransport.TBufferedTransport(TSocket.TSocket('localhost', 9090)) 
protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport) 

# Create and open the client connection 
client = Hbase.Client(protocol) 
transport.open() 

tables = client.getTableNames() 

print(tables) 

# Do Something 

transport.close() 

回答

0

你知道什麼是本地主機的手段?它意味着你正在運行命令的機器。例如。如果我在我的PC上的瀏覽器中輸入http://localhost:8080/,那麼它會調用運行在我的機器上的端口8080上的服務器。

如果您嘗試在同一個盒子上連接到本地主機,我確定您的連接正常工作。如果從不同的機器連接,則需要知道要連接的盒子的IP地址或主機名。

相關問題