云服务器内容精选

  • 操作步骤 创建OBS并行文件系统,详情请参考创建并行文件系统章节。例如文件系统名称为“lakeformation-test”。 在并行文件系统页面,单击已创建的文件系统名称,例如“lakeformation-test”。 在左侧导航栏选择“文件”,单击“新建文件夹”,填写待创建的文件夹名称,单击“确定”。继续单击该文件夹名称,单击“新建文件夹”,可以创建其子文件夹。 参考该步骤,依次创建用于存放元数据的路径,例如: Catalog存储路径:lakeformation-test/catalog1 数据库存储路径:lakeformation-test/catalog1/database1 数据表存储路径:lakeformation-test/catalog1/database1/table1、lakeformation-test/catalog1/database1/table2 函数存储路径:lakeformation-test/catalog1/database1/udf1
  • 前提条件 已参考元数据迁移完成元数据迁移。 当前用户具有OBS相关操作权限,且已创建用于存储数据的OBS并行文件系统。 需将待迁移的权限策略文件导出,并上传至OBS并行文件系统中。权限导出操作可联系对应服务支持人员。 权限策略中授权主体(除角色外)需要提前创建,且名称需保持一致;权限策略中包含的元数据已存在,且名称一致。 如果迁移类型为DLF,其对应关系及迁移策略如下: RAM 用户: IAM 用户(如果对应的IAM用户不存在,该权限策略不进行迁移) RAM角色:IAM用户组(如果对应的IAM用户组不存在,该权限策略不进行迁移) DLF角色:LakeFormation角色(不存在会自动创建) 如果迁移类型为Ranger,则仅支持Ranger的allow权限迁移,不支持deny权限迁移。
  • 前提条件 当前实例已创建存储迁移元数据的Catalog。 待操作用户具有OBS相关操作权限、具有已创建存储迁移元数据的Catalog的操作权限。 已创建了用于存储迁移数据的OBS并行文件系统。 表的Owner只能包含字母、数字和下划线(_),且长度为1~49个字符。不能包含中划线(-)等其他字符。 如果需要迁移多个 MRS 集群中的元数据到同一个LakeFormation实例,MRS集群之间的Database名称不能重复。 如果需要进行多次迁移,表的列更新需要满足列排序和列类型一致的兼容性要求。
  • 支持审计日志的操作 表1 云审计 服务支持的LakeFormation服务操作 操作名称 资源类型 事件名称 创建Catalog Catalog createCatalog 删除Catalog Catalog dropCatalog 修改Catalog Catalog alterCatalog 创建数据库 Database createDatabase 删除数据库 Database dropDatabase 修改数据库 Database alterDatabase 创建数据表 Table createTable 删除数据表 Table dropTable 修改数据表 Table alterTable 清空表的数据 Table truncateTable 创建函数 Function createFunction 修改函数属性 Function alterFunction 删除函数 Function dropFunction 创建实例 instance createInstance 修改实例 instance updateInstance 删除实例 instance deleteInstance 授予权限 Access grantAccess 取消授权 Access revokeAccess 更新表的指定列统计信息 TableColumnStatistic setTableColumnStatistics 删除表的指定列统计信息 TableColumnStatistic deleteTableColumnStatistics 批量创建表的列限制条件 TableConstraint addConstraints 删除列限制条件 TableConstraint deleteConstraints 批量添加分区信息 Partition addPartitions 批量修改分区信息 Partition alterPartitions 批量删除分区信息 Partition dropPartitions 批量清空列表信息 Partition truncatePartitions 批量设置分区的统计信息 PartitionColumnStatistic setPartitionColumnStatistics 删除分区列的统计信息 PartitionColumnStatistic deletePartitionColumnStatistics
  • 数据权限概述 数据湖 权限支持配置数据库、数据表、函数等维度的权限。 云服务管理员可针对不同的管理对象配置不同用户组的权限,统一对数据湖资源进行管理。 用户可通过LakeFormation管理控制台对数据湖内的资源进行统一权限管理,对于IAM用户/用户组,也可以通过关联LakeFormation服务的细粒度权限策略进行特性权限场景的授权,参见创建LakeFormation自定义IAM策略。当湖内数据资源较多时,建议通过LakeFormation管理控制台对数据湖内的资源进行统一权限管理。 LakeFormation配置权限时需要包含如下要素: 表1 LakeFormation权限要素 权限要素 描述 授权主体 被授予权限的对象,使其具备针对某数据资源的指定访问权限的用户组、角色、IAM用户、委托用户等身份,如某一用户组、某一角色等。 授权主体(用户组、角色、IAM用户、委托用户)名称中不能包含中划线(-),否则可能造成操作失败。 授权类型 数据湖中管理的资源: 数据目录(Catalog) 数据库(Database) 数据表(Table) 数据列(Column) 函数(Function) OBS路径。 操作类型 主体对授权类型的访问权限,不同授权类型支持的操作类型各不相同,可参见表2。 赋予授权权限 是否赋予授权权限,赋予授权权限后,授权主体便可以将拥有将权限授权给其他授权主体。 表2 不同授权类型的操作权限 授权类型 操作类型 权限说明 Catalog ALL Catalog的所有操作权限。 ALTER 修改Catalog。 CREATE_DATABASE 创建数据库。 DROP 删除Catalog。 DESCRIBE 查看Catalog的元数据信息或切换Catalog。 LIST_DATABASE 查看Catalog下资源列表。 数据库 ALL 数据库的所有操作权限。 ALTER 修改数据库。 DROP 删除数据库。 DESCRIBE 查看数据库的元数据信息或切换数据库。 LIST_TABLE 查看数据库下资源列表。 LIST_FUNC 查看某一数据库下的函数。 CREATE_TABLE 在数据库中创建表。 CREATE_FUNC 在数据库中创建函数。 表 ALL 表的所有操作权限。 ALTER 修改表。 DROP 删除表。 DESCRIBE 查看表的元数据信息。 UPDATE 更新表数据。 INSERT 插入表数据。 SELECT 查询表内数据。 DELETE 删除表的数据。 列 SELECT 查询表内的列数据。 函数 ALL 函数的所有操作权限。 ALTER 修改函数。 DROP 删除函数。 DESCRIBE 查看函数的元数据信息。 EXEC 执行函数。 路径 READ 路径下文件的读权限。 WRITE 路径下文件的写权限。 权限管理员通常分为系统权限管理员与业务权限管理员,需要具备的IAM权限与权限管理范围不同 系统权限管理员 需要拥有以下IAM操作权限:lakeformation:policy:describe、lakeformation:policy:create、lakeformation:policy:drop。 权限管理范围:可将任意元数据权限授予给其他授权主体,可撤销任意元数据权限。 业务权限管理员 需要拥有以下IAM操作权限: lakeformation:policy:describe、lakeformation:policy:delegate。 权限管理范围:需要被业务管理员赋予授权权限,才能将元数据权限授予其他授权主体,或撤销元数据权限。 例如:系统中存在系统权限管理员User A、业务权限管理员User B、普通用户User C。User A将Catalog1的ALL权限授予User B并同时赋予授权权限后,User B可将Catalog1的DESC等权限授予User C。但User B无法将其他Catalog的权限授予User C。 父主题: 管理数据权限
  • LakeFormation自定义策略样例 示例1:授权用户批量LakeFormation只读权限 { "Version": "1.1", "Statement": [ { "Effect": "Allow", "Action": [ "lakeformation:instance:describe", "lakeformation:role:describe", "lakeformation:policy:export", "lakeformation:group:describe", "lakeformation:function:describe", "lakeformation:catalog:describe", "lakeformation:policy:describe", "lakeformation:table:describe", "lakeformation:database:describe" ] } ] } 示例2:拒绝用户删除数据 拒绝策略需要同时配合其他策略使用,否则没有实际作用。用户被授予的策略中,一个授权项的作用如果同时存在Allow和Deny,则遵循Deny优先原则。 如果您给用户授予Admin的系统策略,但不希望用户拥有删除LakeFormation的Catalog、数据库、表的权限,您可以创建一条拒绝删除云服务的自定义策略,然后同时将Admin和拒绝策略授予用户,根据Deny优先原则,则用户可以对LakeFormation执行除了删除Catalog、数据库、表外的所有操作。 拒绝策略示例如下: { "Version": "1.1", "Statement": [ { "Effect": "Deny", "Action": [ "lakeformation:database:drop", "lakeformation:table:drop", "lakeformation:catalog:drop" ] } ] } 示例3:多个云服务同时授权项策略 { "Version": "1.1", "Statement": [ { "Effect": "Allow", "Action": [ "obs:bucket:CreateBucket" ] }, { "Effect": "Allow", "Action": [ "lakeformation:table:create", "lakeformation:database:create", "lakeformation:catalog:create" ] } ] }
  • LakeFormation服务权限 默认情况下,管理员创建的IAM用户没有任何权限,需要将其加入用户组,并给用户组授予策略或角色,才能使得用户组中的用户获得对应的权限,这一过程称为授权。授权后,用户就可以基于被授予的权限对云服务进行操作。 权限根据授权精细程度分为角色和策略。 角色:IAM最初提供的一种根据用户的工作职能定义权限的粗粒度授权机制。该机制以服务为粒度,提供有限的服务相关角色用于授权。由于各服务之间存在业务依赖关系,因此给用户授予角色时,可能需要一并授予依赖的其他角色,才能正确完成业务。角色并不能满足用户对精细化授权的要求,无法完全达到企业对权限最小化的安全管控要求。 IAM项目只读授权指导:当租户管理员需要给某个子用户分配LakeFormation服务在某个IAM项目下的只读权限。可以给该用户创建一个用户组,同时在用户组将LakeFormation ReadOnlyAccess系统策略授权给指定IAM项目即可。 企业项目授权指导:当租户管理员需要给某个子用户分配LakeFormation服务在某个企业项目下的所有操作权限。可以给该用户创建一个用户组,同时在用户组中将LakeFormation CommonAccess授权给全局,将LakeFormation FullAccess授权给指定企业项目即可。 策略:IAM最新提供的一种细粒度授权的能力,可以精确到具体服务的操作、资源以及请求条件等。基于策略的授权是一种更加灵活的授权方式,能够满足企业对权限最小化的安全管控要求。多数细粒度策略以API接口为粒度进行权限拆分,LakeFormation的自定义IAM策略操作可参考创建LakeFormation自定义IAM策略。 表1 LakeFormation系统策略 系统角色/策略名称 描述 类别 依赖关系 LakeFormation FullAccess LakeFormation管理员权限,拥有该权限的用户可以操作并使用所有LakeFormation服务功能。 系统策略 IAM AgencyFullAccess OBS OperateAccess VPC FullAccess VPCEndpoint FullAccess LakeFormation ReadOnlyAccess LakeFormation只读权限,拥有该权限的用户可以执行LakeFormation所有查询类功能。 系统策略 IAM ReadOnlyAccess OBS ReadOnlyAccess VPC ReadOnlyAccess VPCEndpoint ReadOnlyAccess LakeFormation CommonOperations LakeFormation基础权限,包含LakeFormation服务协议查看/授权/取消,以及OBS、TMS等周边依赖服务的基础权限集合。 系统策略 IAM ReadOnlyAccess OBS ReadOnlyAccess VPC FullAccess VPCEndpoint FullAccess 表2 LakeFormation的IAM权限列表 操作类型 操作项 描述 只读 lakeformation:access:describe 查询接入客户端。 lakeformation:accessAgency:describe 查询接入委托信息。 lakeformation:accessService:describe 查看接入服务。 lakeformation:agency:describe 查询委托。 lakeformation:agreement:describe 查询服务协议授权。 lakeformation:catalog:describe 查询Catalog元数据。 lakeformation:configuration:describe 查询配置。 lakeformation:credential:describe 查询认证信息。 lakeformation:database:describe 查询数据库元数据。 lakeformation:dataset:describe 查询数据集元数据。 lakeformation:dataset:describeFile 查询数据集文件元数据。 lakeformation:dataset:describeFileGroup 查询数据集文件组元数据。 lakeformation:function:describe 查询函数元数据。 lakeformation:group:describe 查询用户组信息。 lakeformation:instance:describe 查询实例。 lakeformation:instance:listAuthorizedLocation 查询授权资源。 lakeformation:instanceJob:describe 查询任务。 lakeformation:model:describe 查询模型元数据。 lakeformation:model:describeFile 查询模型文件元数据。 lakeformation:obs:describe 查询OBS桶列表。 lakeformation:policy:describe 查询权限策略。 lakeformation:policy:export 批量查询权限策略。 lakeformation:role:describe 查询角色。 lakeformation:table:describe 查询表元数据。 lakeformation:tableFileGroup:describe 查询表文件组元数据。 lakeformation:tag:describe 查询资源标签。 lakeformation:user:describe 查询用户以及关联角色关系。 写 lakeformation:access:create 创建接入客户端。 lakeformation:access:delete 删除接入客户端。 lakeformation:agency:create 创建委托。 lakeformation:agency:drop 删除委托。 lakeformation:catalog:alter 修改Catalog元数据。 lakeformation:catalog:create 创建Catalog元数据。 lakeformation:catalog:drop 删除Catalog元数据。 lakeformation:database:alter 修改数据库元数据。 lakeformation:database:create 创建数据库元数据。 lakeformation:database:drop 删除数据库元数据。 lakeformation:dataset:alter 修改数据集元数据。 lakeformation:dataset:alterFile 修改数据集文件元数据。 lakeformation:dataset:alterFileGroup 修改数据集文件组元数据。 lakeformation:dataset:create 创建数据集元数据。 lakeformation:dataset:createFile 创建数据集文件元数据。 lakeformation:dataset:createFileGroup 创建数据集文件组元数据。 lakeformation:dataset:drop 删除数据集元数据。 lakeformation:dataset:dropFile 删除数据集文件元数据。 lakeformation:dataset:dropFileGroup 删除数据集文件组元数据。 lakeformation:function:alter 修改函数元数据。 lakeformation:function:create 创建函数元数据 lakeformation:function:drop 删除函数元数据。 lakeformation:group:alter 修改用户组信息。 lakeformation:instance:access 申请接入服务。 lakeformation:instance:alter 修改实例。 lakeformation:instance:create 创建实例。 lakeformation:instance:drop 删除实例。 lakeformation:instanceJob:alter 修改任务。 lakeformation:instanceJob:create 创建任务。 lakeformation:instanceJob:drop 删除任务。 lakeformation:instanceJob:exec 执行任务。 lakeformation:model:alter 修改模型元数据。 lakeformation:model:alterFile 修改模型文件元数据。 lakeformation:model:create 创建模型元数据。 lakeformation:model:createFile 创建模型文件元数据。 lakeformation:model:drop 删除模型元数据。 lakeformation:model:dropFile 删除模型文件元数据。 lakeformation:policy:create 创建权限策略。 lakeformation:policy:drop 删除权限策略。 lakeformation:role:alter 修改角色。 lakeformation:role:create 创建角色。 lakeformation:role:drop 删除角色。 lakeformation:table:alter 修改表元数据。 lakeformation:table:create 创建表元数据。 lakeformation:table:drop 删除表元数据。 lakeformation:tableFileGroup:create 创建表文件组元数据。 lakeformation:tableFileGroup:drop 删除表文件组元数据。 lakeformation:transaction:operate 操作事务。 lakeformation:user:alter 修改用户以及关联角色关系。 权限管理 lakeformation:accessService:grant 授权接入服务。 lakeformation:accessTenant:grant 授权接入租户。 lakeformation:agreement:cancel 取消服务协议授权。 lakeformation:agreement:grant 授权服务协议授权。 lakeformation:instance:authorizeLocation 授权OBS路径。 lakeformation:instance:cancelAuthorizeLocation 取消授权OBS路径。
  • 操作流程 图1 给用户授权LakeFormation权限流程 创建用户组并授权 在IAM控制台创建用户组,并授予LakeFormation服务对应权限。 创建用户并加入用户组 在IAM控制台创建用户,并将其加入1.创建用户组并授权中创建的用户组。 用户登录并验证权限 以新创建的用户登录云服务控制台,切换至授权区域,验证权限是否生效。 例如: 在“服务列表”中选择LakeFormation服务,进入总览界面,单击右上角“购买实例”,实例创建界面正常展示,表示“lakeformation:role:create”权限已生效。
  • 请求示例 POST https://{endpoint}/v1/{project_id}/instances/{instance_id}/lf-jobs { "name" : "testjob", "description" : "testjob", "type" : "METADATA_MIGRATION", "parameter" : { "metadata_migration_parameter" : { "datasource_type" : "ALIYUN_DLF", "datasource_parameter" : { "jdbc_url" : "jdbc:protocol://host:port/db_name", "username" : "root", "password" : "password", "endpoint" : "example.com", "access_key" : "LTAIxxxxxxxxxxxxxxxxRxPG", "secret_key" : "12345xxxxxxxxxxxxxxxxNabcdefgh", "subnet_ip" : "127.0.0.1" }, "source_catalog" : "sourceCatalog1", "target_catalog" : "targetCatalog1", "conflict_strategy" : "UPSERT", "log_location" : "obs://logStore/2023", "sync_objects" : [ "string" ], "default_owner" : "string", "locations" : [ { "key" : "test/test1", "value" : "test2/db" } ], "instance_id" : "string", "ignore_obs_checked" : false, "network_type" : "EIP", "accepted_vpc_id" : "13551d6b-755d-4757-b956-536f674975c0" }, "permission_migration_parameter" : { "location" : "obs://location/uri/", "file_name" : "string", "log_location" : "obs://logStore/2023", "policy_type" : "DLF", "catalog_id" : "test_catalog", "instance_id" : "string", "ranger_permission_migration_principal_relas" : { "user_to" : "IAM_USER", "user_prefix" : "string", "user_suffix" : "string", "group_to" : "IAM_USER", "group_prefix" : "string", "group_suffix" : "string", "role_to" : "IAM_USER", "role_prefix" : "string", "role_suffix" : "string" } }, "metadata_discovery_parameter" : { "data_location" : "obs://logStore/2023", "target_catalog" : "targetCatalog1", "target_database" : "targetCatalog1", "conflict_strategy" : "UPDATE", "file_discovery_type" : "PARQUET", "separator" : ",", "quote" : "DOUBLE_QUOTE", "escape" : "\\", "header" : false, "file_sample_rate" : 100, "table_depth" : 3, "log_location" : "obs://logStore/2023", "default_owner" : "testOwner", "principals" : [ { "principal_type" : "USER", "principal_source" : "IAM", "principal_name" : "user1" } ], "give_write" : false, "instance_id" : "abcdefgh12345678abcdefgh12345678", "rediscovery_policy" : "FULL_DISCOVERY", "execute_strategy" : "MANNUAL", "execute_frequency" : "MONTHLY", "execute_day" : 1, "execute_hour" : 1, "execute_minute" : 1 } } }
  • 响应示例 状态码: 201 创建任务成功 { "id" : "03141229-84cd-4b1b-9733-dd124320c125", "name" : "testjob", "description" : "testJob", "type" : "METADATA_MIGRATION", "parameter" : { "metadata_migration_parameter" : { "datasource_type" : "ALIYUN_DLF", "datasource_parameter" : { "endpoint" : "protocol://example.example1.com" }, "source_catalog" : "sourceCatalog1", "target_catalog" : "targetCatalog1", "conflict_strategy" : "UPDATE", "log_location" : "obs://logStore/2023", "sync_objects" : [ "DATABASE" ], "locations" : [ { "key" : "test/test1", "value" : "test2/db" } ] } }, "status" : { "status" : "SUC CES S" } } 状态码: 400 Bad Request { "error_code" : "common.01000001", "error_msg" : "failed to read http request, please check your input, code: 400, reason: Type mismatch., cause: TypeMismatchException" } 状态码: 401 Unauthorized { "error_code": 'APIG.1002', "error_msg": 'Incorrect token or token resolution failed' } 状态码: 403 Forbidden { "error" : { "code" : "403", "message" : "X-Auth-Token is invalid in the request", "error_code" : null, "error_msg" : null, "title" : "Forbidden" }, "error_code" : "403", "error_msg" : "X-Auth-Token is invalid in the request", "title" : "Forbidden" } 状态码: 404 Not Found { "error_code" : "common.01000001", "error_msg" : "response status exception, code: 404" } 状态码: 408 Request Timeout { "error_code" : "common.00000408", "error_msg" : "timeout exception occurred" } 状态码: 500 Internal Server Error { "error_code" : "common.00000500", "error_msg" : "internal error" }
  • URI POST /v1/{project_id}/instances/{instance_id}/lf-jobs 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目编号。获取方法,请参见获取项目ID。 instance_id 是 String LakeFormation实例ID。创建实例时自动生成。例如:2180518f-42b8-4947-b20b-adfc53981a25。
  • URI PUT /v1/{project_id}/instances/{instance_id}/lf-jobs/{job_id} 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目编号。获取方法,请参见获取项目ID。 instance_id 是 String LakeFormation实例ID。创建实例时自动生成。例如:2180518f-42b8-4947-b20b-adfc53981a25。 job_id 是 String 任务ID。
  • 请求示例 PUT https://{endpoint}/v1/{project_id}/instances/{instance_id}/lf-jobs/{job_id} { "name" : "testjob", "description" : "string", "parameter" : { "metadata_migration_parameter" : { "datasource_type" : "ALIYUN_DLF", "datasource_parameter" : { "endpoint" : "protocol://example.example1.com", "access_key" : "LTAIxxxxxxxxxxxxxxxxRxPG", "secret_key" : "1234xxxxxxxxxxxxxxxxxxxxefgh" }, "source_catalog" : "sourceCatalog1", "target_catalog" : "targetCatalog1", "conflict_strategy" : "UPDATE", "log_location" : "obs://logStore/2023", "sync_objects" : [ "DATABASE" ], "locations" : [ { "key" : "test/test1", "value" : "test2/db" } ], "instance_id" : "12345678910a" } } }
  • 响应示例 状态码: 200 修改任务信息成功 { "id" : "03141229-84cd-4b1b-9733-dd124320c125", "name" : "testjob", "description" : "testJob", "type" : "METADATA_MIGRATION", "parameter" : { "metadata_migration_parameter" : { "datasource_type" : "ALIYUN_DLF", "datasource_parameter" : { "endpoint" : "protocol://example.example1.com" }, "source_catalog" : "sourceCatalog1", "target_catalog" : "targetCatalog1", "conflict_strategy" : "UPDATE", "log_location" : "obs://logStore/2023", "sync_objects" : [ "DATABASE" ], "locations" : [ { "key" : "test/test1", "value" : "test2/db" } ] } }, "status" : { "status" : "SUCCESS" } } 状态码: 400 Bad Request { "error_code" : "common.01000001", "error_msg" : "failed to read http request, please check your input, code: 400, reason: Type mismatch., cause: TypeMismatchException" } 状态码: 401 Unauthorized { "error_code": 'APIG.1002', "error_msg": 'Incorrect token or token resolution failed' } 状态码: 403 Forbidden { "error" : { "code" : "403", "message" : "X-Auth-Token is invalid in the request", "error_code" : null, "error_msg" : null, "title" : "Forbidden" }, "error_code" : "403", "error_msg" : "X-Auth-Token is invalid in the request", "title" : "Forbidden" } 状态码: 404 Not Found { "error_code" : "common.01000001", "error_msg" : "response status exception, code: 404" } 状态码: 408 Request Timeout { "error_code" : "common.00000408", "error_msg" : "timeout exception occurred" } 状态码: 500 Internal Server Error { "error_code" : "common.00000500", "error_msg" : "internal error" }
  • URI GET /v1/{project_id}/instances/{instance_id}/access-clients 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目编号。获取方法,请参见获取项目ID。 instance_id 是 String LakeFormation实例ID。创建实例时自动生成。例如:2180518f-42b8-4947-b20b-adfc53981a25。 表2 Query参数 参数 是否必选 参数类型 描述 id 否 String ID搜索。根据ID进行搜索。 name 否 String 名称关键字搜索。只能包含字母、数字、下划线和中划线,且最大长度为32个字符。 offset 是 Integer 分页查询时的偏移量。默认值为0。最小值为0,最大值为1000。 limit 否 Integer 分页一页显示数。默认值为10。最小值为1,最大值为1000。