hive-1.1.0-cdh5.7.0 的编译安装并修改元数据存储数据库为MySQL

1 准备工作

1.1 配置jdk1.7

1.2 部署MySQL

1.3 安装maven

1.4编译安装 hadoop-2.6.0-cdh5.7.0.src.tar.gz

1.5创建hadoop用户

 安装的目录结构:/opt/software

参考该博客
下载地址(hive-1.1.0-cdh5.7.0 和 hadoop-2.6.0-cdh5.7.0.src.tar.gz )

2 下载hive-1.1.0-cdh5.7.0-src.tar.gz(版本号要对应)

下载:hive-1.1.0-cdh5.7.0-src.tar.gz
[hadoop@zydatahadoop001 software]$wget http://archive.cloudera.com/cdh5/cdh/5/hive-1.1.0-cdh5.7.0-src.tar.gz
  • 我在解压的时候出现了一个问题 :Exiting with failure status due to previous errors
    解决方法:切换至root用户进行解压或者赋予零食root权限即加上sudo。

3 编译,解压

[root@zydatahadoop001 hive-1.1.0-cdh5.7.0]# mvn clean package -DskipTests -Phadoop-2 -Pdist

编译之后,会在源码目录下面的packaging/target目录下面生成一个tar包,相关的hive模块jar包都能在这个tar包里面找到。
文件名称:apache-hive-1.1.0-cdh5.7.0-bin.tar.gz
把编译好的文件mv到software目录下
解压:
[root@zydatahadoop001 software]#tar -zxvf apache-hive-1.1.0-cdh5.7.0-bin.tar.gz

4 安装部署

4.1 修改用户和用户组

查看下载好的hive-1.1.0-cdh5.7.0
这里已经把编译好的mv到了software目录下
[root@zhangyu software]# ll
total 460064
drwxr-xr-x.  8 root   root        4096 Jan 14 05:22 apache-hive-1.1.0-cdh5.7.0-bin
-rw-r--r--.  1 root   root   105763125 Jan 14 02:57 apache-hive-1.1.0-cdh5.7.0-bin.tar.gz
drwxr-xr-x.  6 root   root        4096 Nov 10  2015 apache-maven-3.3.9
-rw-r--r--.  1 root   root     8617253 Jan 14  2018 apache-maven-3.3.9-bin.zip
lrwxrwxrwx.  1 hadoop hadoop        35 Jan 14 01:23 hadoop -> /opt/software/hadoop-2.6.0-cdh5.7.0
drwxr-xr-x. 15 hadoop hadoop      4096 Jan 14 01:50 hadoop-2.6.0-cdh5.7.0
-rw-r--r--.  1 root   root   311585484 Jan 13 23:29 hadoop-2.6.0-cdh5.7.0.tar.gz
drwxrwxr-x. 32 root   root        4096 Jan 14 02:46 hive-1.1.0-cdh5.7.0
-rw-r--r--.  1 root   root    14652104 Jan 13 21:46 hive-1.1.0-cdh5.7.0-src.tar.gz
-rw-r--r--.  1 root   root    29966286 Jan 14  2018 sqoop-1.4.6-cdh5.7.0.tar.gz

[root@zydatahadoop001 software]# chown -R hadoop:hadoop apache-hive-1.1.0-cdh5.7.0-bin

建立软连接兵修改用户和用户组:
[root@zydatahadoop001 software]# ln -s apache-hive-1.1.0-cdh5.7.0-bin hive
[root@zydatahadoop001 software]# chown -R hadoop:hadoop hive
[root@zydatahadoop001 software]# chown -R hadoop:hadoop hive/*
(这里没什么要进行两次chown呢? 对软连接使用chown和文件夹使用chown的区别,以前博客中有介绍。)

4.2 添加HIVE_HOME到系统环境变量

[root@zydatahadoop001 ~]# vi /etc/profile
添加下面内容:
export HIVE_HOME=/opt/software/hive

export PATH=$HIVE_HOME/bin:$PATH

4.3Hive配置修改(hive-env.sh)

[hadoop@zydatahadoop001 hive]$ cd conf/

修改hive-env.sh.template 为 hive-env.sh
[hadoop@zydatahadoop001 conf]$ cp hive-env.sh.template  hive-env.sh
[hadoop@zydatahadoop001 conf]$ vi hive-env.sh

在hive-env.sh添加一行
# Set HADOOP_HOME to point to a specific hadoop install directory
# HADOOP_HOME=${bin}/../../hadoop
添加该行:
HADOOP_HOME=/opt/software/hadoop

4.4 添加hive-site.xml mysql的连接文件(统一的元元数据管理)

创建文件夹hive-site.xml
[hadoop@zydatahadoop001 conf]$ vi hive-site.xml

添加下面的内容:



<configuration>
<property>
  <name>javax.jdo.option.ConnectionURLname>
    <value>jdbc:mysql://localhost:3306/basic01?createDatabaseIfNotExist=truevalue>  (自动创建basic01数据库)
    property>
    <property>
      <name>javax.jdo.option.ConnectionDriverNamename>
        <value>com.mysql.jdbc.Drivervalue>
        property>

<property>
  <name>javax.jdo.option.ConnectionUserNamename>
    <value>rootvalue>  (用户名)
    property>

<property>
  <name>javax.jdo.option.ConnectionPasswordname>
    <value>123456value>   (密码)
    property>
configuration>

4.5在lib下添加mysql驱动包

上传mysql驱动
[hadoop@zydatahadoop001 lib]$ rz

解压
[hadoop@zydatahadoop001 lib]$ unzip mysql-connector-java-5.1.45

将mysql-connector-java-5.1.45-bin.jar移动到lib目录下:
[hadoop@zydatahadoop001 lib]$ cp mysql-connector-java-5.1.45/mysql-connector-java-5.1.45-bin.jar .

5 创建表进行测试

启动hive:
[hadoop@zydatahadoop001 hive]$ hive
which: no hbase in (/usr/java/jdk1.8.0_45/bin:/opt/software/hive/bin:/opt/software/hadoop-cdh/sbin:/opt/software/hadoop-cdh/bin:/opt/software/findbugs-1.3.9/bin:/usr/local/protobuf/bin:/opt/software/apache-maven-3.3.9/bin:/usr/java/jdk1.8.0_45/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin)

Logging initialized using configuration in jar:file:/opt/software/hive-1.1.0-cdh5.7.0/lib/hive-common-1.1.0-cdh5.7.0.jar!/hive-log4j.properties

hive> show databases;
OK
default
Time taken: 1.548 seconds, Fetched: 1 row(s)
hive> use default;
OK
Time taken: 0.086 seconds

创建一张表:
hive> create table helloword (id int,name string ) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';

hive> show tables;
OK
helloword
Time taken: 0.145 seconds, Fetched: 1 row(s)

向表中添加数据
hive> load data local inpath '/home/hadoop/helloword.txt' into table helloword;
Loading data to table default.helloword
Table default.helloword stats: [numFiles=1, totalSize=27]
OK
Time taken: 9.705 seconds
hive> select * from helloword;
OK
1       zhangsan
2       lisi
3       wangwu
Time taken: 0.294 seconds, Fetched: 3 row(s)

你可能感兴趣的:(Hadoop,hive)