大資料離線計算基本命令

2021-10-09 03:36:57 字數 2205 閱讀 8711

//建立分割槽表  根據店鋪名稱字段分割槽

create table dianpu(month string,price int) partitioned by (name string) row format delimited fields terminated by ',';

//建立普通表

create table dianpu_tmp(name string,month string,price int)  row format delimited fields terminated by ',';

//載入資料到普通表

load data local inpath '/opt/zuoye727' into table dianpu1;

//根據普通表的資料新增到分割槽表

insert into dianpu partition(name) select month,price,name from dianpu1;

//求出每個月銷售額最高的一次記錄

select month,max(price) from dianpu group by month;

//求出每個店鋪的銷售記錄

select name,count(0) from dianpu group by name;

set hive.exec.dynamic.partition=true;

set hive.exec.dynamic.partition.mode=nostrick;

//啟動程序

start-all.sh

//啟動    mysql

service mysqld start

./hive --service hiveserver2 &

netstat -tunl

./beeline

!connect jdbc:hive2://hdp2:10000

root

root

//  檢視表./

show tables;

//   新增jar 包

add jar /opt/myudf-hive.jar;

//   建立 臨時  函式  getudf

create temporary function getudf as 'com.bawei.myudf.myudf';

建立永久函式

方法一:

add jar /opt/apache-hive-1.2.2-bin/lib/hive-udf2.jar; 

create function getjson as 'com.bawei.hive.jsontostring';

//  檢視函式

show functions;

//   建立表

0: jdbc:hive2://hdp2:10000>  create table people(id int,name string,adder string,ufd int)

0: jdbc:hive2://hdp2:10000>  row format delimited fields terminated by ',';

0: jdbc:hive2://hdp2:10000>  load data local  inpath '/opt/udf' into table people;

//  檢視表

select * from people;

//   使用函式

select *,getudf(ufd) from people;

//檢視永久函式

service mysqld starrt

mysql -uroot -p

use hive

show tables; 

select * from funce;

// flume採集kafka資料到hdfs

bin/flume-ng agent --conf conf --conf-file conf/kafka-hdfs.conf --name a1 -dflume.root.logger=info,console

大資料Linux基本命令三

軟體包管理 rmp包管理 功能 安裝 將軟體從包中解出來,並且安裝到硬碟 解除安裝 將軟體從硬碟清除 公升級 替換軟體的舊版本 查詢 查詢軟體包的資訊 rpm包有依賴性 安裝有依賴關係的多個軟體時。被依賴的軟體包需要先安裝 同時指定多個.rpm包檔案進行安裝 被依賴其他程式的軟體包需要先解除安裝,同...

大資料常用基本命令 使用者管理命令

linux使用者管理命令 1.useradd 新增新使用者 基本語法 useradd 使用者名稱 功能描述 新增新使用者 useradd g 組名 使用者名稱 功能描述 新增新使用者到某個組 例項 新增乙個使用者 useradd ceshi 2.passwd 設定使用者密碼 基本語法 passwd ...

知識積累 大資料旅程 Linux 基本命令

ssh root 192.168.217.11 type 命令 type ifconfig file sbin ifconfig elf 二進位制可執行程式的格式 yum install man man pages type yum file usr bin python 二進位制檔案 echo h...