cdh5.7.4上hive的配置

1.1  添加hive服务

 

将hive服务都安装到hadoop-manager2上(列表所示)

并在所有机器上存放mysql驱动,存放位置

    /opt/cloudera/parcels/CDH/lib/hive/lib

 

选择hadoop-manager1上的mysql

选择默认路径

 

 

 

 

 

 

 

1.2   impala

 

 

1)在hive安装集群中输入一下命令,登入hive客户端

         hive

2)打开hive.txt,并将建表命令拷贝在客户端执行

3)将hive_add_partition.sh拷贝到/opt/data-platform/bin

4)在 /opt/data-platform/sbin/jobs_day.sh 文件中添加如下命令

 

#添加partition

sh/opt/data-platform/bin/hive_add_partition.sh >  /opt/data-platform/log/hive_add_partition.log2>&1

 

hive.txt

 

drop table if exists call_logs;

CREATE external TABLE call_logs (

accesscode string,

province string,

region string,

domain string,

frontid string,

callingnumber string,

oricallednumber string,

callednumber string,

starttime string,

answertime string,

keypresstime string,

endtime string,

keypressduration string,

keynumber string,

callduration string,

callingareanum string,

oricalledareanum string,

calledareanum string,

calltype string,

barringtype string,

trunkid string,

localcode string,

destcode string,

listtype string,

category string,

auditresult string,

auditstutas string,

recordfileid string,

recordpath string,

recordstarttime string,

recordendtime string,

ismonitoring string,

direction string,

answerendtiome string,

calllenth string,

notinterceptreason string,

ishide string,

templet_no string,

policyid string

) partitioned BY(stat_date STRING)

ROW format delimited FIELDS TERMINATED BY '|';

 

hive_add_partition.sh

#!/bin/bash

source /etc/profile

if [ $# -eq 1 ]; then

         target_day=$1

else

         target_day=`date-d "-0 days" +"%Y%m%d"`

fi

 

hive -e "alter table call_logs addpartition (stat_date ='${target_day}') location'/user/callLog/stat_date=${target_day}'"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CDH 6.2 中配置 Hive,需要执行以下步骤: 1. 安装 MySQL 或 MariaDB 数据库,并创建一个新的数据库和用户,用于 Hive 元数据存储。 2. 在 Hive 配置文件中设置元数据存储的 JDBC 连接参数。打开 `/etc/hive/conf/hive-site.xml` 文件,添加以下内容: ```xml <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://<mysql_host>:<mysql_port>/<hive_metastore_db_name>?createDatabaseIfNotExist=true</value> <description>metadata is stored in a MySQL server</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>MySQL JDBC driver class</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value><hive_metastore_db_user></value> <description>user name for connecting to mysql server</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value><hive_metastore_db_password></value> <description>password for connecting to mysql server</description> </property> ``` 其中,`<mysql_host>` 为 MySQL 主机名或 IP 地址,`<mysql_port>` 为 MySQL 端口号,`<hive_metastore_db_name>` 为 Hive 元数据存储的数据库名称,`<hive_metastore_db_user>` 和 `<hive_metastore_db_password>` 分别为连接 MySQL 数据库的用户名和密码。 3. 配置 Hadoop HDFS,创建 Hive 所需的 HDFS 目录。例如,可以执行以下命令: ```bash hdfs dfs -mkdir /user/hive/warehouse hdfs dfs -chmod g+w /user/hive/warehouse ``` 4. 启动 Hive Metastore 服务。可以使用以下命令启动: ```bash sudo systemctl start hive-metastore ``` 5. 启动 HiveServer2 服务。可以使用以下命令启动: ```bash sudo systemctl start hive-server2 ``` 6. 使用 Hive 命令行客户端测试配置是否成功。可以使用以下命令: ```bash hive ``` 如果成功配置,将会进入到 Hive 命令行界面。 以上就是在 CDH 6.2 中配置 Hive 的步骤,如果有需要可以参考。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值