简体   繁体   English

如何在Redis集群中拆分数据?

[英]How can i split data in redis cluster?

Is there any possibility to split the data in the redis cluser. 是否有可能在redis cluser中拆分数据。 If there are multiple application using the same redis cluster, would there any possibility to split the key value pair based on application name. 如果有多个使用同一Redis集群的应用程序,则有可能根据应用程序名称拆分键值对。 One way i could see is using database select in the redis, but it don't work in the redis cluster. 我可以看到的一种方法是在Redis中使用数据库选择,但是它在Redis集群中不起作用。 can you please suggest any other approach. 您能建议其他方法吗?

Indeed, shared/numbered/logical databases are not supported by the Redis cluster. 实际上,Redis群集支持共享/编号/逻辑数据库。 That said, even if the cluster had supported databases, I would recommend against using them for multiple applications. 也就是说,即使集群支持数据库,我也建议不要将它们用于多个应用程序。

Your best option is to install a Redis cluster per application. 最好的选择是为每个应用程序安装Redis集群。 This will not only solve the namespacing problem, but will also ensure each application can fully utilize its Redis database's resources and allows per-app configuration of the database. 这不仅将解决命名空间问题,还将确保每个应用程序都能充分利用其Redis数据库的资源,并允许按应用程序配置数据库。

If you must, you can still use a single database for all your applications by prefixing each key with a unique, per-application, prefix to provide a "namespace" for each app. 如果需要,仍然可以通过为每个键添加每个应用程序的唯一前缀为每个应用程序提供一个“命名空间”,来为所有应用程序使用单个数据库。

database select is not supported by redis cluster mode. Redis集群模式不支持数据库选择。 You can adopt the concept of namespace by appending the application name to key. 您可以通过将应用程序名称附加到键来采用名称空间的概念。 But it's not a good idea to use the same redis cluster for different application. 但是,对于不同的应用程序使用相同的redis集群并不是一个好主意。 It will make the maintenance and troubleshooting more difficult. 这将使维护和故障排除更加困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM