hiveserver2的启动与datagrip连接hiveserver2
hiveserver2的启动与datagrip连接hiveserver2
hiveserver2的配置
- {HIVE_HOME}\conf\hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- hive -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive</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>root</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
<!-- hiveserver2 -->
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>192.168.134.154</value>
</property>
</configuration>
- {HADOOP_HOME}\etc\hadoop\core-site.xml
注意如果是真集群下的hadoop需要修改所有节点上的配置文件
<!-- 如果连接不上10000 -->
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hive.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hive.groups</name>
<value>*</value>
</property>
- 启动hiverserver2
hiveserver2
hive --service hiveserver2
- Tips
-
hive版本1.2.1 hadoop版本2.7.1 mysql版本8 可能会出现启动时命令行一直加载不出来的问题,mysql换回5.7版本可以解决
-
启动如果有问题善用debug模式
hive --hiveconf hive.root.logger=DEBUG,console
hiveserver2 --hiveconf hive.root.logger=DEBUG,console
- hive的metastore信息其实在启动的过程中就会自动创建一部分,不过如果需要更加完整安全的元数据初始化需要使用
schematool -dbType mysql -initSchema
使用datagrip连接hive
datagrip自带的hive driver为3.*版本,低版本需要自己下载驱动,但是网络上自己查找这些资源异常复杂,所以还是通过maven项目自动下载过来然后拷贝走
新建一个maven项目,引入以下依赖
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.7.1</version>
</dependency>
然后通过本地的maven仓库路径搜索以下包
hive-common-1.2.1.jar
hive-service-1.2.1.jar
hadoop-common-2.7.1.jar
commons-httpclient-3.1.jar
commons-logging-1.2.jar
curator-client-2.6.0.jar
curator-framework-2.6.0.jar
hadoop-auth-2.7.1.jar
hadoop-common-2.7.1.jar
hive-metastore-1.2.1.jar
httpclient-4.4.jar
httpcore-4.4.jar
zookeeper-3.4.6.jar
libthrift-0.9.2.jar
hive-jdbc-1.2.1.jar
guava-14.0.1.jar
hive-serde-1.2.1.jar
slf4j-api-1.7.5.jar
单独拷贝出去并加入datagrip的hive链接driver中
或者还可以自己去该网站下载配套的hive驱动(其实还是上面那种方法好,因为这个jar包覆盖版本并不全面)
https://github.com/timveil/hive-jdbc-uber-jar/releases
之后test connection 一般就可以通过了
但是,如果出现test connection通过但是任意查询出现org.apache.thrift.TApplicationException: Required field 'client_protocol' is unset!
这个问题的时候,请关闭项目重新打开,因为更换驱动后datagrip的查询部分不会自动重新加载新的驱动,让我在版本完全对齐的情况下找了足足半天有余,最后才想到重新启动