Example 2: Importing Data in Shared Mode
- Prepare for data import.
This section assumes that a source data file foreign_tpcds_reasons.dat.0 in text format is stored in the /input_data directory on the 192.168.0.90 server.
- Configure the NFS service on the data server. For details, see SUSE DOC: Administration Guide – Configuring NFS Server.
The security of the NFS service and data transmission is ensured by users. You are advised to use the NFS service in a trusted domain.
- Start the NFS service on the data server.
service nfs start
- Log in as a common user to each server where GaussDB DNs reside, create the /input_data directory on each server, and mount each data server storing source data files to this directory.
cd /input_data mount -t nfs 192.168.0.90:/input_data /input_data
- Configure the NFS service on the data server. For details, see SUSE DOC: Administration Guide – Configuring NFS Server.
- Log in as the OS user omm to the host where the CN is located.
- 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=#
- 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) );
- Create the foreign table foreign_tpcds_reasons for the source data.
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:///input_data/foreign_tpcds_reasons.dat.0', format 'TEXT', mode 'shared', delimiter E'\x20', NULL '');
- Import data to the reasons table.
1
openGauss=# INSERT INTO reasons SELECT * FROM foreign_tpcds_reasons;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot