我有hive-site.xml
,其属性由setting-up-hiveserver2
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.0.25:3306/hive_test?characterEncoding=UTF-8</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123123</value>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/data/hive</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/data/temp</value>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>false</value>
</property>
<property>
<name>hive.querylog.location</name>
<value>/home/hadoop/hadoopLogs/hive</value>
</property>
<property>
<name>hive.server2.thrift.min.worker.threads</name>
<value>5</value>
</property>
<property>
<name>hive.server2.thrift.max.worker.threads</name>
<value>500</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>cloud1</value>
</property>
<property>
<name>hive.server2.transport.mode</name>
<value>binary</value>
</property>
<property>
<name>hive.server2.authentication</name>
<value>NOSASL</value>
</property>
</configuration>
这是使用pyhs2
import pyhs2
class HiveClient:
def __init__(self, db_host, user, password, database, port=10000, authMechanism="PLAIN"):
self.conn = pyhs2.connect(host=db_host,
port=port,
authMechanism=authMechanism,
user=user,
password=password,
database=database,
)
def query(self, sql):
with self.conn.cursor() as cursor:
cursor.execute(sql)
return cursor.fetch()
def close(self):
self.conn.close()
def main():
hive_client = HiveClient(db_host='cloud1', port=10000,user='user', password='bblink',
database='default', authMechanism='PLAIN')
result = hive_client.query('select * from bblink_bi_test3 limit 10')
print result
hive_client.close()
if __name__ == '__main__':
main()
但是当我运行这个python脚本时,在hiverserver2控制台或python客户端上没有任何事情发生。
请帮助我。