Redis cluster deployment and some pitfalls

Source: Internet
Author: User
Tags redis cluster install redis

Redis cluster deployment and some pitfalls

Before starting the deployment, check the first 6th items.

1. Download and compile the redis installation package from the official website
 $ wget http://download.redis.io/releases/redis-3.2.5.tar.gz  $ tar xzf redis-3.2.5.tar.gz $ cd redis-3.2.5 $ make
 
 
 
2. Configure redis
 port 7000  cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes
 
 
If you do not want persistence, appendonly yes-> appendonly no
Suppose we deploy three redis nodes, then we need to create six redis instances, three of which are the slave of the other three nodes;
 mkdir cluster-test cd cluster-test mkdir 7000 7001 7002 7003 7004 7005
Ensure that the redis. conf ports in these six directories are 7000 ~ 7005
3. Start all redis instances
Go to the six directories and start the corresponding redis-server
cd 7000../redis-server ./redis.conf
4. Install the redis-trib.rb Runtime Environment
Redis-trib.rb is ruby code, so install ruby first
Yum install ruby gem install redis -- install redis Dependencies
Because of wall problems, gem install redis may fail. Use the domestic source instead.
Gem sources -- remove https://rubygems.org/Delete the original source gem sources-a http://gems.ruby-china.org switch to the domestic source gem sources-l view the existing source gem install redis dependency
5. Create a cluster
 ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 
 
 
6. Notes
(1) Build a cluster with redis-trib.rb, do not configure the password before completion
(2) After the cluster is built, use the config set + config rewrite command to set passwords for instances one by one.
(3) set the password for the cluster. Both requirepass and masterauth must be set.
(4) The passwords of each node must be consistent; otherwise, Redirected will fail.
 config set masterauth  yourpasswd  config set requirepass  yourpasswd auth yourpasswd config rewrite
 
(5) If an error is prompted, The redis dependency version is incorrect. Remove the current redis dependency and install the specified version.
/usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:111:in `rescue in _write_to_socket': Connection timed out (Redis::TimeoutError)     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:104:in `_write_to_socket'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:131:in `block in write'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:130:in `loop'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:130:in `write'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/connection/ruby.rb:374:in `write'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:271:in `block in write'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:250:in `io'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:269:in `write'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:228:in `block (3 levels) in process'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:222:in `each'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:222:in `block (2 levels) in process'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:367:in `ensure_connected'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:221:in `block in process'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:306:in `logging'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:220:in `process'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis/client.rb:120:in `call'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:2705:in `block in method_missing'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:58:in `block in synchronize'     from /usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:58:in `synchronize'     from /usr/local/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:2704:in `method_missing'     from ./redis-trib.rb:212:in `flush_node_config'     from ./redis-trib.rb:776:in `block in flush_nodes_config'     from ./redis-trib.rb:775:in `each'     from ./redis-trib.rb:775:in `flush_nodes_config'     from ./redis-trib.rb:1296:in `create_cluster_cmd'     from ./redis-trib.rb:1701:in ` 
That is the gem version to delete the redis-3.3.2 plug-in, use 3.0.0
gem list
 gem uninstall redis --version 3.3.2
 gem install redis --version 3.0.0
 gem list

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.