diff --git a/source/_posts/es-on-hive.md b/source/_posts/es-on-hive.md index 2621adf..4be0b09 100644 --- a/source/_posts/es-on-hive.md +++ b/source/_posts/es-on-hive.md @@ -3,8 +3,9 @@ title: es on hive date: 2022-06-16 21:50:59 tags: - hive +- ElasticSearch categories: -- 配置相关 +- 大数据 --- diff --git "a/source/_posts/hive-ip\345\234\260\347\220\206\344\277\241\346\201\257\346\237\245\350\257\242.md" "b/source/_posts/hive-ip\345\234\260\347\220\206\344\277\241\346\201\257\346\237\245\350\257\242.md" index 88068ab..616a06a 100644 --- "a/source/_posts/hive-ip\345\234\260\347\220\206\344\277\241\346\201\257\346\237\245\350\257\242.md" +++ "b/source/_posts/hive-ip\345\234\260\347\220\206\344\277\241\346\201\257\346\237\245\350\257\242.md" @@ -3,6 +3,8 @@ title: hive-ip地理信息查询 date: 2022-06-20 23:04:06 tags: - hive +categories: +- 大数据 --- # HIVE UDF IP查询 diff --git "a/source/_posts/hive-\344\270\255\346\226\207\344\271\261\347\240\201.md" "b/source/_posts/hive-\344\270\255\346\226\207\344\271\261\347\240\201.md" index c462a28..19c1de5 100644 --- "a/source/_posts/hive-\344\270\255\346\226\207\344\271\261\347\240\201.md" +++ "b/source/_posts/hive-\344\270\255\346\226\207\344\271\261\347\240\201.md" @@ -4,7 +4,7 @@ date: 2022-06-16 21:51:19 tags: - hive categories: -- 配置相关 +- 大数据 --- diff --git "a/source/_posts/hive\346\235\203\351\231\220\347\233\270\345\205\263\345\221\275\344\273\244.md" "b/source/_posts/hive\346\235\203\351\231\220\347\233\270\345\205\263\345\221\275\344\273\244.md" new file mode 100644 index 0000000..fc057ed --- /dev/null +++ "b/source/_posts/hive\346\235\203\351\231\220\347\233\270\345\205\263\345\221\275\344\273\244.md" @@ -0,0 +1,112 @@ +--- +title: hive权限相关命令 +author: xxzuo +date: 2022-06-22 23:27:58 +tags: +- hive +categories: +- 大数据 +--- + + + +```sql +-- 查看当前用户 +select current_user(); + + +-- 查看当前角色 +show current roles; + + +-- 切换 admin 角色 +set role admin; + +-- 查看所有角色 +show roles; + + + +-- 查看用户的角色 +show role grant user {userName}; + + + + +-- 把角色授权给某个用户 +grant role {roleName} to user {userName}; + + + + +-- 撤销某个用户的角色授权 +revoke role {roleName} from user {userName}; + + + + + + +-- 创建角色 +create role {roleName}; + + + + +-- 删除角色 +drop role {roleName}; + + +-- 授予某个库的权限给某个用户 +grant select on database {dbName} to user {userName}; +grant insert on database {dbName} to user {userName}; +grant update on database {dbName} to user {userName}; +grant delete on database {dbName} to user {userName}; + +-- 回收某个库的权限给某个用户 +revoke select on database {dbName} from user {userName}; +revoke insert on database {dbName} from user {userName}; +revoke update on database {dbName} from user {userName}; +revoke delete on database {dbName} from user {userName}; + +-- 查看指定用户在所有库下面的权限 +show grant user {userName}; +-- 查看指定用户在某个库的权限 +show grant user {userName} on database {dbName}; + + + + + + +-- 授予表的权限给某个用户 +grant select on table {dbName}.tableName to user {userName}; +grant insert on table {dbName}.tableName to user {userName}; +grant update on table {dbName}.tableName to user {userName}; +grant delete on table {dbName}.tableName to user {userName}; + + +-- 回收某个用户的表的权限 +revoke create on table {dbName}.tableName from user {userName}; +revoke select on table {dbName}.tableName from user {userName}; +revoke insert on table {dbName}.tableName from user {userName}; +revoke update on table {dbName}.tableName from user {userName}; +revoke delete on table {dbName}.tableName from user {userName}; + +-- 查看指定用户在指定表的权限 +show grant user {userName} on table {dbName}.{tableName}; + + + + + +-- 权限类别 +-- ALTER 更改表结构,创建分区 +-- CREATE 创建表 +-- DROP 删除表,或分区 +-- INDEX 创建和删除索引 +-- LOCK 锁定表,保证并发 +-- SELECT 查询表权限 +-- SHOW_DATABASE 查看数据库权限 +-- UPDATE 为表加载本地数据的权限 +``` diff --git "a/source/_posts/yarn\351\205\215\347\275\256.md" "b/source/_posts/yarn\351\205\215\347\275\256.md" index 0f65f20..6fd7690 100644 --- "a/source/_posts/yarn\351\205\215\347\275\256.md" +++ "b/source/_posts/yarn\351\205\215\347\275\256.md" @@ -5,7 +5,7 @@ date: 2022-06-21 22:54:37 tags: - yarn categories: -- 配置相关 +- 大数据 --- diff --git "a/source/_posts/\345\210\233\345\273\272hive-udf.md" "b/source/_posts/\345\210\233\345\273\272hive-udf.md" new file mode 100644 index 0000000..e43fee1 --- /dev/null +++ "b/source/_posts/\345\210\233\345\273\272hive-udf.md" @@ -0,0 +1,76 @@ +--- +title: 创建hive-udf +author: xxzuo +date: 2022-06-22 23:28:20 +tags: +- hive +categories: +- 大数据 +--- + + + +### 1.自定义 UDF 函数 +pom 中添加下面依赖 +```xml + + + org.apache.hive + hive-exec + 2.3.4 + + provided + + +``` +> 由于 hive 环境中已经有了 hive-exec jar包 所以打包时,不需要将hive-exec 打入 + +新建一个类 继承 UDF 即可 +```java +// 继承UDF类 +public class MyUDF extends UDF { +// 实现evaluate方法 + public int evaluate(String str) { + // 自定义逻辑 + return 0; + } +} +``` + +在这个类中,方法名一定要为 **evaluate** + +### 2.打包上传 +在 maven 中打包 +找到刚才的 jar 包 +上传到 hive 所在服务器 + +将jar包移动到 hive目录下的auxlib目录 + +然后重启hiveserver2 + + +### 3.注册函数 +将jar包注册到hive中后,就可以注册刚才自己编写的udf函数了 + +一般需要先注册临时函数,因为UDF开发完成后,需要进过一些测试才能确认代码是否没有问题。在测试UDF代码时,务必使用临时函数进行测试。这样即使代码出现了问题,也不会把函数真正的注册到Hive。代码测试完毕并且确认无误后,再将函数注册为永久函数 + + +HIVE 函数相关 +```sql +# 创建临时函数 +CREATE TEMPORARY FUNCTION <函数名> AS ; +# 删除临时函数 +DROP TEMPORARY FUNCTION [IF EXISTS] <函数名>; + + +# 创建永久函数 +CREATE FUNCTION [db_name.]function_name AS class_name + [USING JAR|FILE|ARCHIVE 'file_uri' [, JAR|FILE|ARCHIVE 'file_uri'] ]; +# 删除永久函数 +DROP FUNCTION [IF EXISTS] function_name; + + +# 查看函数 +show functions; + +```