Updated on 2023-11-21 GMT+08:00

Connecting to an Instance over a Public Network

You can use an ECS or local device to connect to a GeminiDB Cassandra instance over a public network.

This section describes how to use a Linux ECS to connect to a GeminiDB Cassandra instance over a public network.

You can use a common connection or establish a secure connection with SSL if necessary.

Prerequisites

  1. Bind an EIP to the GeminiDB Cassandra instance node and set security group rules. For details, see Binding and Unbinding an EIP and Configuring Security Group Rules.
  2. An ECS has been created. The following uses a Linux ECS as an example. For details, see Purchasing an ECS in Getting Started with Elastic Cloud Server.
  3. Download and install the Cassandra client that matches the CPU type of the ECS.
  4. Before accessing an instance using an SSL connection, obtain the SSL certificate by referring to Downloading the SSL Certificate.

Non-SSL Connection

  1. Log in to the ECS. For details, see Logging In to an ECS in Getting Started with Elastic Cloud Server.
  2. Upload the Cassandra client installation package to the ECS.
  3. Run the following command to decompress the client installation package. The x86 client is used as an example.

    unzip Cassandra_cqlsh_x86_64.zip

  4. Run the following command to grant the execute permission on all files:

    chmod +x *

  5. Connect to the DB instance in the directory where the cqlsh tool is located.

    ./cqlsh <DB_HOST> <DB_PORT> -u <DB_USER>

    Example:

    ./cqlsh 192.xx.xx.xx 8635 -u rwuser

    Table 1 Parameter description

    Parameter

    Description

    <DB_HOST>

    Specifies the EIP bound to the instance to be connected.

    To obtain the EIP, go to the Instance Management page and click the target instance name. The EIP can be found in the EIP column in the Node Information area on the Basic Information page.

    If the instance you bought has multiple nodes, you can bind the EIP to any node to connect to the GeminiDB Cassandra instance.

    Figure 1 Viewing EIPs

    If there are no EIPs bound to the instance, bind an EIP to the instance by referring to Binding and Unbinding an EIP and then connect to the instance.

    <DB_PORT>

    Port number of the instance to be connected. The default port number is 8635. Replace it with the actual port number.

    Click the instance name to go to the Basic Information page and obtain the port number in the Network Information area.

    Figure 2 Viewing the port number

    <DB_USER>

    Database account. The default value is rwuser.

  6. Check the results. If the following information is displayed, the connection is successful.

    rwuser@cqlsh>

SSL Connection

  1. Log in to the ECS. For details, see Logging In to an ECS in Getting Started with Elastic Cloud Server.
  2. Upload the Cassandra client installation package to the ECS.
  3. Upload the SSL certificate to the ECS.
  4. Run the following command to decompress the client installation package. The x86 client is used as an example.

    unzip Cassandra_cqlsh_x86_64.zip

  5. Run the following command to grant the execute permission on all files:

    chmod +x *

  6. Connect to the DB instance in the directory where the cqlsh tool is located.

    export SSL_CERTFILE=/<PATH_OF_SSL_CERT_FILE>

    export SSL_VERSION=TLSv1_2

    ./cqlsh <DB_HOST> <DB_PORT> --ssl -u <DB_USER>

    Example:

    ./cqlsh 192.168.1.8 8635 --ssl -u rwuser

    Table 2 Parameter description

    Parameter

    Description

    <PATH_OF_SSL_CERT_FILE>

    The path of the SSL certificate.

    <DB_HOST>

    Specifies the EIP bound to the instance to be connected.

    To obtain the EIP, go to the Instance Management page and click the target instance name. The EIP can be found in the EIP column in the Node Information area on the Basic Information page.

    If the instance you bought has multiple nodes, you can bind the EIP to any node to connect to the GeminiDB Cassandra instance.

    Figure 3 Viewing EIPs

    If there are no EIPs bound to the instance, bind an EIP to the instance by referring to Binding and Unbinding an EIP and then connect to the instance.

    <DB_PORT>

    Port number of the instance to be connected. The default port number is 8635. Replace it with the actual port number.

    Click the instance name to go to the Basic Information page and obtain the port number in the Network Information area.

    Figure 4 Viewing the port number

    <DB_USER>

    Database account. The default value is rwuser.

  7. Check the results. If the following information is displayed, the connection is successful.

    rwuser@cqlsh>

Follow-up Operations

After logging in to the instance, you can create keyspaces, databases, or tables. For details, see Buying and Connecting to a GeminiDB Cassandra Instance.