本文為您介紹如何按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_ID
OSS或OSS-HDFS的AccessKey ID。
OSS_ACCESS_KEY_SECRET
OSS或OSS-HDFS的AccessKey Secret。
OSS_SECURITY_TOKEN
OSS或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>