The UserGroupsMapping command is used to manage and query information about user group mappings.
Prerequisites
A Hadoop environment, Hadoop cluster, or Hadoop client is created. For more information about how to install Hadoop, see Step 2: Create a Hadoop runtime environment.
OSS-HDFS is enabled for specific buckets. For more information about how to enable OSS-HDFS, see Enable OSS-HDFS and grant access permissions.
JindoSDK 4.5.0 or later is installed and configured. For more information, see Connect non-EMR clusters to OSS-HDFS.
Step 1: Configure environment variables
Connect to an ECS instance. For more information, see Connect to an ECS instance.
Go to the bin directory of the installed JindoSDK JAR package.
cd jindosdk-x.x.x/bin/
Notex.x.x indicates the version number of the JindoSDK JAR package.
Grant read and write permissions to the
jindo-util
file in the bin directory.chmod 700 jindo-util
Rename the
jindo-util
file tojindo
.mv jindo-util jindo
Create a configuration file named
jindosdk.cfg
, and then add the following parameters to the configuration file.[common] Retain the following default configurations. logger.dir = /tmp/jindo-util/ logger.sync = false logger.consolelogger = false logger.level = 0 logger.verbose = 0 logger.cleaner.enable = true hadoopConf.enable = false [jindosdk] Specify the following parameters. <!-- In this example, the China (Hangzhou) region is used. Specify your actual region. --> fs.oss.endpoint = cn-hangzhou.oss-dls.aliyuncs.com <! -- Configure the AccessKey ID and AccessKey secret that is used to access OSS-HDFS. --> fs.oss.accessKeyId = LTAI******** fs.oss.accessKeySecret = KZo1********
Configure environment variables.
export JINDOSDK_CONF_DIR=<JINDOSDK_CONF_DIR>
Set <JINDOSDK_CONF_DIR> to the absolute path of the
jindosdk.cfg
configuration file.
Step 2: Manage mappings between users and user groups
Map users to user groups
Command syntax
./jindo admin -addUserGroupsMapping \ [-dlsUri <uri>] \ [-user <user>] \ [-groups <group1,group2...>]
Example
You can run the following command to map user1 to group1 and group2:
./jindo admin -addUserGroupsMapping \ -dlsUri oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com \ -user user1 \ -groups group1,group2
Query the information about users and user groups
Command syntax
./jindo admin -listUserGroupsMappings \ [-dlsUri <dlsUri>] \ [-maxKeys <maxKeys>] \ [-marker <marker>]
Example
You can run the following command to query information about 10 users whose names contain the test string in the path specified by <dlsUri>:
./jindo admin -listUserGroupsMappings \ -dlsUri oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com \ -maxKeys 10 \ -marker test
The -maxKeys and -marker options are both optional.
The -maxKeys option is used to specify the number of users that you want to query.
The -marker option is used to filter users whose names contain a specific string.
Delete the mapping between a user and a user group
Command syntax
./jindo admin -deleteUserGroupsMapping \ [-dlsUri <uri>] \ [-user <user>]
Example
You can run the following command to remove the mapping between user1 and the user groups to which user1 belongs:
./jindo ad -deleteUserGroupsMapping \ -dlsUri oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com \ -user user1