Using ELB for Public Access to DCS
Currently, DCS Redis 4.0, 5.0, and 6.0 instances cannot be bound with elastic IP addresses (EIPs) and cannot be accessed over public networks directly. This section describes how to access a single-node, master/standby, read/write splitting, or Proxy Cluster instance or a node in a Redis Cluster instance through public networks by enabling cross-VPC backend on a load balancer.
- Due to cluster node address translation, you cannot access a Redis Cluster as a whole. You can only access individual nodes in the cluster.
- Do not use public network access in the production environment. Client access exceptions caused by poor public network performance will not be included in the SLA.
Solution Design​
The following figure shows the process for accessing DCS through ELB.
Prerequisites​
- Create a VPC or use an existing one.
- Create a DCS Redis instance. Record the IP address and port number of the instance.
- Create a dedicated load balancer.
- A shared load balancer does not support cross-VPC backend servers. Therefore, it cannot be bound to a DCS instance.
- For Specification, select Network load balancing (TCP/UDP).
- To access the DCS instance over public networks, enable IP as a Backend when creating a dedicated load balancer.
-
Add a TCP listener to the dedicated load balancer.
note- When adding a backend server, click the IP as Backend Servers tab and then click Add IP as Backend Sever.
- In the Backend Server IP Address Column, enter the IP address and in the Backend Port Column, enter the port number of your DCS instance.
- A Redis Cluster DCS instance contains multiple master/replica pairs. When configuring an IP as Backend server, you can add the IP address and port number of any master or replica node.
- If you enable Health Check, you do not need to manually configure the port. By default, the service port of the backend server will be used.
-
Create a VPC peering connection. For the local VPC, select the VPC where your load balancer is located. For the peer VPC, select the VPC where your DCS instance is located.
noteEven if your load balancer and DCS instance are in the same VPC, you still need to create a VPC peering connection. For the local VPC, select the VPC where your load balancer and DCS instance are located. For the peer VPC, select another VPC.
-
Click the name of the VPC peering connection to go to its details page. Obtain Local VPC CIDR Block and Peer VPC CIDR Block.
-
Configure local and peer routes for the VPC peering connection.
a. On the Local Routes and Peer Routes tab pages, click the link to go to the Route Tables page.
b. Local route: On the summary page of local routes, click Add Route. In the displayed Add Route dialog box, set Destination to the value of Peer VPC CIDR Block of the VPC peering connection, set Next Hop Type to VPC peering connection, set Next Hop to the VPC peering connection created in
5 <dcs-bp-211201001__li782011051412>
, and click OK.c. Peer route: On the summary page of peer routes, click Add Route. In the displayed Add Route dialog box, set Destination to the value of Local VPC CIDR Block of the VPC peering connection, set Next Hop Type to VPC peering connection, set Next Hop to the VPC peering connection created in
5 <dcs-bp-211201001__li782011051412>
, and click OK.noteIf the load balancer and the DCS instance are in the same VPC, you do not need to add a peer route. :::
-
Perform a health check on the IP address of the DCS instance. If the health check result is
Healthy
, the added cross-VPC backend IP address can be used.a. In the navigation pane of Network Console, choose Elastic Load Balance -> Load Balancers. b. Click the name of the created Elastic Load Balancer. c. On the Backend Server Server Groups -> IP as Backend Servers tab page, view the health check result of the DCS instance IP address.
Connecting to the DCS Instance Through ELB​
-
Connecting to a node in a Redis Cluster DCS instance through ELB a. View the basic information of the load balancer created in
3 <dcs-bp-211201001__li185984400426>
.b. Create an ECS, log in to it, and install the Redis client by referring to redis-cli.
c. On the Redis client, connect to the DCS instance using the IP address and port number configured in
4 <dcs-bp-211201001__li2180434205513>
. If you use the EIP and port number of the load balancer, an error will be reported. -
Connecting to a single-node, master/standby, read/write splitting, or Proxy Cluster DCS instance through ELB a. View the IPv4 EIP and port number of the load balancer created in
3 <dcs-bp-211201001__li185984400426>
.b. Create an ECS, log in to it, and install the Redis client by referring to redis-cli.
c. Use redis-cli to access the load balancer using its EIP and port number (which is
80
).d. Write a key through ELB.
e. Log in to the DCS console. On the Cache Manager page, choose More -> Connect to Redis in the row that contains the DCS instance created in
2 <dcs-bp-211201001__li145661168417>
. Check whether the key written in4 <dcs-bp-211201001__li352815512015>
exists.