如何连接到部署在Google Cloud上的redis? [英] How to connect to redis deployed on Google Cloud?

查看:681
本文介绍了如何连接到部署在Google Cloud上的redis?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

案例基础:
在Google Cloud中部署了一个redis实例(单实例)。使用基于NodeJS的服务器和redis-sentinel库连接到节点。原因是在Google Cloud上基于标记的节点管理。



我可以通过仪表板/控制台的SSH登录登录redis实例。使用redis-cli连接到redis的本地运行服务,并可以创建/编辑各种数据集。



问题:当我尝试通过本地主机或任​​何其他计算机访问它时实例部署在同一个项目域中。我使用公共IP和端口26379/6379进行连接,但连接被拒绝。



可能的原因:


  • 网络访问政策。


解决方案

上周为自己起见,想分享我在这里学到的教训。希望这是有帮助的,即使这已经晚了近一年:)



我使用的是点击部署方案,发现这里(Redis by Redis,而不是Bitnami),它允许奇数个虚拟机作为群集。



创建部署后,我必须在每个虚拟机上执行以下手动步骤以使其可用作哨兵集群:


  • redis-cli 并运行 CONFIG SET保护模式no CONFIG REWRITE 。这会将redis服务器暴露给外部连接。

  • >并添加保护模式否,所以哨兵也可以互相连接 c> sudo /etc/init.d/redis-sentinel start 启动sentinel服务


  • redis-cli -p 26379 并通过运行 sentinel ckquorum master 来检查sentinel状态。预计会看到'OK X可用的Sentinels',X表示您在群集中拥有的虚拟机数量。




剩菜:


  • redis-sentinel 不作为服务运行。需要添加到 /etc/rc?.d 旁边 redis-server

  • /etc/init.d/redis- {server,sentinel} 不会被编写为正确的Debian服务,因此一旦死亡就不会重新生成。



总体而言,该产品非常失望,期待更完整的设置。

Case Basics: Deployed a redis instance (single instance) in Google Cloud. Using NodeJS based server and redis-sentinel library to connect to the node. Reason being sentinel based management of nodes on google cloud.

I can login in the redis instance via dashboard/console's SSH login. Connect to the local running service of redis using redis-cli and can create/edit various datasets.

Issue: When i try to access it via my localhost or any other compute instance deployed within the same project domain. I am using public ip and port 26379/6379 for the connection but connection is being refused.

Possible reasons:

  • Network access policies.

解决方案

Struggled to set this up for myself last week, wanted to share the lessons I learnt here. Hope this is helpful, even if this is almost a year late :)

I was using a click-to-deploy scheme found here (Redis by Redis, not Bitnami), which allows an odd number of VMs to serve as a cluster.

Once the deployment is created, I had to perform the following manual steps on each VM to make it usable as a sentinel cluster:

  • redis-cli and run CONFIG SET protected-mode no and CONFIG REWRITE. This will expose the redis server to external connections.

  • sudo vi /etc/redis/sentinel.conf and add protected-mode no so sentinels can also connect to each other

  • sudo /etc/init.d/redis-sentinel start to start the sentinel service

  • redis-cli -p 26379 and check sentinel status by running sentinel ckquorum master. Expect to see 'OK X usable Sentinels', X being the number of VMs you have in the cluster.

Leftovers:

  • redis-sentinel DOES NOT run as a service. Need to be added to /etc/rc?.d alongside redis-server
  • /etc/init.d/redis-{server,sentinel} are not written as proper Debian services, hence they do not respawn once killed.

Overall very disappointed in this offering, was expecting a more finished setup.

这篇关于如何连接到部署在Google Cloud上的redis?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆