MySQL-server-5.1.73-1.glibc23.i386.rpm
MySQL-client-5.1.73-1.glibc23.i386.rpm
1 derby 单连接
/bin 启动hive ,则自动生成库,但只支持一个连接,所以可以在其他文件夹下启动hive,只是这是另一个库
show databases;
create table user(id int, name string);
show tables;
show create table user;
load data local inpath '/root/user.txt' into table user; --执行后,无法select出来,需指定文件中的分隔符
select count(*) from user;
create table role(id bigint, name string) row format delimited fileds terminated by '\t';
安装mysql
《linux系统安装mysql》
MySQL-server-5.1.73-1.glibc23.i386.rpm
MySQL-client-5.1.73-1.glibc23.i386.rpm
1通过rpm源码安装,下载文件小,但依赖包太多,不建议
2通过二进制安装,下载文件大,但安装快,推荐
mirror: http://mysql.mirror.kangaroot.net/Downloads/
tar -zxvf mysql-5.1.72
cp mysql-5.1.72 /usr/local/mysql -r
删除derby时使用的文件夹
linux:
hadoop fs -rmr /usr/hive
mv hive-default.xml.template hive-site.xml
managed table
hive:
create table user(id int, name string);
mysql:
TBLS - hive创建的表都在这里面定义
CLOUMNS_V2 - 字义的字段
SDS - 存放在hdfs上的位置
hive:
create table role(id bigint, name string) row format limited fields terminited by '\t';
外部表(先有数据,后建表)
hive状态下查询hdfs
hive:(在hive中操作hdfs)
dfs -fs /;
dfs -mkdir /data;
dfs -put /root/user.txt /data/user.txt
create external table ext_user(id int, name string) row format delimited fields termited by '\t' location '/data';
不管内部表或外部表,只要放在对应文件夹下,就可以
create table sms(id bigint, content string, area string) partitioned by (area_par string) row format delimited fileds terminated by '\t';
create table trade_detail(id bigint, account string, income double, expense double, time string) row format delimited fields terminated by '\t';
create table user_info(id int, account string, name string, age int) row format delimited fields terminated by '\t';
sqoop从mysql导入到hive
hive下执行trade_detail和user_info的关联查询
UDF
extends UDF
定义evaluate函数
添加jar: add jar *.jar;
创建临时函数:create temporary function toUpper as 'net.oschina.udf.ToUpperUDF'