All Products
Search
Document Center

ApsaraDB for Memcache:Use a public endpoint to connect to an ApsaraDB for Memcache instance

Last Updated:May 19, 2022

You can connect to an ApsaraDB for Memcache instance from an Elastic Compute Service (ECS) instance over an internal network. To connect to an ApsaraDB for Memcache instance from an on-premises machine over the Internet, you can configure port forwarding on the ECS instance.

Procedure for Windows ECS instances

  1. Log on to the ECS instance and run the following command in the specified format:

    netsh interface portproxy add v4tov4 listenaddress=Public IP address of the ECS instance listenport=11211 connectaddress=Endpoint of the ApsaraDB for Memcache instance connectport=11211
    1.png
    Note

    To view the mapping of the current ECS instance, run the netsh interface portproxy show all command.

  2. On your on-premises machine, connect to the ApsaraDB for Memcache instance by running the telnet command, write data to the instance, and verify the result by querying the data.

    For example, if the IP address of the ECS instance is 1.1.*.*, you can run telnet 1.1.*.* 11211.

    Note

    The portproxy feature provided by Microsoft is not an open source program. For more information about issues related to this feature, see the netsh interface portproxy document or contact Microsoft customer service. You can also use other solutions such as portmap.

  3. Optional. To delete port forwarding rules, run the following command in the specified format:

    netsh interface portproxy delete v4tov4 listenaddress=Public IP address of the ECS instance listenport=11211

Procedure for Linux ECS instances

  1. Log on to the ECS instance, and download and install rinetd. For more information, see rinetd.
    Warning

    rinetd.com is not the official site of rinetd. If you download rinetd from this website, the program may contain security risks such as a backdoor. We recommend that you reinstall the program at the earliest opportunity and check for risks. For example, you can run a virus scan.

  2. Modify the configuration file. Version 0.73 is used in this example.

    cd rinetd-0.73
    vi rinetd.conf
  3. Enter the following content in the required format in the configuration file and save the settings:

    0.0.0.0 11211 The internal endpoint of the ApsaraDB for Memcache instance 11211
    allow *.*.*.*

    The following figure shows an example.

  4. Run the rinetd -c rinetd.conf command to start rinetd.

    Note

    You can also run the echo rinetd -c rinetd.conf >>/etc/rc.local command to enable auto-start for rinetd. To terminate port forwarding, run the pkill rinetd command.

  5. On your on-premises machine, connect to the ApsaraDB for Memcache instance by running the telnet command, write data to the instance, and verify the result by querying the data.

    For example, if the IP address of the ECS instance is 1.1.*.*, you can run telnet 1.1.*.* 11211.