当前位置: 首页 > news >正文

hive的安装配置笔记

1.上传hive安装包

2.解压

3.配置Hive(在一台机器上即可)

    mv hive-env.sh.template hive-env.sh


4.运行hive
    发现内置默认的metastore存在问题(1.换执行路径后,原来的表不存在了。2.只能有一个用户访问同一个表)
    
5.配置mysql的metastore
        查询以前安装的mysql相关包

        rpm -qa | grep mysql

        暴力删除这个包

        rpm -e mysql-libs-5.1.66-2.el6_3.i686 --nodeps

        上传两个mysql的rpm包

        rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm rpm -ivh MySQL-client-5.1.73-1.glibc23.i386.rpm

         执行命令设置mysql

        /usr/bin/mysql_secure_installation

         授权:

        GRANT ALL PRIVILEGES ON hive.* TO 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;FLUSH PRIVILEGES

          在hive当中创建两张表

        create table trade_detail (id bigint, account string, income double, expenses double, time string) row format delimited fields terminated by '\t';create table user_info (id bigint, account string, name  string, age int) row format delimited fields terminated by '\t';

        将mysql当中的数据直接导入到hive当中

        sqoop import --connect jdbc:mysql://192.168.1.10:3306/itcast --username root --password 123 --table trade_detail --hive-import --hive-overwrite --hive-table trade_detail --fields-terminated-by '\t'sqoop import --connect jdbc:mysql://192.168.1.10:3306/itcast --username root --password 123 --table user_info --hive-import --hive-overwrite --hive-table user_info --fields-terminated-by '\t'

        创建一个result表保存前一个sql执行的结果

        create table result row format delimited fields terminated by '\t' as select t2.account, t2.name, t1.income, t1.expenses, t1.surplus from user_info t2 join (select account, sum(income) as income, sum(expenses) as expenses, sum(income-expenses) as surplus from trade_detail group by account) t1 on (t1.account = t2.account);
        create table user (id int, name string) row format delimited fields terminated by '\t'

        将本地文件系统上的数据导入到HIVE当中

        load data local inpath '/root/user.txt' into table user;

       创建外部表

        create external table stubak (id int, name string) row format delimited fields terminated by '\t' location '/stubak';

       
        创建分区表
        普通表和分区表区别:有大量数据增加的需要建分区表

        create table book (id bigint, name string) partitioned by (pubdate string) row format delimited fields terminated by '\t'; 

        分区表加载数据

        load data local inpath './book.txt' overwrite into table book partition (pubdate='2023-08-22');

http://www.lryc.cn/news/216103.html

相关文章:

  • lamba stream处理集合
  • 操作系统 day04(系统调用)
  • 【深度学习】pytorch——线性回归
  • golang工程——中间件redis,单节点集群部署
  • Lua基础
  • 微信小程序之开发工具介绍
  • 【AUTOSAR】【以太网】DoIp
  • 游戏中UI的性能优化手段
  • Idea快速生成测试类
  • Java文件操作详解
  • 二叉树系列主题Code
  • Leetcode 673. 最长递增子序列的个数 C++
  • html用css grid实现自适应四宫格放视频
  • 【机器学习可解释性】5.SHAP值的高级使用
  • CentOS开机自动运行jar程序实现
  • matlab双目标定中基线物理长度获取
  • 自己动手实现一个深度学习算法——二、神经网络的实现
  • gRPC源码剖析-Builder模式
  • ARM传输数据以及移位操作
  • 06、如何将对象数组里 obj 的 key 值变成动态的(即:每一个对象对应的 key 值都不同)
  • ngx_http_request_s
  • Docker 学习路线 2:底层技术
  • UEFI实战——显示图片
  • Ansible中的playbook
  • 怎样去除视频中的杂音,保留人声部分?
  • 基于Qt QTreeView|QTreeWidget控件使用简单版
  • edge浏览器的隐藏功能
  • 安卓抓包之小黄鸟
  • Django中的FBV和CBV
  • 信息泄露--