Access ElastiCache memcache instance from local development environment

*爱你&永不变心* 提交于 2019-12-12 20:53:43

问题


Is there any way to access cache nodes from local development environment? Although the same cache nodes are accessible from EC2 instance.

I'm using Enyim memcache client library with C#. I found few article saying this is not possible then what should be best approach. Should i need to setup memcache locally for development work?


回答1:


When you create your Elastic Cache cluster, you have to define a Security Group. A Security group is a set of rules that define what IP addresses are authorised to connect to your cluster.

Should you want to connect to your cache cluster from your local machine, be sure to add a rule to authorise your local IP address to connect to the cluster (beware if you're behind a NATing gateway or a proxy, you need to use your external IP address and not your internal IP address)

Details are available at : http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/GettingStarted.CreateCacheCluster.html

Security Group is explained at : http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_SecurityGroups.html

--Seb




回答2:


According to Amazon, there is no accessing elasticache clusters from outside AWS:

...an Amazon ElastiCache Cluster, inside or outside a VPC, is never allowed to be accessed from the Internet.

From http://aws.amazon.com/elasticache/faqs/#Can_I_access_Amazon_ElastiCache_from_outside_AWS

Also see this question:

Can you connect to Amazon Elasticache Redis outside of Amazon




回答3:


You can create ssh tunnel:

$ ssh -nNT -L 11211:<elasticache instance public dns name>:11211 ubuntu@<ec2 instance> -i <path to your pem file>
  • -L means local port forwarding
  • -nNT means no tty allocated and no commands executed on remote side

for example:

$ ssh -nNT -L 11211:blah-blah.cfg.use1.cache.amazonaws.com:11211 ubuntu@ec2-54-254-254.compute-1.amazonaws.com -i ~/.ssh/mykey.pem

And in another console you can connect to localhost:

telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.


来源:https://stackoverflow.com/questions/22630124/access-elasticache-memcache-instance-from-local-development-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!