Hive环境搭建及简单使用

发布时间:2020-07-19 20:36:14 作者:wangkunj
来源:网络 阅读:1082

前言:

1.下载安装包并解压
# 下载地址http://archive.cloudera.com/cdh6/cdh/5/ 选择hive-1.1.0-cdh6.7.0.tar.gz包,也可用我们上篇文章编译来的包
[hadoop@hadoop000 ~]$ ll
total 32
drwxrwxr-x 4 hadoop hadoop 4096 Jun  1 21:27 app          --软件安装路径
drwx------ 3 hadoop hadoop 4096 Jun  1 21:46 data
drwxrwxr-x 2 hadoop hadoop 4096 May 31 19:41 lib
drwxrwxr-x 2 hadoop hadoop 4096 May 31 19:41 maven_repo
drwxrwxr-x 2 hadoop hadoop 4096 Jun  1 21:46 pids
drwxrwxr-x 2 hadoop hadoop 4096 May 31 19:42 shell
drwxrwxr-x 2 hadoop hadoop 4096 May 31 19:48 software     --安装包路径
drwxrwxr-x 3 hadoop hadoop 4096 May 31 20:59 source       --源码包路径
[hadoop@hadoop000 ~]$ cd software/
[hadoop@hadoop000 software]$ pwd
/home/hadoop/software
[hadoop@hadoop000 software]$ wget http://archive.cloudera.com/cdh6/cdh/5/hive-1.1.0-cdh6.7.0.tar.gz
[hadoop@hadoop000 software]$ tar -xzvf hive-1.1.0-cdh6.7.0.tar.gz -C /home/hadoop/app/
2.配置环境变量
[hadoop@oradb3 ~]$ vi .bash_profile
# 添加下面内容:
export HIVE_HOME=/home/hadoop/app/hive-1.1.0-cdh6.7.0
export PATH=$HIVE_HOME/bin:$PATH
[hadoop@oradb3 ~]$ source .bash_profile
# 或添加到全局环境变量/etc/profile也可以
3.配置文件修改
[hadoop@hadoop000 conf]$ pwd
/home/hadoop/app/hive-1.1.0-cdh6.7.0/conf
[hadoop@hadoop000 conf]$ cp hive-env.sh.template  hive-env.sh
[hadoop@hadoop000 conf]$ vi hive-env.sh
# 更改HADOOP_HOME
HADOOP_HOME=/home/hadoop/app/hadoop-2.6.0-cdh6.7.0
[hadoop@hadoop000 conf]$ vi hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
        <property>
                <name>javax.jdo.option.ConnectionURL</name>
                <value>jdbc:mysql://localhost:3306/ruozedata_basic03?createDatabaseIfNotExist=true</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionDriverName</name>
                <value>com.mysql.jdbc.Driver</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionUserName</name>
                <value>root</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionPassword</name>
                <value>123456</value>
        </property>
</configuration>
4.在lib下添加MySQL驱动包
# 需要自行下载 下载地址https://dev.mysql.com/downloads/connector/j/
[hadoop@oradb3 lib]$ pwd
/home/hadoop/app/hive-1.1.0-cdh6.7.0/lib
[hadoop@oradb3 lib]$ ll mysql-connector-java-5.1.13-bin.jar
-rw-r--r-- 1 hadoop hadoop 767492 Jun  1 22:01 mysql-connector-java-5.1.13-bin.jar
5.创建表进行测试
[hadoop@oradb3 ~]$ hive
which: no hbase in (/home/hadoop/app/hive-1.1.0-cdh6.7.0/bin:/home/hadoop/app/hadoop-2.6.0-cdh6.7.0/bin:/usr/java/jdk1.7/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin)

Logging initialized using configuration in jar:file:/home/hadoop/app/hive-1.1.0-cdh6.7.0/lib/hive-common-1.1.0-cdh6.7.0.jar!/hive-log4j.properties
hive> create database ruoze;
OK
Time taken: 1.35 seconds
hive> use ruoze;
OK
Time taken: 0.05 seconds
hive> create table test (id int);
OK
Time taken: 0.65 seconds
hive> show tables;
OK
test
Time taken: 0.239 seconds, Fetched: 1 row(s)

# 详细操作可参考:https://blog.csdn.net/scgaliguodong123_/article/details/46868525 
推荐阅读:
  1. netstat简单使用
  2. ansible简单使用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

hive

上一篇:PHP函数介绍

下一篇:网络安全学习站和漏洞平台搜集

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》