Hive搭建

news2025/7/19 6:25:10

Hive系列第二章


第二章 Hive搭建

2.1 MySQL5.6安装

1、检查删除已有的
有就删除,没有就不用管。
rpm -qa | grep mysql
rpm -e mysql-libs-5.1.73-8.el6_8.x86_64 --nodeps

rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

2、删除mysql分散的文件夹
whereis mysql
rm -rf /usr/lib64/mysql


3、 准备安装包 MySQL-5.6.27-1.linux_glibc2.5.x86_64.rpm-bundle.tar, 上传,解压 
命令:tar -xvf MySQL-5.6.27-1.linux_glibc2.5.x86_64.rpm-bundle.tar 

4、 安装 server 
rpm -ivh MySQL-server-5.6.27-1.linux_glibc2.5.x86_64.rpm 

5、 安装客户端 
rpm -ivh MySQL-client-5.6.27-1.linux_glibc2.5.x86_64.rpm 

6、 登陆 MYSQL(登录之前千万记得一定要启动 mysql 服务) 
启动MySQL服务
service mysql start
登录MySQL 
然后登陆,初始密码在 /root/.mysql_secret 这个文件里 
Cq2HDH3dUr1ggQIu

mysql -uroot -pCq2HDH3dUr1ggQIu

7、 修改密码 
set PASSWORD=PASSWORD('111111'); 

8、退出登陆验证,看是否改密码成功 

9、增加远程登陆权限,执行以下两个命令:
>grant all privileges on *.* to 'root'@'%' identified by '111111' with grant option;
>flush privileges;

10、至此 mysql 安装成功

2.2 Hive1安装

1、安装mysql
2、上传安装包 apache-hive-1.2.1-bin.tar.gz 
3、 解压安装包 
tar -zxvf apache-hive-1.2.1-bin.tar.gz
mv apache-hive-1.2.1-bin hive
4、 修改配置文件 
目录下面没有,直接vim就可以了。
[root@hadoop0 conf]# vim hive-site.xml 

<configuration>
<property>
	<name>javax.jdo.option.ConnectionURL</name>
	<value>jdbc:mysql://localhost:3306/hivedb?createDatabaseIfNotExist=true</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>111111</value>
</property>
<property>
	<name>hive.metastore.warehouse.dir</name>
	<value>/user/hive/warehouse</value>
</property> 
</configuration>

5、 一定要记得加入 MySQL 驱动包(mysql-connector-java-5.1.40-bin.jar) 
该 jar 包放置在 hive 的根路径下的 lib 目录 

6、安装完成,配置环境变量 
export HIVE_HOME=/software/hive
export PATH=$PATH:$HIVE_HOME/bin 

7、 验证 Hive 安装 
[root@hadoop0 lib]# hive --help
Usage ./hive <parameters> --service serviceName <service parameters>
Service List: beeline cli help hiveburninclient hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool version 
Parameters parsed:
  --auxpath : Auxillary jars 
  --config : Hive configuration directory
  --service : Starts specific service/component. cli is default
Parameters used:
  HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
  HIVE_OPT : Hive options
For help on a particular service:
  ./hive --service serviceName --help
Debug help:  ./hive --debug --help


8、 初始化元数据库 
注意:当 hive 依赖普通分布式 hadoop 集群,不做初始化也是 OK 的,当 hive 第一次启动的时候会自动进行初始化。
schematool  -dbType  mysql  -initSchema

9、 启动 Hive 客户端 
[root@hadoop0 bin]# hive --service cli
Logging initialized using configuration in jar:file:/software/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
hive> 
直接使用hive启动也行。

10、退出 Hive 
hive> quit; 
或者 
hive> exit; 

2.3 Hive2安装

1、安装mysql
2、上传安装包 apache-hive-2.3.8-bin.tar.gz
3、 解压安装包 
tar -zxvf apache-hive-2.3.8-bin.tar.gz
mv apache-hive-2.3.8-bin hive2
4、 修改配置文件 
目录下面没有,直接vim就可以了。
[root@hadoop0 conf]# vim hive-site.xml 

<configuration>
<property>
	<name>javax.jdo.option.ConnectionURL</name>
	<value>jdbc:mysql://localhost:3306/hivedb2?createDatabaseIfNotExist=true</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>111111</value>
</property>
<property>
	<name>hive.metastore.warehouse.dir</name>
	<value>/user/hive/warehouse</value>
</property> 
</configuration>

5、 一定要记得加入 MySQL 驱动包(mysql-connector-java-5.1.40-bin.jar) 
该 jar 包放置在 hive 的根路径下的 lib 目录 

6、安装完成,配置环境变量 
export HIVE_HOME=/software/hive2
export PATH=$PATH:$HIVE_HOME/bin 

7、 验证 Hive 安装 
[root@hadoop0 lib]# hive --help
Usage ./hive <parameters> --service serviceName <service parameters>
Service List: beeline cli help hiveburninclient hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool version 
Parameters parsed:
  --auxpath : Auxillary jars 
  --config : Hive configuration directory
  --service : Starts specific service/component. cli is default
Parameters used:
  HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
  HIVE_OPT : Hive options
For help on a particular service:
  ./hive --service serviceName --help
Debug help:  ./hive --debug --help


8、 初始化元数据库 
注意:当 hive 依赖普通分布式 hadoop 集群,不做初始化也是 OK 的,当 hive 第一次启动的时候会自动进行初始化。
schematool  -dbType  mysql  -initSchema

9、 启动 Hive 客户端 
[root@hadoop0 lib]# hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/software/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/software/hive2/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
21/05/18 21:20:35 INFO conf.HiveConf: Found configuration file file:/software/hive2/conf/hive-site.xml

Logging initialized using configuration in jar:file:/software/hive2/lib/hive-common-2.3.8.jar!/hive-log4j2.properties Async: true
21/05/18 21:20:38 INFO SessionState: 
Logging initialized using configuration in jar:file:/software/hive2/lib/hive-common-2.3.8.jar!/hive-log4j2.properties Async: true
21/05/18 21:20:39 INFO session.SessionState: Created HDFS directory: /tmp/hive/root/1a0eb4c0-a7eb-410a-9734-925ea5d03807
21/05/18 21:20:39 INFO session.SessionState: Created local directory: /tmp/root/1a0eb4c0-a7eb-410a-9734-925ea5d03807
21/05/18 21:20:39 INFO session.SessionState: Created HDFS directory: /tmp/hive/root/1a0eb4c0-a7eb-410a-9734-925ea5d03807/_tmp_space.db
21/05/18 21:20:39 INFO conf.HiveConf: Using the default value passed in for log id: 1a0eb4c0-a7eb-410a-9734-925ea5d03807
21/05/18 21:20:39 INFO session.SessionState: Updating thread name to 1a0eb4c0-a7eb-410a-9734-925ea5d03807 main
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
21/05/18 21:20:39 INFO CliDriver: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> 


10、退出 Hive 
hive> quit; 
或者 
hive> exit; 

上面中第8步骤中的初始化数据库

[root@hadoop0 lib]# schematool  -dbType  mysql  -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/software/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/software/hive2/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
21/05/18 21:16:45 INFO conf.HiveConf: Found configuration file file:/software/hive2/conf/hive-site.xml
Metastore connection URL:	 jdbc:mysql://localhost:3306/hivedb2?createDatabaseIfNotExist=true
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 root
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed

在这里插入图片描述

2.4 MySQL5.7安装

MySQL下载地址: https://downloads.mysql.com/archives/community/

在这里插入图片描述

1、上传解压

在这里插入图片描述

在这里插入图片描述

2、删除原来Centos7上面已有的MySQL相关内容

[root@hadoop10 software]# rpm -qa|grep mysql
[root@hadoop10 software]# rpm -qa|grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@hadoop10 software]# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
[root@hadoop10 software]# rpm -qa|grep mariadb
[root@hadoop10 software]# 

在这里插入图片描述

3、安装MySQL相关服务

rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm

注意安装的时候按照顺序安装。

在这里插入图片描述

4、初始化数据库,然后生成对应的临时密码

在这里插入图片描述

[root@hadoop10 mysql]# cat /var/log/mysqld.log
[root@hadoop10 mysql]# pwd
/software/mysql
[root@hadoop10 mysql]# mysqld --initialize --user=mysql
[root@hadoop10 mysql]# cat /var/log/mysqld.log
2021-09-18T09:35:50.147120Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-09-18T09:35:51.244724Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-09-18T09:35:51.366111Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-09-18T09:35:51.445145Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d023611d-1863-11ec-99e0-000c29c415d7.
2021-09-18T09:35:51.446228Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-09-18T09:35:52.168727Z 0 [Warning] CA certificate ca.pem is self signed.
2021-09-18T09:35:52.324359Z 1 [Note] A temporary password is generated for root@localhost: Uc5&LIwp6OU/

5、找到对应的临时密码

在这里插入图片描述

[root@hadoop10 mysql]# cat /var/log/mysqld.log
2021-09-18T09:35:50.147120Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-09-18T09:35:51.244724Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-09-18T09:35:51.366111Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-09-18T09:35:51.445145Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d023611d-1863-11ec-99e0-000c29c415d7.
2021-09-18T09:35:51.446228Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-09-18T09:35:52.168727Z 0 [Warning] CA certificate ca.pem is self signed.
2021-09-18T09:35:52.324359Z 1 [Note] A temporary password is generated for root@localhost: Uc5&LIwp6OU/

6、启动MySQL服务

在这里插入图片描述

[root@hadoop10 mysql]# systemctl start mysqld.service
[root@hadoop10 mysql]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2021-09-18 17:39:00 CST; 26s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 13798 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 13767 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 13801 (mysqld)
    Tasks: 27
   CGroup: /system.slice/mysqld.service
           └─13801 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Sep 18 17:38:58 hadoop10 systemd[1]: Starting MySQL Server...
Sep 18 17:39:00 hadoop10 systemd[1]: Started MySQL Server.

7、使用临时密码登录MySQL

[root@hadoop10 mysql]# mysql -uroot -pF_xwRf7ejrUk
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.32

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

8、修改密码,并退出重新登录验证

[root@hadoop10 mysql]# mysql -uroot -pF_xwRf7ejrUk
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.32

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set PASSWORD=PASSWORD('111111'); 
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit;
Bye
[root@hadoop10 mysql]# mysql -uroot -p111111
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

在这里插入图片描述

9、修改远程访问权限

在这里插入图片描述

mysql> grant all privileges on *.* to 'root'@'%' identified by '111111' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

补充:重新生成初始化密码:

[root@hadoop10 lib]# cd mysql
[root@hadoop10 mysql]# ll
total 110660
-rw-r-----. 1 mysql mysql       56 Sep 18 17:35 auto.cnf
-rw-------. 1 mysql mysql     1676 Sep 18 17:35 ca-key.pem
-rw-r--r--. 1 mysql mysql     1112 Sep 18 17:35 ca.pem
-rw-r--r--. 1 mysql mysql     1112 Sep 18 17:35 client-cert.pem
-rw-------. 1 mysql mysql     1680 Sep 18 17:35 client-key.pem
-rw-r-----. 1 mysql mysql      301 Sep 18 17:45 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Sep 18 17:45 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Sep 18 17:45 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Sep 18 17:35 ib_logfile1
drwxr-x---. 2 mysql mysql     4096 Sep 18 17:35 mysql
drwxr-x---. 2 mysql mysql     8192 Sep 18 17:35 performance_schema
-rw-------. 1 mysql mysql     1680 Sep 18 17:35 private_key.pem
-rw-r--r--. 1 mysql mysql      452 Sep 18 17:35 public_key.pem
-rw-r--r--. 1 mysql mysql     1112 Sep 18 17:35 server-cert.pem
-rw-------. 1 mysql mysql     1676 Sep 18 17:35 server-key.pem
drwxr-x---. 2 mysql mysql     8192 Sep 18 17:35 sys
[root@hadoop10 mysql]# pwd
/var/lib/mysql
[root@hadoop10 mysql]# rm -rf *
[root@hadoop10 mysql]# pwd
/var/lib/mysql
[root@hadoop10 mysql]# ll
total 0
[root@hadoop10 mysql]# 
[root@hadoop10 mysql]# mysqld --initialize --user=mysql

在这里插入图片描述

2.5 Hive3安装

2.5.1 安装MySQL

见2.4MySQL5.7安装

2.5.2 上传解压重命名

[root@hadoop10 software]# tar -zxvf apache-hive-3.1.2-bin.tar.gz
[root@hadoop10 software]# mv apache-hive-3.1.2-bin hive

在这里插入图片描述

2.5.3 添加环境变量

export HIVE_HOME=/software/hive
export PATH=$PATH:$HIVE_HOME/bin

在这里插入图片描述

2.5.4 修改配置文件hive-site.xml

目录下面没有,直接vim就可以了。
[root@hadoop10 conf]# vim hive-site.xml

<configuration>
<property>
	<name>javax.jdo.option.ConnectionURL</name>
	<value>jdbc:mysql://localhost:3306/hivedb3?useSSL=false</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>111111</value>
</property>
<property>
	<name>hive.metastore.warehouse.dir</name>
	<value>/user/hive/warehouse</value>
</property> 
</configuration>

在这里插入图片描述

2.5.5 给MySQL的jar包放到hive的lib下面

一定要记得加入 MySQL 驱动包(mysql-connector-java-5.1.40-bin.jar)
该 jar 包放置在 hive 的根路径下的 lib 目录

在下面的路径里面,根据个人的配置略有不同。

/software/hive/lib

在这里插入图片描述

2.5.6 初始化元数据库遇到的问题

[root@hadoop10 software]# schematool -dbType mysql -initSchema

可能遇到的问题:

[root@hadoop10 software]# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/software/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/software/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
	at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
	at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338)
	at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:536)
	at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:554)
	at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:448)
	at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5141)
	at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5104)
	at org.apache.hive.beeline.HiveSchemaTool.<init>(HiveSchemaTool.java:96)
	at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1473)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:236)

{% asset_img image-20210921181507537.png %}

这是由于hadoop的common中的lib里面的包和hive的lib里面的包冲突导致的。可以参考如下方法解决:

hadoop中的路径为:

[root@hadoop10 lib]# pwd
/software/hadoop/share/hadoop/common/lib

在这里插入图片描述

Hive中的路径:

[root@hadoop10 lib]# pwd
/software/hive/lib

在这里插入图片描述

保留一个就可以了。下面我们通过给hive的jar包注释掉的方式解决。

也就是给hive中的jar重命名让它不生效即可。

[root@hadoop10 lib]# mv log4j-slf4j-impl-2.10.0.jar log4j-slf4j-impl-2.10.0.jar.backup

上面是解决了jar日志的冲突而已。看接着报错如下,其实报错信息没有变,只是上面的解决方案帮日志jar的冲突打印给解决了 。 需要接着解决下面的问题,下面的问题是guava不一致引起的。

在这里插入图片描述

1、给Hive的下面的包删除了,或者重命名让失效

[root@hadoop10 lib]# mv guava-19.0.jar guava-19.0.jar.backup

2、给hadoop下面的包拷贝过来。

[root@hadoop10 lib]# pwd
/software/hadoop/share/hadoop/common/lib
[root@hadoop10 lib]# cp guava-27.0-jre.jar /software/hive/lib/

在这里插入图片描述

2.5.7 再次初始化元数据库

解决了上面的问题之后,再次启动,提示需要先在MySQL中创建数据库hivedb3。这个和hive1和hive2版本都不一样。

在hive1和hive2版本中不需要自己提前创建。在hive3版本中需要自己提前创建。

[root@hadoop10 ~]# schematool -dbType mysql -initSchema
Metastore connection URL:	 jdbc:mysql://localhost:3306/hivedb3?useSSL=false
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 root
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException : Unknown database 'hivedb3'
SQL Error code: 1049
Use --verbose for detailed stacktrace.
*** schemaTool failed ***

在这里插入图片描述

1、下面就先在MySQL中创建对应的元数据库

[root@hadoop10 ~]# mysql -uroot -p111111
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database hivedb3;
Query OK, 1 row affected (0.00 sec)

mysql> quit;
Bye
[root@hadoop10 ~]# 

2、再次初始化元数据库就成功了

[root@hadoop10 ~]# schematool -dbType mysql -initSchema
Metastore connection URL:	 jdbc:mysql://localhost:3306/hivedb3?useSSL=false
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 root
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.mysql.sql


(中间会有很多空白行,可以加上 -verbose 显示对应详细信息)

Initialization script completed
schemaTool completed
[root@hadoop10 ~]# 

在这里插入图片描述

在这里插入图片描述

2.5.8 启动hive客户端

注意先启动MySQL和Hadoop

[root@hadoop10 ~]# hive
which: no hbase in (.:.:.:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/software/jdk/bin:/software/zk/bin:/software/hadoop/bin:/software/hadoop/sbin:/software/hive/bin:/root/bin)
Hive Session ID = 68244266-325a-4600-8e91-d52d65f24629

Logging initialized using configuration in jar:file:/software/hive/lib/hive-common-3.1.2.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
Hive Session ID = 475cdcf6-2da2-48dd-8c13-1e4161527f92
hive> show databases;
OK
default
Time taken: 0.495 seconds, Fetched: 1 row(s)
hive> 

在这里插入图片描述

2.6 关于使用默认的derby数据库的补充说明

1、安装步骤

安装步骤是直接安装hive

上传、解压、重命名、添加环境变量

初始化元数据库

bin/schematool -dbType derby -initSchema

2、使用derby的问题

在针对于同一份数据打开两个及两个以上的客户端进行操作的时候,会报错如下

Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database ........

这是因为 Hive 默认使用的元数据库为 derby,开启 Hive 之后就会占用元数据库,且不与其他客户端共享数据。也就相当于是单用户单客户端操作。
所以在企业中需要将 Hive 的元数据地址改为 MySQL。

Derby数据库不做深究了,大家知道即可。



声明:
        文章中代码及相关语句为自己根据相应理解编写,文章中出现的相关图片为自己实践中的截图和相关技术对应的图片,若有相关异议,请联系删除。感谢。转载请注明出处,感谢。


By luoyepiaoxue2014

微博地址: http://weibo.com/luoyepiaoxue2014 点击打开链接

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/36267.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Windows下Labelimg标注自己的数据集使用(Ubuntu18.04)Jetson AGX Orin进行YOLO5训练测试完整版教程

一、环境配置介绍 整个实现过程所涉及的文件目录&#xff0c;其中&#xff0c;自备表示自己需要准备的&#xff0c;生成表示无需自己准备。 使用yolov5时出现“assertionerror:no labels found in */*/*/JPEGImages.cache can not train without labels”问题 很多朋友都会遇…

SpringBoot+Vue项目医疗管理系统

文末获取源码 开发语言&#xff1a;Java 使用框架&#xff1a;spring boot 前端技术&#xff1a;JavaScript、Vue.js 、css3 开发工具&#xff1a;IDEA/MyEclipse/Eclipse、Visual Studio Code 数据库&#xff1a;MySQL 5.7/8.0 数据库管理工具&#xff1a;phpstudy/Navicat JD…

待办事项是什么意思,怎么用?

待办事项是什么意思&#xff0c;为什么要用&#xff1f;待办事项工具怎么设置&#xff1f;这里一文给你讲清&#xff01; 废话不多说&#xff0c;下面直接教你&#xff1a;梳理待办事项清单的方法&#xff0c;以及待办工具的操作实操步骤。想要快速提升工作效率的小伙伴&#…

第三十七篇 Vue中封装Swiper组件

在上一篇内容的结尾讲到了将swiper初始化从mounted生命周期转移到updated中来能够让swiper动起来&#xff0c;但同时是否会造其他的一个问题&#xff1f;什么问题呢&#xff1f;在每次data中的状态发什么改变&#xff0c;updated中的内容会又重新执行&#xff0c;这样会导致swi…

二维数组与二级指针是好朋友吗?

抛出问题 有一个二维数组&#xff0c;我想把它传给一个函数。于是我把函数接口定义出来了&#xff0c;如下&#xff1a; int array[2][3] {1,2,3,4,5,6}; void fun(int **array) {array[0][0] 5; } 当我试图直接把数组名传给函数时候&#xff0c;fun(array)编译会报错&…

C++ 中explicit的作用及用法

目录 Cexplicit&#xff08;官网的说法&#xff09; Cexplicit 清楚的说法&#xff08;建议英文不好的从这里开始食用哦&#xff09; Cexplicit使用的例子&#xff08;建议喜欢自己敲代码实验的从这里开始食用哦&#xff09; 总结 Cexplicit&#xff08;官网的说法&#xff…

神经网络和深度学习-梯度下降Gradient Descent(下)

梯度下降gradient descent 我们接着用数学公式来看一下梯度下降 首先是梯度 ∂cos⁡t∂ω\frac{\partial \cos t}{\partial \omega} ∂ω∂cost​ 然后我们对权重进行更新 ωω−α∂cos⁡t∂ω\omega\omega-\alpha \frac{\partial \cos t}{\partial \omega} ωω−α∂ω∂c…

python基础之容器类型公共方法

文章目录一、简介1.高级数据类型的公共方法&#xff1a;2.python的内置函数&#xff1a;3.python包含的内置函数&#xff1a;二、遍历字典的列表一、简介 1.高级数据类型的公共方法&#xff1a; 列表元组字典或者字符串都能够共同使用的方法&#xff1b; 2.python的内置函数…

【kafka】七、kafka数据可靠性保证

数据可靠性保证 为保证producer发送的数据&#xff0c;能可靠的发送到指定的topic&#xff0c;topic的每个partition收到producer发送的数据后&#xff0c;都需要向producer发送ack&#xff08;acknowledgement确认收到&#xff09;&#xff0c;如果producer收到ack&#xff0c…

基于AntBlazor的学生在线练习系统实现过程的简单总结

前言 疫情当前&#xff0c;作为一名教师&#xff0c;如何能让学生进行有效练习成了一个难题。如果使用 “问卷星”等线上调查问卷式的网站来做练习测试&#xff0c;是无法及时有效的进行&#xff0c;更谈不上对学生练习情况进行跟踪。鉴于以上现实情况和问题&#xff…

神经网络和深度学习-用pytorch实现线性回归

用pytorch实现线性回归 用pytorch的工具包来实现线性模型的训练过程 准备数据集 设计模型 构造损失函数和优化器&#xff08;使用pytorch API&#xff09; 训练过程&#xff1a;前馈、反馈、更新 准备数据 在PyTorch中&#xff0c;计算图是小批处理的&#xff0c;所以X和…

MATLAB | 世界杯来用MATLAB画个足球玩叭~

世界杯教你用MATLAB画个超逼真的足球&#xff0c; 需要准备Partial Differential Equation Toolbox工具箱&#xff0c;同时因为用到了polyshape类所以至少需要R2017b版本。 绘制讲解 数据来源及说明 我是真的不想写注释了太麻烦了&#xff0c;给大家讲一下我的思路希望能够看…

判断一个时间段是否经过了另一个时间段

场景&#xff1a; IOT设备存在离线与恢复时间记录&#xff0c;每一次离线和恢复记为一个周期即一条数据, 现在需要统计出在某个时段存在离线记录的数据,如果目前未恢复,没有恢复时间&#xff0c;恢复时间置为9999-01-01 00:00:00 原始数据如下(t_offline_record)&#xff1a;…

OPengl学习——初识opengl

文章目录1、网站罗列2、一些词语解析1.入门概念2.Opengl Vs DirectX3、QOpenGLWidget4、引用**OpenGL&#xff08;Open Graphics Library&#xff09;*是一个跨编程语言、跨平台的编程图形程序接口&#xff0c;它将计算机的资源抽象称为一个个OpenGL的对象&#xff0c;对这些资…

3.5、点对点协议 PPP

3.5、点对点协议 PPP 3.5.1、基本介绍 点对点协议 PPP(Point-to-Point Protocol) 是目前使用最广泛的点对点数据链路层协议。 用户计算机只有获取到 ISP 所分配的合法 IP 地址后&#xff0c;才能成为因特网上的主机 用户计算机与 ISP 进行通信时&#xff0c;所使用的数据链路…

【学习笔记21】JavaScript数组的基本方法

笔记首发 一、push&#xff1a;末位新增 语法: 数组.push(数据)作用: 向数组末尾添加数据返回值: 追加数据后, 数组最新的长度 var arr [10, 20, 30, 40];console.log(原始数组: , arr); ​var num arr.push(500);console.log(push新增后数组: , arr);console.log(push的返回…

进程的初识

目录预备知识 -> 操作系统操作系统的定义操作系统的定位进程进程的概念进程调度的过程进程的管理描述组织PCB描述进程的特征进程调度的相关属性进程的状态优先级上下文记账信息预备知识 -> 操作系统 操作系统的定义 操作系统是一个搞管理的软件 对上&#xff0c;要对硬…

为什么一定要申请专利呢

问题一&#xff1a;如何避免被判为非正常专利&#xff1f; 原本有个发明创造&#xff0c;想申请专利&#xff0c;却被列入非正常申请&#xff0c;甚至违法。以下五种情况一定要注意&#xff0c;千万不能碰。 1、同一单位或个人申请多件明显抄袭现有技术的专利&#xff1b; 2…

如何通过 Java 合并和取消合并 Excel 单元格

在整理 Excel 中的数据时&#xff0c;我们不可避免地需要合并和取消合并单元格。同时&#xff0c;如果需要创建跨列或行的标题&#xff0c;我们可以合并 Excel 单元格以在电子表格中轻松完成此操作。 合并单元格是指将两个或多个单元格合并为一个单元格&#xff0c;而取消合并单…

4.4——数据库和前后端身份认证

目录数据库与身份认证数据库的基本概念什么是数据库常见的数据库及分类传统型数据库的数据组织结构安装并配置 MySQL使用 MySQL Workbench 管理数据库连接数据库了解主界面的组成部分创建数据库创建数据表向表中写入数据使用 SQL 管理数据库在项目中操作 MySQL安装与配置 mysql…