Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Examples

Updated on 2024-10-14 GMT+08:00

Example: Exporting Data in Remote Mode

A data server resides on the same intranet as the cluster, the IP address of the data server is 192.168.0.90, and data files are in CSV format. In this scenario, data is concurrently exported in Remote mode.

To concurrently export data in Remote mode, perform the following operations:

  1. (Optional) Create a user and its user group. The user is used to start GDS. If the user and user group already exist, skip this step.
    groupadd gdsgrp
    useradd -g gdsgrp gds_user
  2. Switch to user gds_user, create the /output_data directory for storing data files, and start user gds_user and its user group.
    su - gds_user
    mkdir -p /output_data
  3. Change the owner of the /output_data directory on the data server to gds_user.
    chown -R gds_user:gdsgrp /output_data 
  4. Log in to the data server as user gds_user and start GDS.
    The GDS installation path is /opt/bin/gds. Exported data files are stored in /output_data/. The IP address of the data server is 192.168.0.90. The GDS monitoring port number is 5000. The GDS runs in the background.
    /opt/bin/gds/gds -d /output_data -p 192.168.0.90:5000 -H 10.10.0.1/24 -D
  5. In the database, create the foreign table foreign_tpcds_reasons for receiving data from the data server.

    Data export mode settings are as follows:

    • The directory for storing exported files is set to /output_data/ and the GDS listening port number is 5000 while GDS is started. The created directory for storing exported files is /output_data/. Therefore, set the location parameter to gsfs://192.168.0.90:5000/.

    Data format parameter settings are as follows:

    • format is set to CSV.
    • encoding is set to UTF-8.
    • delimiter is set to E'\x20'.
    • quote is set to 0x1b.
    • null is set to an empty string without quotation marks.
    • escape is set to a double quotation mark.
    • header is set to false, indicating that the first row is identified as a data row in an exported file.

    Based on the above settings, the foreign table is created using the following statement:

    1
    2
    3
    4
    5
    6
    openGauss=# CREATE FOREIGN TABLE foreign_tpcds_reasons
    (
      r_reason_sk    integer        not null,
      r_reason_id    char(16)       not null,
      r_reason_desc  char(100)
    ) SERVER gsmpp_server OPTIONS (LOCATION 'gsfs://192.168.0.90:5000/', FORMAT 'CSV',ENCODING 'utf8',DELIMITER E'\x20', QUOTE E'\x1b', NULL '') WRITE ONLY;
    
  6. In the database, export data to data files through the foreign table foreign_tpcds_reasons.
    1
    openGauss=# INSERT INTO foreign_tpcds_reasons SELECT * FROM reasons;
    
  7. After data export is complete, log in to the data server as user gds_user and stop GDS.
    The GDS process ID is 128954.
    ps -ef|grep gds
    gds_user 128954      1  0 15:03 ?        00:00:00 gds -d /output_data -p 192.168.0.90:5000 -D
    gds_user 129003 118723  0 15:04 pts/0    00:00:00 grep gds
    kill -9 128954

Example: Exporting Data Using Multiple Threads

As planned, a data server resides on the same intranet as a cluster, the IP address of the data server is 192.168.0.90, and data source files are in CSV format. In this scenario, data is concurrently exported to two target tables using multiple threads in Remote mode.

To concurrently export data using multiple threads in Remote mode, perform the following operations:

  1. Log in to the GDS data server and create a database user and its user group.
    groupadd gdsgrp
    useradd -g gdsgrp gds_user
  2. Switch to user gds_user and create the /output_data directory for storing exported files.
    su - gds_user
    mkdir -p /output_data
  3. Change the owner of the /output_data directory on the data server to gds_user.
    chown -R gds_user:gdsgrp /output_data 
  4. Log in to the data server as user gds_user and start GDS.
    The GDS installation path is /opt/bin/gds. Exported data files are stored in /output_data/. The IP address of the data server is 192.168.0.90. The GDS listening port number is 5000. The GDS runs in the background. The concurrency level is 2.
    /opt/bin/gds/gds -d /output_data -p 192.168.0.90:5000 -H 10.10.0.1/24 -D -t 2 
  5. In GaussDB, create the foreign tables foreign_tpcds_reasons1 and foreign_tpcds_reasons2 for receiving data from the data server.
    • Data export mode settings are as follows:
      • The directory for storing exported files is set to /output_data/ and the GDS listening port number is 5000 while GDS is started. The created directory for storing exported files is /output_data/. Therefore, the location parameter is set to gsfs://192.168.0.90:5000/.
    • Data format parameter settings are as follows:
      • format is set to CSV.
      • encoding is set to UTF-8.
      • delimiter is set to E'\x20'.
      • quote is set to 0x1b.
      • null is set to an empty string without quotation marks.
      • escape is set to a double quotation mark.
      • header is set to false, indicating that the first row is identified as a data row in an exported file.

    Based on the above settings, the foreign table foreign_tpcds_reasons1 is created using the following statement:

    1
    2
    3
    4
    5
    6
    openGauss=# CREATE FOREIGN TABLE foreign_tpcds_reasons1
    (  
      r_reason_sk    integer     not null,
      r_reason_id    char(16)    not null,
      r_reason_desc  char(100)
    ) SERVER gsmpp_server OPTIONS (LOCATION 'gsfs://192.168.0.90:5000/', FORMAT 'CSV',ENCODING 'utf8', DELIMITER E'\x20', QUOTE E'\x1b', NULL '') WRITE ONLY;
    

    Based on the above settings, the foreign table foreign_tpcds_reasons2 is created using the following statement:

    1
    2
    3
    4
    5
    6
    openGauss=# CREATE FOREIGN TABLE foreign_tpcds_reasons2
    (  
      r_reason_sk    integer     not null,
      r_reason_id    char(16)    not null,
      r_reason_desc  char(100)
    ) SERVER gsmpp_server OPTIONS (LOCATION 'gsfs://192.168.0.90:5000/', FORMAT 'CSV', DELIMITER E'\x20', QUOTE E'\x1b', NULL '') WRITE ONLY;
    
  6. In the database, export data from table reasons1 through the foreign table foreign_tpcds_reasons1 and from table reasons2 through the foreign table foreign_tpcds_reasons2 to /output_data.
    1
    openGauss=# INSERT INTO foreign_tpcds_reasons1 SELECT * FROM reasons1;
    
    1
    openGauss=# INSERT INTO foreign_tpcds_reasons2 SELECT * FROM reasons2;
    
  7. After data export is complete, log in to the data server as user gds_user and stop GDS.
    The GDS process ID is 128954.
    ps -ef|grep gds
    gds_user 128954      1  0 15:03 ?        00:00:00 gds -d /output_data -p 192.168.0.90:5000 -D -t 2 
    gds_user 129003 118723  0 15:04 pts/0    00:00:00 grep gds
    kill -9 128954

Example: Exporting Data in Local Mode

A cluster contains eight DNs and four physical nodes. Every two DNs reside on the same physical node. The cluster has sufficient disk space and the cluster node I/O performance is satisfactory. In this scenario, data is concurrently exported in Local mode.

To concurrently export data in Local mode, perform the following operations:

  1. Log in to a physical node, create the /output_data directory for storing data files, and change the owner of the directory to omm.
    All the following operations use a node with the IP address 192.168.0.11 as an example.
    mkdir -p /output_data
    chown -R omm:dbgrp /output_data 
  2. In the database, create the foreign table foreign_tpcds_reasons.
    • Data export mode settings are as follows:
      • The directory created in the previous step for storing data files is /output_data/. Therefore, the location parameter is set to file:///output_data/.
    • Data format parameter settings are as follows:
      • format is set to CSV.
      • encoding is set to UTF-8.
      • delimiter is set to E'\x20'.
      • quote is set to 0x1b.
      • null is set to an empty string without quotation marks.
      • escape is set to a double quotation mark.
      • header is set to false, indicating that the first row is identified as a data row in an exported file.

    Based on the above settings, the foreign table foreign_tpcds_reasons is created using the following statement:

    1
    2
    3
    4
    5
    6
    openGauss=# CREATE FOREIGN TABLE foreign_tpcds_reasons
    (  
      r_reason_sk    integer     not null,
      r_reason_id    char(16)    not null,
      r_reason_desc  char(100)
    ) SERVER gsmpp_server OPTIONS (LOCATION 'file:///output_data/', FORMAT 'CSV',ENCODING 'utf8', DELIMITER E'\x20', QUOTE E'\x1b', NULL '') WRITE ONLY;
    
  3. Export data in the database.
    1
    openGauss=# INSERT INTO foreign_tpcds_reasons SELECT * FROM reasons;
    
  4. View data files.

    The data files are generated in /output_data/YYYYMMDD/DN name on each cluster node. YYYYMMDD indicates the current system date. DN name can be found by running the following statement:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    openGauss=# SELECT node_name,node_host FROM pgxc_node WHERE node_type='D';
      node_name   |   node_host    
    --------------+----------------
     dn_6001_6002 | 192.168.0.11
     dn_6003_6004 | 192.168.0.11
     dn_6005_6006 | 192.168.0.12
     dn_6007_6008 | 192.168.0.12
     dn_6009_6010 | 192.168.0.13
     dn_6011_6012 | 192.168.0.13
     dn_6013_6014 | 192.168.0.14
     dn_6015_6016 | 192.168.0.14
    (8 rows)
    

    On the node whose IP address is 192.168.0.11, the names of DNs are dn_6001_6002 and dn_6003_6004. In this case, data files are generated in /output_data/20160101/dn_6001_6002 and /output_data/20160101/dn_6003_6004 on the node.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback