hive官网中mysql配置文件位置,Hive配置

Hive配置

(只需要主机上配置)

MySQL数据库安装

元数据迁移到mysql

主机上先安装mysql,用于存放hadoop元数据

Mysql驱动

下载一个数据包mysql-connector-java-5.1.18-bin.jar,放到hive的lib目录下,

创建mysql用户并赋权

创建hive数据库

mysql>create database hive;

mysql>show databases;

+--------------------+

|Database           |

+--------------------+

|information_schema |

|hive               |

|mysql              |

|test               |

+--------------------+

创建hadoop用户并设置密码

mysql>insert into mysql.user(Host,User,Password)values("hadoop1","hadoop",password("hadoop"));

mysql>flush privileges;

[hadoop@hadoop1 ~]$ mysql -u hadoop -phadoop-h hadoop1

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 63

Server version: 5.1.71 Source distribution

Copyright (c) 2000, 2013, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

mysql>

对hadoop用户赋权

mysql>grant all privileges on hive.* to hadoop@hadoop1identified by ‘hadoop’;

mysql>flush privileges;

hive配置

软件包下载

从官网上下载hive软件包,上传到服务器后,使用以下命令进行解压:

[hadoop@hadoop1 soft]$ tar -zxvfapache-hive-0.13.1-bin.tar.gz

为了配置方便,可以对解压后的目录进行修改名称:

[hadoop@hadoop1 ~]$ mvapache-hive-0.13.1-bin hive2/

配置系统用户环境变量

[hadoop@hadoop1 ~]$ cat .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

.~/.bashrc

fi

# User specific environment and startupprograms

PATH=$PATH:$HOME/bin

export PATH

export JAVA_HOME=/usr/lib/jvm/java-1.7.0/

export HADOOP_HOME=/home/hadoop/hadoop2

export HIVE_HOME=/home/hadoop/hive2

export HIVE_CONF=/home/hadoop/hive2/conf

exportHIVE_CLASSPATH=$HIVE_HOME/lib:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

exportPATH=$PATH:$JAVA_HOME/bin/:$HADOOP_HOME/bin:$HIVE_HOME/bin

修改hive数据库连接

在hive的conf目录下创建文件hive-site.xml配置文件(数据库连接等信息自定义):

配置hive-site.xml 文件

hive.metastore.warehouse.dir

/hive2/warehouse

hive.querylog.location

/home/hadoop/hive2/log

hive.metastore.local

true

javax.jdo.option.ConnectionURL

jdbc:mysql://hadoop1:3306/hive

javax.jdo.option.ConnectionDriverName

com.mysql.jdbc.Driver

javax.jdo.option.ConnectionUserName

hadoop

javax.jdo.option.ConnectionPassword

hadoop

配置hive-env.sh文件

exportHIVE_CONF_DIR=/home/hadoop/hive2/conf

# Folder containing extra ibraries requiredfor hive compilation/execution can be controlled by:

# export HIVE_AUX_JARS_PATH=

exportHIVE_AUX_JARS_PATH=/home/hadoop/hive2/lib

Hive启动运行

Cd/app/hive

./hive

查看数据表:

Showtables;

Ok,配置完成!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值