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
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
NoteTo view the mapping of the current ECS instance, run the
netsh interface portproxy show all
command.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
.NoteThe 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.
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
- 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.
Modify the configuration file. Version 0.73 is used in this example.
cd rinetd-0.73 vi rinetd.conf
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.
Run the rinetd -c rinetd.conf command to start rinetd.
NoteYou can also run the
echo rinetd -c rinetd.conf >>/etc/rc.local
command to enable auto-start for rinetd. To terminate port forwarding, run thepkill rinetd
command.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
.