hive安装文档 hive安装文档
安装java,hadoop,zookeeper(其实hive不依赖zookeeper),启动hadoop、zookeeper,看到了654进程。
解压安装包
1 tar -zxvf /opt/software/apache-hive-3. 1. 2-bin. tar. gz -C /opt/module/
更改目录,使文件目录名变小,以利于配置
1 2 cd /opt/module/mv apache-hive-3.1.2-bin/ hive
查看 hive-default.xml.template,将前两句话复制到新建的文件hive-default.xml中,并保存
1 2 cd /opt/module/hive/conf/vi hive-default.xml.template
复制:
1 2 <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml-stylesheet type="text/xsl" href="configuration.xsl" ?>
(可以在自己的工程中新建一个html文件临时粘贴一下)
复制
1 2 <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml-stylesheet type="text/xsl" href="configuration.xsl" ?>
并保存
在hive-site.xml中插入下面的内容:
在插入时,可以打开hive-default.xml.template,通过?查找几个关键词的方式来复制粘贴,更改参数。关键词有:ConnectionURL、ConnectionUserName、ConnectionDriverName、ConnectionPassword
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <configuration > <property > <name > javax.jdo.option.ConnectionURL</name > <value > jdbc:mysql://master:3306/hive?useSSL=false& createDatabaseIfNotExist=true</value > </property > <property > <name > javax.jdo.option.ConnectionUserName</name > <value > root</value > </property > <property > <name > javax.jdo.option.ConnectionDriverName</name > <value > com.mysql.jdbc.Driver</value > </property > <property > <name > javax.jdo.option.ConnectionPassword</name > <value > Passwd123!</value > </property > </configuration >
将mysql的连接jar包mysql-connector-java-5. 1. 38-bin. jar,放到hive的lib目录下面
1 cp /opt/software/mysql-connector-java-5.1.38-bin.jar /opt/module/hive/lib/
设置环境变量
添加:
1 2 export HIVE_HOME=/opt/module/hiveexport PATH=$PATH :$HIVE_HOME /bin
初始化元数据库
1 schematool -initSchema -dbType mysql
debug
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hive/lib/log4j-slf4j-impl-2. 10. 0. jar!/org/slf4j/impl/StaticLoggerBinder. class] SLF4J: Found binding in [jar:file:/opt/module/hadoop/share/hadoop/common/lib/slf4j-log4j12-1. 7. 25. jar!/org/slf4j/impl/StaticLoggerBinder. class] SLF4J: See http://www. slf4j. org/codes. html 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:518)
报错,原因是某个jar包冲突(guava-19.0.jar),解决方案是删除这个jar包
将/hive/lib的guava-19.0.jar删除,将hadoop/share/hadoop/common/lib下面的guava-27.0.jar拷过来
1 2 3 cd /opt/module/hive/librm -rf guava-19.0.jarcp /opt/module/hadoop/share/hadoop/common/lib/guava-27.0-jre.jar ./
(在课堂配置时,发现了以下的错误,经观察,报的信息User根本就没有root,而是APP,原来是hive-site.xml文件名弄错了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [root@master conf] SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hive/lib/log4j-slf4j-impl-2. 10. 0. jar!/org/slf4j/impl/StaticLoggerBinder. class] SLF4J: Found binding in [jar:file:/opt/module/hadoop/share/hadoop/common/lib/slf4j-log4j12-1. 7. 25. jar!/org/slf4j/impl/StaticLoggerBinder. class] SLF4J: See http://www. slf4j. org/codes. html SLF4J: Actual binding is of type [org. apache. logging. slf4j. Log4jLoggerFactory] Metastore connection URL: jdbc:derby:;databaseName=metastore_db;create=true Metastore Connection Driver : org. apache. derby. jdbc. EmbeddedDriver Metastore connection User: APP Starting metastore schema initialization to 3. 1. 0 Initialization script hive-schema-3. 1. 0. mysql. sql Error: Syntax error: Encountered "<EOF>" at line 1, column 64. (state=42X01,code=30000) org. apache. hadoop. hive. metastore. HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !! Underlying cause: java. io. IOException : Schema script failed, errorcode 2 Use --verbose for detailed stacktrace. *** schemaTool failed ***)
最后初始化成功。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [root@master conf] SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder. class] SLF4J: Found binding in [jar:file:/opt/module/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder. class] SLF4J: See http://www.slf4j.org/codes.html SLF4J: Actual binding is of type [org. apache. logging. slf4j. Log4jLoggerFactory] Metastore connection URL: jdbc:mysql://master:3306/hive?useSSL=false &createDatabaseIfNotExist=true 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
进入hive进行测试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 [root@master conf] which : no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/module/jdk/bin:/opt/module/hadoop/bin:/opt/module/hadoop/sbin:/opt/module/zookeeper/bin:/opt/module/kafka/bin:/root/bin:/opt/module/jdk/bin:/opt/module/hadoop/bin:/opt/module/hadoop/sbin:/opt/module/zookeeper/bin:/opt/module/kafka/bin:/opt/module/hive/bin)SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/module/hadoop/share/hadoop/common/lib/slf4j-log4j12-1. 7. 25. jar!/org/slf4j/impl/StaticLoggerBinder. class] SLF4J: See http://www. slf4j. org/codes. html SLF4J: Actual binding is of type [org. apache. logging. slf4j. Log4jLoggerFactory] Hive Session ID = 927802b0-8222-40e1-9c37-f933c74359de Logging initialized using configuration in jar:file:/opt/module/hive/lib/hive-common-3. 1. 2. jar!/hive-log4j2. properties Async: true Hive Session ID = c3a2cf3b-7332-47bf-86c5-84f0159d3c83 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> hive> show databases; OK default Time taken: 0. 321 seconds, Fetched: 1 row(s) hive> show tables; OK Time taken: 0. 027 seconds