。。可以使用java redis客户端(lettuce)从我的本地计算机连接到Amazon Elastic Cache吗?
我在安全组中定义了TCP端口6379和SSH端口22的入站规则。
我的连接代码是:
RedisClient redisClient = new RedisClient("CacheCluster Endpoint", 6379);
RedisConnection<String, String> connection = redisClient.connect();
connection.set("key", "Hello, Redis!");
connection.close();
redisClient.shutdown();我运行这个java,我得到:
Exception in thread "main" com.lambdaworks.redis.RedisConnectionException: Unable to connect to mycachecluster.b4ujee.0001.usw2.cache.amazonaws.com/172.31.34.211:6379
at com.lambdaworks.redis.AbstractRedisClient.initializeChannel(AbstractRedisClient.java:214)
at com.lambdaworks.redis.RedisClient.connectAsync(RedisClient.java:322)
at com.lambdaworks.redis.RedisClient.connectAsync(RedisClient.java:303)
at com.lambdaworks.redis.RedisClient.connect(RedisClient.java:259)
at com.lambdaworks.redis.RedisClient.connect(RedisClient.java:238)
at com.lambdaworks.redis.RedisClient.connect(RedisClient.java:222)
at project1.JavaRedis.main(JavaRedis.java:17)
Caused by: java.net.ConnectException: Connection timed out: no further information: mycachecluster.b4ujee.0001.usw2.cache.amazonaws.com/172.31.34.211:6379
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:574)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:289)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.lang.Thread.run(Thread.java:619)所以我的问题是:我做错了什么?我必须使用ClusterRedis EndPoint或EC2 DNS来建立连接吗?
请帮帮我!
谢谢!
发布于 2015-09-16 20:22:39
没有外网IP,无法接入。DNS名称解析为内网IP 172.31.34.211,只能从您的AWS VPC访问。
此外,为了连接,您需要使用DNS,而不是IP,因为节点的IP可能会更改。如果您需要在本地使用Redis进行开发,您可以轻松地在本地机器上安装一个实例。
发布于 2017-09-06 04:56:34
要做到这一点,如果您仍然希望从本地连接到亚马逊网络服务(redis),而无需在亚马逊网络服务中托管您的web服务,则最好的方法是通过ElastiCache。
我们使用https://pritunl.com来实现这一点,它非常容易配置和使用。
https://stackoverflow.com/questions/32608147
复制相似问题