---
title: "hive配置"
author: "samwalt"
date: "2013-06-18T11:56:59Z"
tags: []
categories: ["开源软件"]
slug: "hive"
draft: false
lastmod: "2013-07-31T13:52:34Z"
id: 1888627
url: "https://samwalt.iteye.com/blog/1888627"
---

hive本身的配置还是很简单的，关键在于需要一些前提条件。 1）hadoop必须配置成伪分布模式或者集群模式 2）必须启动hadoop hive的数据仓库路径不是本机文件系统路径，而是hdfs的路径 \[code="xml"] hive.metastore.warehouse.dir /home/hadoop/hive/warehouse location of default database for the warehouse \[/code] 创建表 \[code="sql"]create table visit\_record(code string, created\_at string, phone string, ip string) row format delimited fields terminated by ' ';\[/code] 向hive数据仓库中加载数据 \[code="java"]load data local inpath '/home/hadoop/hive.txt' into table visit\_record;\[/code] 这里的inpath是本机文件系统路径 采用mysql存储metadata hive-site.xml文件添加如下配置： \[code="xml"] hive.metastore.local true javax.jdo.option.ConnectionURL jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver javax.jdo.option.ConnectionUserName 这里是mysql的用户名 javax.jdo.option.ConnectionPassword 这里是mysql的密码 \[/code] 把mysql的java版本的jdbc驱动复制到hive的Lib目录下，启动hive。 当输入show tables;没有报错时，配置成功。登录到mysql查看是否创建了 名为hive的数据库。