启动远程链接
hive --service hiveserver2 --hiveconf hive.root.logger=DEBUG,console
lsof -i:10000 查看是否启动成功
报错修改文件 /software/hadoop/hadoop-2.7.7/etc/hadoop/core-site.xml
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
链接
beeline -u jdbc:hive2//127.0.0.1:10000 -n root
beeline
!connect jdbc:hive2://192.168.0.197:10000
!connect jdbc:hive2://master:10000
链接报错解决方案(TProtocolException: TProtocolException(type=4))
原因是由于connect方法里面没有增加参数:auth_mechanism='PLAIN'
报错 AttributeError: ‘TSocket’ object has no attribute ‘isOpen’
pip uninstall thrift-sasl
pip install thrift-sasl==0.2.1
报错 thriftpy.transport.TTransportException: TTransportException(type=1, message=“Could not start SASL: b’Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2’”)
pip uninstall SASL
报错 TypeError: can’t concat str to bytes
init.py 第94行
header = struct.pack(">BI", status, len(body))
#按照网上的提供的办法增加对BODY的处理
if (type(body) is str):
body = body.encode()
self._trans.write(header + body)
self._trans.flush()
解决完毕启动成功python操作数据库
create database myhive;
create table if not exists userLogo(id int,username string,password string, age int);
insert into userLogo values(1,'xiaodou','B',28);
select * from userLogo;
-- 删除库
drop database if exists db_name;
-- 强制删除库
drop database if exists db_name cascade;
-- 删除表
drop table if exists employee;
-- 清空表
truncate table employee;
-- 清空表,第二种方式
insert overwrite table employee select * from employee where 1=0;
-- 删除分区
alter table employee_table drop partition (stat_year_month>='2018-01');
-- 按条件删除数据
insert overwrite table employee_table select * from employee_table where id>'180203a15f';
安装库
pip install ipython six bit_array thriftpy thrift_sasl==0.2.1 sasl impyla
from impala.dbapi import connect
conn = connect(host="192.168.0.197", port=10000, user="root", password="admin",database="databig", auth_mechanism="PLAIN")
cur = conn.cursor()
cur.execute("show databases")
print(cur.fetchall())
conn.close()