首页 > 解决方案 > hiveserver2 在启动时挂起。10000 端口没有监听

问题描述

我一直在尝试设置 Apache 套件的本地单个大数据节点。我成功设置了 hadoop,hdfs 和 yarn 工作正常。但是,在过去的几个小时里,我一直试图让 Hive 启动并运行,但没有成功。当我说“hive --services hiveserver2”时,在打印出几行后它挂起。我检查了端口 10000 上是否有任何东西在监听,但没有。下面是命令“hive --services hiveserver2”的输出

2019-07-27 17:55:54: Starting HiveServer2
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/particle/apache-hive-2.3.5-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/particle/hadoop-2.9.2/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]

由于 hive-site.xml 很大,我无法在此处粘贴,但如果您怀疑有任何属性,请告诉我,我会将其粘贴在这里。我已经从 tarball 而不是 maven 安装了 Hive。

我想这一切都与这里提到的某种 SLF4J 绑定冲突有关,但我不知道处理它所需的步骤。帮助将不胜感激。

标签: servicehivehadoop2

解决方案


我多次尝试让 Hive 通过 tar-ball 和 Maven 安装工作。无论如何,它没有发生。

这是我如何让蜂巢开始工作的。(2019 年 8 月 3 日)。

首先,我下载了最新的 Hive .tar.gz 文件(截至今天为 3.1.1)。下载后,我确保在 ~/.bashrc 文件中设置了以下内容。请注意,Java 版本是 1.8,Hadoop 版本是 2.9.2。不确定这些版本是否重要,但这些设置对我有用。

export JAVA_HOME=/home/particle/jdk1.8.0_221
export PATH=$JAVA_HOME/bin:$PATH
export HADOOP_HOME=/home/particle/hadoop-2.9.2
export PATH=$HADOOP_HOME/bin:$PATH
export HIVE_HOME=/home/particle/apache-hive-3.1.1-bin
export PATH=$HIVE_HOME/bin:$PATH

之后,我获取了 ~/.bashrc 文件(如下所示)。

source ~/.bashrc

在继续之前,我确保 DFS 和 YARN 并运行。如果没有,请从 $HADOOP_HOME/sbin/start-dfs.sh 和 $HADOOP_HOME/sbin/start-yarn.sh 开始。用 jps 确认 Namenode、SecondaryNameNode、DataNode、ResourceManager 和 NodeManager 正在运行。

然后我创建了几个目录并设置了所有权。有些目录可能已经为您存在,所以不用担心。

hadoop fs -mkdir       /tmp
hadoop fs -mkdir       /user
hadoop fs -mkdir       /user/hive/
hadoop fs -mkdir       /user/hive/warehouse
hadoop fs -chmod g+w   /tmp
hadoop fs -chmod g+w   /user/hive/warehouse

之后,我通过键入以下内容初始化了 derby db。不确定这是否有必要,但还是做了。

$HIVE_HOME/bin/schematool -dbType derby -initSchema

之后,我创建了一个名为“hive-site.xml”的文件并放在 $HIVE_HOME/conf 中。该文件具有以下内容。确保您进行了适当的更改。下面我们要做的是设置使用 MySQL 作为 HIVE 的数据库的东西。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<configuration>
<property>
  <name>hadoop.proxyuser.TypeYourUserNameHereForTheOSOrVirtualOS.groups</name>
  <value>*</value>
</property>
<property>
  <name>hadoop.proxyuser.TypeYourUserNameHereForTheOSOrVirtualOS.hosts</name>
  <value>*</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://localhost/metastore?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>TypeYourUserNameHereForTheOSOrVirtulOS_YouWillShortlyCreateThisUserInMySQL</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>TypeYourPassword_YouWillShortlyCreateThisPassWordInMySQL</value>
</property>

<property>
  <name>datanucleus.autoCreateSchema</name>
  <value>true</value>
</property>

<property>
  <name>datanucleus.fixedDatastore</name>
  <value>true</value>
</property>

<property>
 <name>datanucleus.autoCreateTables</name>
 <value>True</value>
 </property>
</configuration>

之后我安装了 MySQL 客户端和服务器。因为我使用的是 Ubuntu,所以我的命令很简单,如下所示。此步骤将根据您的操作系统而改变。

sudo apt-get install mysql-client mysql-server

之后,我下载了使 HIVE 工作所需的驱动程序。我使用了这个链接(https://dev.mysql.com/downloads/connector/j/5.1.html),但这可能会因您使用的 MySQL 版本而异。解压缩/解压缩后,您将在解压缩/解压缩文件夹中看到两个(或更多).jar 文件。我在 $HIVE_HOME/lib 中复制了它们中的两个(或全部)(.jar 文件)。

之后我登录了mysql。由于我在安装时没有设置现有密码,因此我不得不使用以下命令。如果您已经有 root/admin 登录名和密码,那么您可以跳过前三行。请确保您已首先更改为以下目录“$HIVE_HOME/scripts/metastore/upgrade/mysql/”。

sudo mysql -u root
# It will first ask the super password associated with sudo
# Then it will either take you straight to the mysql prompt or it will ask for a password.
USE mysql;
CREATE USER 'YourUserNameThatYouSavedIn_hive-site.xml'@'localhost' IDENTIFIED BY 'YourPasswordThatYouSavedIn_hive-site.xml';
GRANT ALL PRIVILEGES ON *.* TO 'YourUserNameThatYouSavedIn_hive-site.xml'@'localhost';
FLUSH PRIVILEGES;
EXIT;

现在我有了一个与我在 hive-site.xml 中的设置相匹配的 MySQL 帐户。我使用上面创建的用户名和密码登录到 MySQL 并键入以下命令,一次一个。

进入 mysql shell 后,一次输入以下几行。

DROP DATABASE IF EXISTS hive;
CREATE DATABASE hive;
USE hive;
SOURCE hive-schema-3.1.0.mysql.sql;
EXIT;

然后我在 bash shell 中输入了以下命令。很多警告来了。

$HIVE_HOME/bin/schematool -dbType mysql --initSchema

然后我终于去了魔法指挥部。

$HIVE_HOME/bin/beeline -u jdbc:hive2://

在多次警告之后,它把我带到了我等待的命令提示符。下面是结果。仍然有很多警告,但我会暂时接受它。过去三天我一直在追求这个。

最终输出


推荐阅读