Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use redis-trib.rb to create a Cluster with password in Redis

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

It is believed that many inexperienced people have no idea about how to use redis-trib.rb to create a cluster with password in Redis. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

1. Set the cluster password

Set the password in the configuration of each node. Note that in cluster mode, the following two lines are required.

one

two

Masterauth passwd123

Requirepass passwd123

2. Enable the relevant options for cluster configuration in the configuration of each node, as follows:

one

two

three

four

five

Port 30001

Cluster-enabled yes

Cluster-config-file nodes-30001.conf

Cluster-node-timeout 5000

Appendonly yes

3. Modify the create-cluster tool

The new version of Redis provides us with the tools to create clusters using redis-trib.rb, that is: utils/create-cluster/create-cluster

We made a slight modification to directly replace the parameters of the redis-server command in the start section with the path of each node profile.

one

two

three

four

five

six

seven

eight

nine

ten

If ["$1" = = "start"]

Then

While [$(PORT)

< ENDPORT)) != "0" ]; do PORT=$((PORT+1)) echo "Starting $PORT" # 通过redis-server并指定各个节点的redis配置文件路径 ../../src/redis-server /redis/redis-$PORT.conf done exit 0 fi 4、修改redis-trib.rb脚本 如果Redis设定了密码,那么通过redis-trib.rb脚本创建集群时,是会类似这样的错误的:[ERR] Sorry, can't connect to node *.*.*.*:7001 这是因为redis-trib.rb脚本中连接Redis时,并未设定密码,这确实是个很大的坑。我的解决方法时,修改该脚本中连接Redis时的代码,修改内容如下: 找到这一行: 1 @r = Redis.new(:host =>

@ info [: host],: port = > @ info [: port],: timeout = > 60)

Modified to:

one

@ r = Redis.new (: host = > @ info [: host],: port = > @ info [: port],: timeout = > 60,: password = > "your password")

5. After the modification is completed, run the following sequence:

. / craete-cluster start

. / craete-cluster create

You can start the cluster

After reading the above, have you mastered how to use redis-trib.rb to create a cluster with a password in Redis? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report