How to access Tencent Cloud COS
search cancel

How to access Tencent Cloud COS

book

Article ID: 296296

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

Tencent cloud offer an object storage service, called COS. It has been widely used in China. This service is compatible with S3 protocol, but the official documentation does not mention how to use S3 protocol to access it's data.

Environment

Product Version: 6.0

Resolution

gpcheckcloud

To access the Tencent Cloud COS service through gpcheckcloud, use the command below:

gpcheckcloud -d 's3://cos.ap-chongqing.myqcloud.com/my_bucket_name/ config=/home/gpadmin/cos2.conf region=ap-chongqing'


Here are more details:

bucket : my_bucket_name
region: ap-chongqing
config file : /home/gpadmin/cos2.conf  (you can rename it)


In this config file, you only need to provided the details below:

secret ="xxxxx"  (secret key)
accessid ="xxxx"  (access id)
encryption = true
version = 2


S3 Protocol 

You can also use an external table with S3 protocol to access the Tencent Cloud COS service.

1. Create the function required by S3 protocol:

CREATE OR REPLACE FUNCTION write_to_s3() RETURNS integer AS
   '$libdir/gps3ext.so', 's3_export' LANGUAGE C STABLE;
CREATE OR REPLACE FUNCTION read_from_s3() RETURNS integer AS
   '$libdir/gps3ext.so', 's3_import' LANGUAGE C STABLE;


2. Create S3 protocol for any database that needs to use this protocol:

CREATE PROTOCOL s3 (writefunc = write_to_s3, readfunc = read_from_s3);


3. Create an external table. Choose a readable or writable external table, but when using S3 protocol, an external web table is not allowed.

create writable external  table t1 (id text)
location ('s3://cos.ap-chongqing.myqcloud.com/my_bucket_name/ region=ap-chongqing config=/home/gpadmin/cos3.conf')
FORMAT 'TEXT';


4. Try to insert one record to the external table.

gpadmin=# insert into t1 values ('asdf');
INSERT 0 1


For more information, refer to the following documentation: