hive3.1.2的连接地址 http://archive.apache.org/dist/hive/hive-3.1.2/
1、下载后上传到/opt/apps下
2、解压
tar -zxvf apache-hive-3.1.2-bin.tar.gz
3、重命名
mv apache-hive-3.1.2-bin hive-3.1.2
4、执行以下命令,修改hive-site.xml
cd /opt/apps/hive-3.1.2/conf mv hive-default.xml.template hive-default.xml
5、执行以下命令,新建一个hive-site.xml配置文件
vim hive-site.xml
javax.jdo.option.ConnectionURL jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true JDBC connect string for a JDBC metastore javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver Driver class name for a JDBC metastore javax.jdo.option.ConnectionUserName root username to use against metastore database javax.jdo.option.ConnectionPassword root password to use against metastore database
6、启动hive
注意:启动hive之前要先把hadoop集群先启动
1.首先下载mysql jdbc包
2.把它复制到hive/lib目录下。
3.启动并登陆mysql
4.创建hive用户,数据库,并把权限赋给root用户。
create database hive; grant all on . to hive@localhost identified by 'root'; flush privileges; #刷新 exit #退出mysql
验证是否创建成功
安装中的错误:
(1)hive连接提示 root is not allowed to impersonate root (state=08S01,code=0)
解决:在hadoop 的core-site.xml添加如下内容,然后重启
hadoop.proxyuser.root.groups root Allow the superuser oozie to impersonate any members of the group group1 and group2 hadoop.proxyuser.root.hosts * The superuser can connect only from host1 and host2 to impersonate a user
(2)Exception in thread “main” java.lang.NoSuchMethodError:com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;) at org.apache.hadoop.conf.Configuration.set(Configuration.java:1380)
hive内依赖的guava.jar和hadoop内版本不一致导致
解决方法:
-
查看hadoop安装目录下的guava.jar版本和hive安装目录下的guava.jar是否一致
-
如果两者不一致,则删除低版本的,把高版本的复制过去。
注: hadoop3.1.3的guava版本是27,而hive3.1.2版本是19
路径:
hadoop(opt/apps/hadoop3.1.3/share/common/lib)
hive(opt/apps/hive-3.1.2/lib)
(3)Failed to load driver
没有com.mysql.jdbc.Driver mysql驱动,上传mysql-connector-java-5.1.47.jar到hive的lib目录下
(4) schematool -initSchema -dbType mysql报错
(5)is not allowed to connect to this mmysql server 本地电脑的navicat链接不上mysql
解决:
-
mysql -u root -p 登录到mysql中。
-
use mysql;
-
select host from user where user='root';
-
修改帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入MySQL后,更改 “mysql”
数据库里的 “user” 表里的 “host” 项,从"localhost"改称"%"
update user set host = '%' where user ='root'; flush privileges;



