Updated on 2024-02-08 GMT+08:00

Connecting to an Instance Using an EIP

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

This section uses the Linux OS as an example to describe how to connect to a GeminiDB Redis instance using the Redis-cli client. You can connect to a DB instance through an unencrypted connection or an encrypted connection (SSL). The SSL connection encrypts data and is more secure.

If you need to access GeminiDB Redis instances over a public network, use a public domain name to ensure instance reliability.

Precautions

  • The SSL connection is in the open beta test (OBT) phase. To use this mode, contact customer service.
  • After the SSL connection is enabled, download the SSL certificate for your applications to access to the GeminiDB Redis instance.
  • If the SSL connection is used, ensure that the Redis client, for example, Redis-cli 6.x, supports SSL.
  • To connect to a DB instance through an unencrypted connection, the SSL connection must be disabled. For details about how to disable SSL, see Configuring an SSL Connection.
  • You need to estimate the bandwidth required by services and purchase an EIP with sufficient bandwidth resources. Client access exceptions caused by poor public network performance will not be included in the SLA.

Prerequisites

  1. 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.
  2. Bind an EIP to the instance node and configure security group rules. For details, see Binding and Unbinding an EIP and Configuring Security Group Rules.

    A GeminiDB Redis instance has multiple nodes. Select any node and bind an EIP to it.

SSL (Recommended)

  1. Log in to the ECS. For details, see Logging In to an ECS in Getting Started with Elastic Cloud Server.
  2. Obtain the Redis client.

    Method 1

    Run the following command to download the Redis client.

    wget https://download.redis.io/releases/redis-6.2.6.tar.gz

    Method 2

    Download the Redis client installation package and upload it to the ECS.

  3. Obtain the SSL certificate.

    Method 1: Click the target instance name. On the Basic Information page, in the DB Information area, click the download button in the SSL field to obtain the SSL certificate.

    Figure 1 Obtaining the SSL certificate

    Method 2: Click the target instance. On the Basic Information page, choose Connections. In the Basic Information area, click the download button in the SSL field to download the SSL certificate.

    Figure 2 Obtaining the SSL certificate

  4. Upload the SSL certificate to the ECS.
  5. Check the OpenSSL version supported by the ECS OS.

    openssl version

    • The SSL function provided by GeminiDB Redis API supports only TLS 1.3 or later.
    • The OpenSSL version in the ECS OS must be 1.1.1 or later so that redis-cli can support TLS 1.3 or later.
    • If the OS version is earlier than 1.1.1, perform the following steps to install OpenSSL:

      wget https://www.openssl.org/source/openssl-1.1.1m.tar.gz

      tar -zxvf openssl-1.1.1m.tar.gz

      cd openssl-1.1.1m/

      ./config --prefix=/usr/local/openssl-1.1.1m_install_dir

      make

      make install

      After OpenSSL is installed, go to 6.

    • If the OS is 1.1.1 or later, go to 6.

  6. Decompress the client tool package.

    tar -xzf redis-6.2.6.tar.gz

  7. Connect to the DB instance in the src directory.

    • If the required OpenSSL version has been installed by performing 5 and the version is earlier than 1.1.1, you can connect to the DB instance using the following method:

      cd redis-6.2.6

      make BUILD_TLS=yes OPENSSL_PREFIX=/usr/local/openssl-1.1.1m_install_dir

      cd src

      LD_PRELOAD=/usr/local/openssl-1.1.1m_install_dir/lib/libssl.so.1.1:/usr/local/openssl-1.1.1m_install_dir/lib/libcrypto.so.1.1 ./redis-cli -h <DB_HOST> -p <DB_PORT> -a <DB_PWD> --tls --cacert <CACERT_PATH>

      Example:

      LD_PRELOAD=/usr/local/openssl-1.1.1m_install_dir/lib/libssl.so.1.1:/usr/local/openssl-1.1.1m_install_dir/lib/libcrypto.so.1.1 ./redis-cli -h 192.168.0.208 -p 8635 -a <DB_PWD> --tls --cacert ./cacert.crt

    • If the OpenSSL version in the ECS OS is 1.1.1 or later, you can connect to the DB instance using the following method:

      cd redis-6.2.6

      make BUILD_TLS=yes

      cd src

      ./redis-cli -h <DB_HOST> -p <DB_PORT> -a <DB_PWD> --tls --cacert <CACERT_PATH>

      Example:

      ./redis-cli -h 192.168.0.208 -p 8635 -a <DB_PWD> --tls --cacert ./cacert.crt

    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 instance.

    If a message is displayed indicating that no EIP has been bound to the instance, bind an EIP to the instance by referring to Binding and Unbinding an EIP.

    <DB_PORT>

    Port for accessing the target instance. Configure this parameter based on service requirements.

    To obtain the instance port number, perform the following steps:

    Click the target instance to go to the Basic Information page. In the Network Information area, you can find the database port.

    <DB_PWD>

    Specifies the administrator password set when you buy a GeminiDB Redis instance.

    <CACERT_PATH>

    The path of the SSL certificate.

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

    IP:port>

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. Obtain the Redis client.

    Method 1

    Run the following command to download the Redis client.

    wget http://download.redis.io/releases/redis-5.0.7.tar.gz

    Method 2

    Download the Redis client installation package and upload it to the ECS.

  3. Decompress the client tool package.

    tar -xzf redis-5.0.7.tar.gz

  4. Connect to the DB instance in the src directory.

    cd redis-5.0.7

    make

    cd src

    ./redis-cli -h <DB_HOST> -p <DB_PORT> -a <DB_PWD>

    Example:

    ./redis-cli -h 192.168.0.208 -p 8635 -a <DB_PWD>

    Table 2 Parameter description

    Parameter

    Description

    <DB_HOST>

    Specifies the EIP of 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 instance.

    If a message is displayed indicating that no EIP has been bound to the instance, bind an EIP to the instance by referring to Binding and Unbinding an EIP.

    <DB_PORT>

    Port for accessing the target instance. Configure this parameter based on service requirements.

    To obtain the instance port number, perform the following steps:

    Click the target instance to go to the Basic Information page. In the Network Information area, you can find the database port.

    <DB_PWD>

    Specifies the administrator password set when you buy a GeminiDB Redis instance.

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

    IP:port>