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

Using the gsql Client to Connect to a Cluster

Updated on 2023-03-17 GMT+08:00

This section describes how to connect to a database through an SQL client after you create a data warehouse cluster and before you use the cluster's database. GaussDB(DWS) provides the gsql client that matches the cluster version for you to access the cluster using the cluster's public or private network address.

Using the gsql CLI Client to Connect to a Cluster

  1. Prepare a Linux ECS to install and run the gsql client.

    For details, see Preparing an ECS as the gsql Client Host.

  2. Download the gsql client by referring to Downloading the Client, and use an SSH file transfer tool (such as WinSCP) to upload the client to a target Linux host.

    The user who uploads the client must have the full control permission on the target directory on the host to which the client is uploaded.

  3. Use the SSH tool to remotely log in to the host where the client is installed.

    For details about how to log in to an ECS, see "ECSs> Logging In to a Linux ECS > Login Using an SSH Password" in the Elastic Cloud Server User Guide.

  4. (Optional) To connect to the cluster in SSL mode, configure SSL authentication parameters on the host where the client is installed. For details, see Establishing Secure TCP/IP Connections in SSL Mode.

    NOTE:

    The SSL connection mode is more secure than the non-SSL mode. You are advised to connect the client to the cluster in SSL mode.

  5. Run the following commands to decompress the client:

    cd <Path for saving the client>
    unzip dws_client_8.1.x_redhat_x64.zip

    In the preceding commands:

    • <Path_for_storing_the_client>: Replace it with the actual path.
    • dws_client_8.1.x_redhat_x64.zip: This is the client tool package name of RedHat x86. Replace it with the actual name.

  6. Run the following command to configure the GaussDB(DWS) client:

    source gsql_env.sh

    If the following information is displayed, the GaussDB(DWS) client is successfully configured:

    All things done.

  7. Connect to the database in the GaussDB(DWS) cluster using the gsql client. Replace the values of each parameter with actual values.

    gsql -d <Database_name> -h <Cluster_address> -U <Database_user> -p <Database_port> -r

    The parameters are described as follows:

    • Database_name: Enter the name of the database to be connected. If you use the client to connect to the cluster for the first time, enter the default database gaussdb.
    • Cluster_address: For details about how to obtain this address, see Obtaining the Cluster Connection Address. If a public network address is used for connection, set this parameter to Public Network Address. If a private network address is used for connection, set this parameter to Private Network Address.
    • Database_user: Enter the username of the cluster's database. If you use the client to connect to the cluster for the first time, set this parameter to the default database administrator configured during cluster creation, for example, dbadmin.
    • Database_port: Enter the database port set during cluster creation.

    For example, run the following command to connect to the default database gaussdb in the GaussDB(DWS) cluster:

    gsql -d gaussdb -h 10.168.0.74 -U dbadmin -p 8000 -W password -r

    If the following information is displayed, the connection succeeded:

    1
    gaussdb=>
    

gsql Command Reference

For more information about the gsql commands, see the Data Warehouse Service (DWS) Tool Guide.

(Optional) Importing TPC-DS Sample Data Using gsql

GaussDB(DWS) users can import data from external sources to data warehouse clusters. This section describes how to import sample data from OBS to a data warehouse cluster and perform querying and analysis operations on the sample data. The sample data is generated based on the standard TPC-DS benchmark test.

TPC-DS is the benchmark for testing the performance of decision support. With TPC-DS test data and cases, you can simulate complex scenarios, such as big data set statistics, report generation, online query, and data mining, to better understand functions and performance of database applications.

  1. Use the SSH remote connection tool to log in to the host where the gsql client is installed and go to the gsql directory. The /opt directory is used as an example for storing the gsql client.

    cd /opt

  2. Switch to the specified directory and set the AK and SK for importing sample data and the OBS access address.

    If the following information is displayed, the settings are successful:

    setup successfully!
    NOTE:

    <Access_Key_Id> and <Secret_Access_Key>: indicate the AK and SK, respectively. For details about how to obtain the AK and SK, see "Data Import > Concurrently Importing Data from OBS > Creating Access Keys (AK and SK)" in the Data Warehouse Service (DWS) Developer Guide. Then, replace the parameters in the statements with the obtained values.

  3. Go back to previous directory and run the gsql environment variables.

    cd ..
    source gsql_env.sh
    cd bin

  4. Import the sample data to the data warehouse.

    Command format:

    gsql -d <Database name> -h <Public network address of the cluster> -U <Administrator> -p <Data warehouse port number> -f <Path for storing the sample data script> -r

    Sample command:

    gsql -d gaussdb -h 10.168.0.74 -U dbadmin -p 8000 -f /opt/sample/tpcds_load_data_from_obs.sql -r
    NOTE:

    In the preceding command, sample data script tpcds_load_data_from_obs.sql is stored in the sample directory (for example, /opt/sample/) of the GaussDB(DWS) client.

    After you enter the database administrator password and successfully connect to the database in the cluster, the system will automatically create a foreign table to associate the sample data outside the cluster. Then, the system creates a target table for saving the sample data and imports the data to the target table using the foreign table.

    The time required for importing a large dataset depends on the current GaussDB(DWS) cluster specifications. Generally, the import takes about 10 to 20 minutes. If information similar to the following is displayed, the import is successful.

    Time:1845600.524 ms

  1. In the Linux command window, run the following commands to switch to a specific directory and query the sample data:

    cd /opt/sample/query_sql/
    /bin/bash tpcds100x.sh

  2. Enter the cluster's public network IP address, access port, database name, user who accesses the database, and password of the user as prompted.

    • The default database name is gaussdb.
    • Use the database administrator username and password configured during cluster creation as the username and password for accessing the database.

    After the query is complete, a directory for storing the query result, such as query_output_20170914_072341, will be generated in the current query directory, for example, sample/query_sql/.

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