随着这些年大数据技术的普及,Hadoop生态中的组件越来越丰富,包括Hbase、Hive、Ranger和Kafka等等,随着组件的增多,集群动辄上百台机器安装、配置、运维的成本也越来越高,对运营用具提出了更高的要求。这时就出现了集群管理平台化的应用,比如大家用的比较多的CDH和HDP。因此,大多数公司都对选用开源的管理工具来管理Hadoop集群,通常情况下组件的基本信息,比如数据库链接、用户名、密码等都已经在集群安装时设置完成,后续关于组件的变更也是通过页面来完成的。本文主要是针对手工安装配置大数据环境的情况下,对Hive相关配置的说明。
Hive Site配置文件
添加hive-site.xml,进入hive conf目录
cd /opt/hive/conf
vi hive-site.xml
将下面内容粘贴到hive-site文件,并的MySQL地址、用户名和密码
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://10.91.85.11:3306/hive1?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>root</value>
</property>
<!-- 以下的配置是针对TEZ引擎的,默认MR不需要配置 -->
<property>
<name>hive.execution.engine</name>
<value>tez</value>
</property>
</configuration>
重启hive,进入hive-cli,运行SQL时可能会遇到虚拟内容的问题。
Container [pid=1006,containerID=container_1609911816050_0001_02_000001] is running beyond virtual memory limits. Current usage: 384.8 MB of 1 GB physical memory used; 2.5 GB of 2.1 GB virtual memory used. Killing container.
遇到上述问题时,可以看到虚拟内存用的过大了,可以通过以下几种方式进行修改
- 增加物理内存大小
- 修改物理内存与虚拟内存比例
- 关闭虚拟内存检查
通常开发环境用第三种方式,修改yarn-site.xml并重启集群。
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
为hive配置tez引擎
Tez是支持DAG的开元引擎,它能将多个有依赖的作业合并成一个作业从而大幅提升DAG作业的性能。Tez引擎不直接面向用户,它给予开发者更多的能力去完成性能更高、扩展性更好的应用程序。安装Tez引擎需要下面几个步骤
- 从tez官网下载tez包
tar xzvf apache-tez-0.9.2-bin.tar.gz
- 上传jar包,创建tez-site配置文件
hdfs dfs -mkdir -p /apps/tez
hdfs dfs -put apache-tez-0.9.2-bin/share/tez.tar.gz /apps/tez/
vi /opt/hadoop/etc/hadoop/tez-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed 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. See accompanying LICENSE file.
-->
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>tez.lib.uris</name>
<value>${fs.defaultFS}/apps/tez/tez.tar.gz</value>
</property>
<property>
<name>tez.use.cluster.hadoop-libs</name>
<value>true</value>
</property>
</configuration>
- 添加tez jars到 hadoop classpath中
vi /opt/hadoop/etc/hadoop/hadoop-env.sh
export TEZ_JARS=/opt/apache-tez-0.9.2-bin
export HADOOP_CLASSPATH=${TEZ_JARS}/*:${TEZ_JARS}/lib/*:${HADOOP_CLASSPATH}
- Tez Jetty 与Hadoop 冲突,导致hiveserver2启动失败,删除Tez Jetty相关的包就可以启动
rm jetty-server-9.3.24*.jar
- 重新启动Hadoop集群
4463

被折叠的 条评论
为什么被折叠?



