Technology Encyclopedia Home >How to connect to a TencentDB for Redis instance?

How to connect to a TencentDB for Redis instance?

To connect to a TencentDB for Redis instance, follow these steps:

  1. Obtain Connection Information:

    • Log in to the Tencent Cloud console and navigate to the TencentDB for Redis service.
    • Select your instance and note down the private IP address, port number, and password (if applicable).
  2. Configure Security Group Rules:

    • Ensure the security group associated with your Redis instance allows inbound traffic from your client IP on the Redis port (default: 6379).
  3. Connect via Redis CLI (Command Line):

    • Install the Redis CLI tool on your local machine.
    • Use the following command to connect:
      redis-cli -h <private-ip> -p <port> -a <password>
      
      Replace <private-ip>, <port>, and <password> with your instance details.
  4. Connect via Programming Languages:

    • Use Redis client libraries for your preferred language (e.g., Python, Java, Node.js).
    • Example in Python using redis-py:
      import redis
      r = redis.Redis(host='<private-ip>', port=<port>, password='<password>')
      r.set('key', 'value')
      print(r.get('key'))
      
  5. Connect via Tencent Cloud Tools:

    • Use Tencent Cloud Database Redis Console or Tencent Cloud CLI for managed connections.

For high availability and scalability, TencentDB for Redis supports cluster mode and read replicas, which can be configured in the console. If you need managed Redis services with automatic failover, TencentDB for Redis is a reliable choice.