WindowsのEclise RSEからリモートマシン(Ubuntu)でHbase、thrift、およびpythonを操作しようとしています。すべて正常に動作していますが、localhost に接続しようとするとエラーが発生します。
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()