单节点hadoop安装hive
时间: 2023-11-03 07:58:14 浏览: 105
hadoop下hive的安装
安装Hive之前,需要先安装Hadoop。以下是单节点Hadoop和Hive的安装步骤:
1. 下载Hadoop并解压缩到一个目录中:
```
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-3.3.0/hadoop-3.3.0.tar.gz
tar -xzvf hadoop-3.3.0.tar.gz
```
2. 修改Hadoop配置文件(conf/hadoop-env.sh),添加JAVA_HOME环境变量:
```
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
```
3. 修改Hadoop配置文件(conf/core-site.xml),添加以下内容:
```
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
```
4. 修改Hadoop配置文件(conf/hdfs-site.xml),添加以下内容:
```
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
```
5. 格式化Hadoop文件系统:
```
bin/hdfs namenode -format
```
6. 启动Hadoop:
```
sbin/start-all.sh
```
7. 下载Hive并解压缩到一个目录中:
```
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz
tar -xzvf apache-hive-3.1.2-bin.tar.gz
```
8. 修改Hive配置文件(conf/hive-env.sh),添加以下内容:
```
export HADOOP_HOME=/path/to/hadoop-3.3.0
export HIVE_CONF_DIR=/path/to/apache-hive-3.1.2-bin/conf
```
9. 修改Hive配置文件(conf/hive-site.xml),添加以下内容:
```
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:/path/to/apache-hive-3.1.2-bin/metastore_db;create=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.server2.enable.doAs</name>
<value>false</value>
<description>Whether to impersonate the connected user to the metastore</description>
</property>
<property>
<name>hive.server2.authentication</name>
<value>NONE</value>
<description>Client authentication for HiveServer2</description>
</property>
<property>
<name>hive.server2.enable.doAs</name>
<value>false</value>
<description>Whether to impersonate the connected user to HiveServer2</description>
</property>
</configuration>
```
10. 创建Hive的元数据库:
```
bin/schematool -initSchema -dbType derby
```
11. 启动Hive Shell:
```
bin/hive
```
现在,您可以在Hive Shell中执行SQL查询了。
阅读全文