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
On this page

Show all

Example 3: Importing Data in Private Mode

Updated on 2024-10-14 GMT+08:00
A cluster has four hosts and eight primary DNs and every two primary DNs reside on the same host. There are eight data files to import and the size of each file is 50 MB. The files are in CSV format.
  1. Log in as the OS user omm to the host where the CN is located.
  2. Run the following command to connect to the database:
    gsql -d postgres -p 8000

    postgres is the name of the database, and 8000 is the port number of the CN.

    If information similar to the following is displayed, the connection succeeds:

    gsql((GaussDB Kernel VxxxRxxxCxx build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
    Non-SSL connection (SSL connection is recommended when requiring high-security)
    Type "help" for help.
    
    openGauss=# 
  3. Query DN names on each node.
    1
    openGauss=# SELECT node_name,node_host FROM pgxc_node WHERE node_type='D';
    

    Example:

     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)
    
  4. Upload the source data files to the nodes where DNs are located.
    1. Log in to each cluster node as a common user. Create the /input_data directory to store data files and create sub-directories named after DNs on each node.

      The following uses the node with the IP address 192.168.0.11 which is queried in 3 as an example. Two DNs, dn_6001_6002 and dn_6003_6004, are on the node.

      mkdir -p /input_data
      mkdir -p /input_data/dn_6001_6002
      mkdir -p /input_data/dn_6003_6004
    2. Evenly distribute source data files to the sub-directories created on each node.
    3. Change the owner of data source files to be imported and the /input_data directory on each cluster node to omm.
      chown -R omm:dbgrp /input_data
  5. Create the target table reasons.
    1
    2
    3
    4
    5
    6
    openGauss=# CREATE TABLE reasons
    (
      r_reason_sk integer not null,
      r_reason_id char(16) not null,
      r_reason_desc char(100)
    );
    
  6. Create the foreign table foreign_tpcds_reasons for the source data.

    Set import mode parameters as follows:

    • Set the import mode to Private.
    • The source data files are stored in sub-directories named after DNs on the nodes, and can be locally accessed. Therefore, set location to file:///input_data/*.

    Information about the data format is set based on data format parameters specified during data export. The parameter settings are as follows:

    • format is set to CSV.
    • delimiter is set to a comma (,).
    • quote is set to 0x1b.
    • null is set to an empty string without quotation marks.

    Set import error tolerance parameters as follows:

    • Set PER NODE REJECT LIMIT (number of allowed data format errors) to unlimited. In this case, all the data format errors detected during data import will be tolerated.
    • Set LOG INTO to err_tpcds_reasons. The data format errors detected during data import will be recorded in the err_tpcds_reasons table.
    1
    2
    3
    4
    5
    6
    7
    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:///input_data/*', format 'CSV', mode 'private', delimiter ',', quote E'\x1b', null '')LOG INTO err_tpcds_reasonS PER NODE REJECT LIMIT 'unlimited';
    
  7. Import data to the reasons table.
    1
    openGauss=# INSERT INTO reasons SELECT * FROM foreign_tpcds_reasons;
    
  8. Query data import errors in the err_tpcds_reasons table and rectify the errors (if any). For details, see Handling Import Errors.
    1
    openGauss=# SELECT * FROM err_tpcds_reasons;
    

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