文档

按Bucket配置OSS/OSS-HDFS Credential Provider

更新时间:

本文为您介绍如何按Bucket配置OSS/OSS-HDFS Credential Provider。

按照Bucket配置Credential Provider

<configuration>
    <property>
        <name>fs.oss.bucket.XXX.credentials.provider</name>
        <value>com.aliyun.jindodata.oss.auth.SimpleAliyunCredentialsProvider,com.aliyun.jindodata.oss.auth.EnvironmentVariableCredentialsProvider,com.aliyun.jindodata.oss.auth.CommonCredentialsProvider</value>
        <description>配置com.aliyun.jindodata.oss.auth.AliyunCredentialsProvider的实现类,多个类时使用英文逗号(,)隔开,按照先后顺序读取Credential直至读到有效的Credential。Provider详情请参见Credential Provider类型。</description>
    </property>
</configuration>
说明

XXX为OSS/OSS-HDFS Bucket名称。

Credential Provider类型

您可以根据情况,选择不同的Credential Provider,支持如下Credential Provider类型:

Credential Provider类型

说明

TemporaryCredentialsProvider

适合使用有时效性的AccessKey和SecurityToken访问OSS或OSS-HDFS的情况。

SimpleCredentialsProvider

适合使用长期有效的AccessKey访问OSS或OSS-HDFS的情况。

EnvironmentVariableCredentialsProvider

在环境变量中获取AccessKey。

CommonCredentialsProvider

通用配置。

TemporaryCredentialsProvider

  • 配置Provider类型

    <configuration>
        <property>
            <name>fs.oss.bucket.XXX.credentials.provider</name>
            <value>com.aliyun.jindodata.oss.auth.TemporaryCredentialsProvider</value>
        </property>
    </configuration>
  • 配置OSS或OSS-HDFS AccessKey

    <configuration>
        <property>
            <name>fs.oss.bucket.XXX.accessKeyId</name>
            <value>OSS/OSS-HDFS bucket的AccessKey Id</value>
        </property>
        <property>
            <name>fs.oss.bucket.XXX.accessKeySecret</name>
            <value>OSS/OSS-HDFS bucket的AccessKey Secret</value>
        </property>
        <property>
            <name>fs.oss.bucket.XXX.securityToken</name>
            <value>OSS/OSS-HDFS bucket的SecurityToken(临时安全令牌)</value>
        </property>
    </configuration>

SimpleCredentialsProvider

  • 配置Provider类型

    <configuration>
        <property>
            <name>fs.oss.bucket.XXX.credentials.provider</name>
            <value>com.aliyun.jindodata.oss.auth.SimpleCredentialsProvider</value>
        </property>
    </configuration>
  • 配置OSS或OSS-HDFS AccessKey

    <configuration>
        <property>
            <name>fs.oss.bucket.XXX.accessKeyId</name>
            <value>OSS/OSS-HDFS bucket的AccessKey Id</value>
        </property>
        <property>
            <name>fs.oss.bucket.XXX.accessKeySecret</name>
            <value>OSS/OSS-HDFS bucket的AccessKey Secret</value>
        </property>
    </configuration>

EnvironmentVariableCredentialsProvider

  • 配置Provider类型

    <configuration>
        <property>
            <name>fs.oss.bucket.XXX.credentials.provider</name>
            <value>com.aliyun.jindodata.oss.auth.EnvironmentVariableCredentialsProvider</value>
        </property>
    </configuration>
  • 配置OSS或OSS-HDFS AccessKey

    需要在环境变量中配置以下参数:
    参数说明
    OSS_ACCESS_KEY_IDOSS或OSS-HDFS的AccessKey ID。
    OSS_ACCESS_KEY_SECRETOSS或OSS-HDFS的AccessKey Secret。
    OSS_SECURITY_TOKENOSS或OSS-HDFS的SecurityToken(临时安全令牌)。
    说明 仅配置有时效Token时需要。

CommonCredentialsProvider

  • 配置Provider类型

    <configuration>
        <property>
            <name>fs.oss.bucket.XXX.credentials.provider</name>
            <value>com.aliyun.jindodata.oss.auth.CommonCredentialsProvider</value>
        </property>
    </configuration>
  • 配置OSS或OSS-HDFS AccessKey

    <configuration>
        <property>
            <name>jindo.common.accessKeyId</name>
            <value>OSS/OSS-HDFS Bucket的AccessKey Id</value>
        </property>
        <property>
            <name>jindo.common.accessKeySecret</name>
            <value>OSS/OSS-HDFS Bucket的AccessKey Secret</value>
        </property>
        <property>
            <name>jindo.common.securityToken</name>
            <value>OSS/OSS-HDFS Bucket的SecurityToken(临时安全令牌)。仅配置有时效Token时需要。</value>
        </property>
    </configuration>
  • 本页导读 (1)