YohLee / Learning

学习资料
2 stars 0 forks source link

hadoop hdfs 授权命令 #21

Open YohLee opened 4 years ago

YohLee commented 4 years ago

由root用户切换到hdfs用户,执行以下命令

hadoop fs -chown -R root:root /warehouse

YohLee commented 4 years ago

create table student(id int, name string, sex string, age int, department string) partitioned by (day string) row format delimited fields terminated by ",";

insert into student PARTITION (day='20200309') select 23,'liyang','f',23,'testing'; ------------hive 分区-----------------------------------------------------------------

insert into student PARTITION (day='20200308') select 24,'wangyang','m',23,'testing';

select * from student where day='20200309';

YohLee commented 4 years ago

        //创建具有分区的表格         hiveCtx.sql("CREATE TABLE IF NOT EXISTS xxx.table (cc STRING, dd STRING) partitioned by (ds string) row format delimited fields terminated by ',' COLLECTION ITEMS TERMINATED BY ',' stored as textfile");         //删除时间为3天之前的分区         String droupSql = "ALTER TABLE xxx.table DROP IF EXISTS PARTITION (ds="+threeDayAgo+")"; hiveCtx.sql(droupSql); //如果当前时间的分区存在也要删除,后面会插入         String droupTodaySql = "ALTER TABLE xxx.table DROP IF EXISTS PARTITION (ds="+today+")"; hiveCtx.sql(droupTodaySql); //增加当前时间的分区 String addSql = "ALTER TABLE xxx.table ADD PARTITION (ds="+today+")";         hiveCtx.sql(addSql);         String inserSql = "insert into xxx.table PARTITION (ds="+today+") select cc,dd from temp";         hiveCtx.sql(inserSql);

YohLee commented 4 years ago

show partitions student;

YohLee commented 4 years ago

给hdfs 修改权限

hadoop fs -chmod -R 777 /