版本
apache-hive-3.0.0-bin
hadoop-3.0.3
spark-2.3.1-bin-hadoop2.7
hbase 2.3.2
1.安装好mysql
创建用户(mysql8.0)
mysql> CREATE USER 'id'@'%' IDENTIFIED BY 'passwd';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'id'@'%' WITH GRANT OPTION;
mysql> flush privileges;
2.解压hive
将jdbc的jar包丢进安装目录的lib目录下
在conf下新建配置文件hive-site.xml
新建的xml会覆盖默认配置
注意修改数据库名,用户名,密码
<configuration>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
<description>driver class</description>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1:3306/hive_2020_test1?createDatabaseIfNotExist=true</value>
<description>mysql url</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>spark</value>
<description>username</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>spark</value>
<description>mysql passwd</description>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
<description>TCP 的监听端口,默认为10000。 Port number of HiveServer2 Thrift interface.
Can be overridden by setting $HIVE_SERVER2_THRIFT_PORT</description>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>0.0.0.0</value>
<description>host设置成0.0.0.0,来接收未知来源的ip
Bind host on which to run the HiveServer2 Thrift interface.
Can be overridden by setting $HIVE_SERVER2_THRIFT_BIND_HOST
</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
</configuration>
3.初始化数据库(二选一)
#初始化mysql为元数据库(建议)
schematool -dbType mysql -initSchema
#初始化derby为元数据库(内置数据库,不推荐)
schematool -dbType derby -initSchema
如果报错:java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
![截屏2020-10-27 下午10.07.07](/Users/angelia/Library/Application%20Support/typora-user-images/截屏2020-10-27%20下午10.07.07.png)
原因:1.系统找不到相关jar包
2.同一类型的 jar 包有不同版本存在,系统无法决定使用哪一个
一:检查发现 com.google.common.base.Preconditions.checkArgument 该类来自于guava.jar
二:查看该jar包在hadoop和hive中的版本信息
hive-3.1.2(路径:安装目录下的\lib)
hadoop-3.2.1(路径:安装目录下的\hadoop\share\hadoop\common\lib)
三:将两处guava.jar统一为高版本即可
6.启动Hive客户端
hive