您的位置:首页 > 其它

Hive 的安装部署和测试

2016-03-02 12:20 246 查看

Hive的安装

Hive安装需求



根据hive安装的需求:

hive1.2需求1.7+的jdk版本

hive0.14-1.1 需求1.6+的jdk版本

(preferred)hadoop2.0+的版本

Hive安装环境准备

jdk 1.7+版本

准备hive安装包(可以去官网下载)

hadoop2.5版本

hive各版本下载地址



Hive的安装步骤

解压hive的文件安装包到指定文件夹

tar zxf apache-hive-0.13.1-bin.tar.gz -C opt/modules/



修改Hive配置文件

重命名hive-env.sh.template文件为hive-env.sh

修改文件内容

1> HADOOP_HOME=/opt/modules/hadoop-2.5.0 ##配置hadoop程序地址

2>export HIVE_CONF_DIR=/opt/modules/hive-0.13.1/conf ##hive程序conf的路径



创建数据的存储地址



根据官方网站介绍

在hdfs上创建指定的文件夹存放数据

进入hadoop目录

1>bin/hdfs dfs -mkdir /tmp

2>bin/hdfs dfs -mkdir /user/hive/warehouse

给定组读写的权限

3>bin/hdfs dfs -chmod g+w /tmp

4>bin/hdfs dfs -chmod g+w /user/hive/warehouse






启动hive程序

查看hive目录结构并进入



启动hive:
bin/hive




简单操作hive,查看当前 库,表并创建测试表



MySql的安装

Hive本身自带一个数据库,但是有弊端,hive本身数据库,每次只允许一个用户登录

安装需求,

1. 机器联网,
2. 检测mysql的下载地址


MySql安装步骤

检测本机mysql

yum list installed mysql*
rpm -qa | grep mysql*


查看是否有mysql安装包

yum list mysql


安装mysql客户端:

yum install mysql


安装mysql 服务器端:

yum install mysql-server
yum install mysql-devel




[root@bigdata00 /]# service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h bigdata00.hadoop-hao.com password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

[  OK  ]
Starting mysqld:                                           [  OK  ]


注意启动提示信息

修改MySql用户信息

修改root用户登录密码
/usr/bin/mysqladmin -u root password '123456'
修改本机登录的密码
/usr/bin/mysqladmin -u root -h bigdata00.hadoop-hao.com password '123456'


登录mysql

登录mysql

mysql -uroot  -p




使用以下sql修改用户信息





设置mysql关联hive

修改配置文件



根据官方网站可以查看需要设置的基本属性

### 创建hive.site.xml文件

在hive/conf/目录下创建hive.site.xml文件



加载mysql驱动文件

将驱动文件解压到相关目录

tar -zxf mysql-connector-java-5.1.27.tar.gz  -C /opt/modules/


进入mysql驱动文件,复制驱动文件到hive



cp -r mysql-connector-java-5.1.27-bin.jar     cd /opt/modules/hive-0.13.1/lib/


重新启动Hive

bin/hive


启动前:



启动后



通过mysql可以看到mysql自动创建了一个库

测试

创建数据库

create database db_hive_test;




创建测试表

create table student(id int,name string) row format delimited fields terminated by '\t';




加载数据到表中

load data local inpath ‘/opt/datafiles/student.txt’ into table default.student`



查询表信息

select * from student;


查看表的详细信息

desc formatted student;




通过ui页面查看创建的数据位置



通过Mysql查看创建的表



查看hive的函数

show functions;




查看函数详细信息

desc function sum;

desc function  extended


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: