Buying a GaussDB Instance and Connecting to It Using gsql
This section describes how to use the gsql client to connect to a GaussDB instance you have bought on the GaussDB management console. For more methods of connecting to an instance, see GaussDB Instance Connection.
Operation Process
Step |
Description |
---|---|
Configure basic information about a GaussDB instance and submit the purchase request. |
|
Buy an ECS that is in the same region and VPC as your GaussDB instance. |
|
Use gsql to connect to GaussDB. |
Buying an Instance
- Log in to the management console.
- Click
in the upper left corner and select a region and project.
- Click
in the upper left corner of the page and choose .
- On the Instances page, click Buy DB Instance.
- On the displayed page, enter DB Instance Name, select DB Engine Version, DB Instance Type, and Deployment Model, and complete other configurations.
Table 1 Parameters Parameter
Example Value
Description
Billing Mode
Pay-per-use
GaussDB provides yearly/monthly billing and pay-per-use billing.
- Yearly/Monthly: You pay upfront for the amount of time you expect to use the DB instance for. You will need to make sure you have a top-up account with a sufficient balance or have a valid payment method configured first.
- Pay-per-use: You can start using the DB instance first and then pay as you go. Pricing is listed on a per-hour basis, but bills are calculated based on the actual usage duration.
Region
EU-Dublin
Region where the tenant is located.
Products in different regions cannot communicate with each other over a private network. After the instance is created, you cannot change its region.
DB Instance Name
gauss-d0a7
The instance name is case-sensitive, must start with a letter, and can contain 4 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.
Edition Type
Enterprise edition
GaussDB provides Basic edition and Enterprise edition.
The basic edition lacks certain advanced features that are available in the enterprise edition. The basic edition delivers the same level of performance as the enterprise edition at a more affordable price. This edition is ideal for users who prioritize cost and do not need advanced features.
DB Engine Version
V2.0-8.103
GaussDB database version.
DB Instance Type
Centralized
- Distributed: You can add nodes for distributed instances as needed to handle large volumes of concurrent requests.
- Centralized: Centralized instances are suitable for scenarios with small and stable volumes of data, where data reliability and service availability are extremely important.
Deployment Model
1 primary + 2 standby
- Distributed
- Independent: Database components are deployed on different nodes. This model is suitable for where high availability and stability are required and the instance scale is large.
- Centralized
- HA (1 primary + 2 standby): 3-node deployment where there is one shard. The shard contains one primary DN and two standby DNs.
- Single: single-node deployment where there is only one CMS component and one DN. This model is only available for instances of V2.0-2.2 or later.
AZ
AZ1
An AZ is a physical region where resources have independent power supply and networks. AZs are physically isolated but interconnected through an internal network.
Time Zone
(UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
You need to select a time zone for your instance based on the region it is hosted in.
- Configure instance specifications.
Table 2 Parameters Parameter
Example Value
Description
Instance Specifications
Dedicated(1:4), 4 vCPUs | 16 GB
The vCPUs and memory of an instance.
Storage Type
Ultra-high I/O
The storage type determines the read/write speed of an instance. The higher the maximum throughput is, the higher the instance read/write speed can be.
Storage Space
40 GB
The storage space contains the file system overhead required for inodes, reserved blocks, and database operations.
Disk Encryption
Disable
Enabling disk encryption improves data security, but slightly affects the read and write performance of the database.
- Retain the default settings for the network information.
- Configure the instance password.
Table 3 Parameters Parameter
Example Value
Description
Administrator Password
-
Enter a strong password and periodically change it to improve security, preventing security risks such as brute force cracking.
Confirm Password
-
Enter the administrator password again.
Enterprise Project
default
If the instance has been associated with an enterprise project, select the target project from the Enterprise Project drop-down list.
You can also go to the Enterprise Project Management console to create a project. .
- Click Create Now, confirm the instance information, and click Submit.
- Go to the instance list.
If status of the instance becomes Available, the instance has been created.
Buying an ECS
GaussDB provides the gsql tool to help you connect to a database using the command-line interface (CLI). Before the connection, you need to create an ECS for installing the gsql tool.
- Log in to the management console.
- Click
in the upper left corner of the page and choose to go to the Elastic Cloud Server console.
- On the page that is displayed, click Buy ECS.
- Configure basic settings and click Next: Configure Network.
- Region: Select the region of the GaussDB instance to be connected.
- Billing Mode: Pay-per-use
- AZ: Select the AZ of the GaussDB instance to be connected.
- Image: EulerOS and EulerOS 2.5 64bit(40 GiB)
- Retain the default values for other parameters.
- Configure the ECS network and click Next: Configure Advanced Settings.
- Network: Select the VPC of the GaussDB instance to be connected.
- Security Group: Select the security group of the GaussDB instance to be connected.
- EIP: Not required
- Configure a password for the ECS, set other parameters as required, and click Next: Confirm.
- ECS Name: Enter a name that is easy to identify.
- Password: Set a strong password to improve security.
- Confirm Password: Enter the password again.
- Retain the default values for other parameters.
- Confirm the configuration and click Submit.
- View the ECS.
- Log in as the root user to the ECS you have created.
- Upload the client tool package and configure gsql environment variables.
- Run the following command to create the /tmp/tools directory for storing the client tool package:
mkdir /tmp/tools
- Download the GaussDB_driver.zip driver package of the required version, and upload it to the /tmp/tools directory of the created ECS.
- Run the following commands to decompress the GaussDB_driver.zip driver package:
cd /tmp/tools unzip GaussDB_driver.zip
- Run the following commands to copy the decompressed GaussDB-Kernel_***_EULER_64bit-Gsql.tar.gz client tool package to the /tmp/tools directory:
This section uses the gsql tool package suitable for the centralized instances running on Euler2.5_x86_64 as an example. The relative path of the tool package varies depending on where you decompressed it.
cd /tmp/tools/GaussDB_driver/Centralized/Euler2.5_X86_64/ cp GaussDB-Kernel_***_EULER_64bit-Gsql.tar.gz /tmp/tools
- Run the following commands to decompress the package:
cd /tmp/tools tar -zxvf GaussDB-Kernel_***_EULER_64bit-Gsql.tar.gz
- Configure environment variables.
Run the following command to open the ~/.bashrc file:
vim ~/.bashrc
Press G to move the cursor to the last line, press i to enter Insert mode, and type the following information. Then, press Esc to exit Insert mode, and run :wq to save the settings and exit.
export PATH=/tmp/tools/bin:$PATH export LD_LIBRARY_PATH=/tmp/tools/lib:$LD_LIBRARY_PATH
Run the following command to make the environment variables take effect permanently:source ~/.bashrc
- Run the following command to create the /tmp/tools directory for storing the client tool package:
- Enter the password when prompted to connect to the database.
After an instance is created, a postgres database is generated by default. Database postgres is used as an example.
gsql -d postgres -h 10.0.0.0 -U root -p 8000 Password for user root:
- postgres indicates the name of the database to be connected.
- 10.0.0.0 indicates the IP address of the instance. On the Basic Information page of the instance to be connected, obtain the private IP address in the Connection Information area.
- root indicates the username used to log in to the database.
- 8000 indicates the port number of the database. On the Basic Information page of the instance to be connected, obtain the database port in the Connection Information area.
- Log in to the management console.
- Click
in the upper left corner and select a region and project.
- Click
in the upper left corner of the page and choose .
- On the Instances page, click the name of the target instance. In the DB Information area on the Basic Information page, click
next to the SSL field to download the root certificate or certificate bundle.
- Upload the root certificate to the ECS or save it to the device to be connected to the GaussDB instance.
Import the root certificate to the Linux ECS. You can use a connection tool (such as WinSCP or PuTTY) to upload the certificate to any directory on a Linux server.
- Connect to a GaussDB instance.
A Linux ECS is used in this example. Run the following command to set environment variables on the ECS:
export PGSSLMODE=<sslmode> export PGSSLROOTCERT=<ca-file-directory>
gsql -h <host> -p <port> -d <database> -U <user>
Example:
export PGSSLMODE="verify-ca" export PGSSLROOTCERT="/home/Ruby/ca.pem"
gsql -h 10.0.0.0 -p 8000 -d postgres -U root
Password for user root:
Table 4 Parameter description Parameter
Description
<host>
IP address of the DB instance. To obtain the IP address, click the instance name on the Instances page to go to the Basic Information page of the instance. The IP address can be found in the Private IP Address field of the Connection Information area if the DB instance is accessed through an ECS.
<port>
Database port number. The default value is 8000. To obtain the database port, click the instance name on the Instances page to go to the Basic Information page of the instance. The database port can be founded in the Database Port field of the Connection Information area.
<database>
Name of the database to connect to. The default database is postgres.
<user>
Username of the GaussDB database account. The default administrator is root.
<ca-file-directory>
Directory of the CA certificate for SSL connection.
<sslmode>
SSL connection mode. Set it to verify-ca to verify that the server is trustworthy by checking the certificate chain.
- Check the command output after you log in to the database. If information similar to the following is displayed, the SSL connection has been established.
SSL connection (cipher: DHE-RSA-AES256-GCM-SHA384, bits: 256)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.