Redis cluster deployment steps and problem resolution

Source: Internet
Author: User
Tags config redis syslog redis cluster install redis redis server
1 Let go of the redis.config cluster-enabled Yes comment
2 Copying redis.conf files
Modify Port: 6380 6381 6382
3 Starting Redis Service separately
4 using the Redis Client command: Cluster meet IP Port command to create a cluster
5 Using the Redis Client command: Cluster addslots slot1 <slot2> ... <slot3> allocating 16,384 slots to each node in the cluster
(Note: cluster addslots 0 1 2 3 4 5 6 7 is supported but the command does not support intermediate ... namely: Cluster addslots 0 1 2 ... 5000 is an error, so if you use the cluster addslots command you need to write out all the slots of the allocated node.
6 using the cluster addslots command to allocate 16,384 slots is a hassle to write from 0 to 16,383 data, so use the cluster tools that Redis has provided yourself redis-trib.rd
7 Redis-trib.rd can automatically create clusters and allocate slot information.
8 using REDIS-TRIB.RD to use Ruby
9 Installing Ruby:
9.1 Mounting RVM 1) curl-l Https://get.rvm.io | Bash-s Stable
2) source/etc/profile.d/rvm.sh
3) rvm-v View RVM version
9.2 Installing Ruby and Rubygem 1) sed-i ' s!cache.ruby-lang.org/pub/ruby!ruby.taobao.org/mirrors/ruby! ' $RVM _path/config/db
Note: The change command is mainly to modify the image address of Ruby, Taobao as the primary mirror address, the cache.ruby-lang.org as the secondary mirror address, mainly because the domestic network is unstable
2) RVM list known view the version of Ruby that can be installed
3) RVM Install 2.2 installation ruby2.2.1 version
4) RVM 2.2--default Set the version of Ruby
5) ruby-v View Ruby version
6) Gem-v View the version of the gem
10 Enter the SRC directory below the Redis directory to execute the command./REDIS-TRIB.RD Create 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382
If the error is as follows:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in ' Gem_original_require ': No such file to load--Redis ( Loaderror)
From/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in ' require '
From./redis-trib.rb:25
Execute the following command: Gem install Redis
11 when performing a gem install Redis will report a connection error, you need to perform the following command to modify
Gem sources--remove https://rubygems.org/Delete the default source address
Gem Sources-a https://ruby.taobao.org/Set a new source address
Gem source-l View Source Address
Execute again later: Gem install Redis




12 execute again./REDIS-TRIB.RB Create 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 Creating a cluster and allocating slots
/REDIS-TRIB.RB Check 127.0.0.1:6380 checking the status of the cluster
/REDIS-TRIB.RB Reshard 127.0.0.1:6380 (Ip:port of any node in the cluster) bulk re-sharding (i.e., completing the migration of slot shards and Key-value)
15 for single slot shards
If slot 4894 on the 6380 corresponding node, now need to move the slot to the 6382 node need to execute the following command
14.1 CLUSTER setslot <slot> migrating <target_id> Migrate the slot slots of this node to the nodes specified in target_id (node name for 6382 nodes)
14.2 CLUSTER setslot <slot> importing <source_id> import slot slots to this node from the node specified by the SOURCE_ID (node name corresponding to 6380 nodes)
14.3 CLUSTER Getkeysinslot <slot> <count> returns the keys in count slots
14.4 Migrate Target_id_ip target_id_port <key> 0 (indicates database number) timeout
14.5 Loops 3, 4 steps until all keys have been merged into the TARGET_ID
14.6 Execute on source_id node: cluster setslot <slot> node <target_id>
Execute on the target_id node: Cluster setslot <slot> node <target_id> here the book says cluster setslot naming on any node, However, when the cluster Setslot is performed on the SOURCE_ID node during the operation, it is right to view cluster nodes information in source_id.
However, it is not right to view the cluster nodes information slot information on other nodes, after a long wait, the information is still incorrect, then the setslot of the nodes on the entire cluster after cluster cluster command is re-executed on target_id. Nodes information remains consistent.


16 issues encountered in deploying a Redis cluster:
16.1 appears when installing the software: insserv:starting Redis depends on Ondeman and therefor on system facility ' $all ' which can not is true!
The reason for this is that the/etc/init.d/redis and/etc/rc.d/redis are configured when the boot is set up prior to deploying redis-6379
After #!/bin/sh in the Redis file, add:
# # # BEGIN INIT INFO
# Provides:redis
# Required-start: $network $remote _fs $syslog $time
# Required-stop:
# Default-start:2 3 4 5
# default-stop:0 1 6
# Short-description:redis
# # # END INIT INFO
Information can
The contents of the specific documents are as follows:
#!/bin/sh
#
# simple Redis INIT.D script conceived to work on Linux systems
# as it does use of the/proc filesystem.


# # # BEGIN INIT INFO
# Provides:redis
# Required-start: $network $remote _fs $syslog $time
# Required-stop:
# Default-start:2 3 4 5
# default-stop:0 1 6
# Short-description:redis
# # # END INIT INFO


redisport=6379
Exec=/usr/local/bin/redis-server
Cliexec=/usr/local/bin/redis-cli


Pidfile=/var/run/redis_${redisport}.pid
conf= "/etc/redis/${redisport}.conf"


Case "$" in
Start
If [-F $PIDFILE]
Then
echo "$PIDFILE exists, process is already running or crashed"
Else
echo "Starting Redis server ..."
$EXEC $CONF &
Fi
;;
Stop
if [!-F $PIDFILE]
Then
echo "$PIDFILE does not exist, process was not running"
Else
pid=$ (Cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC-P $REDISPORT shutdown
While [-x/proc/${pid}]
Do
echo "Waiting for Redis to shutdown ..."
Sleep 1
Done
echo "Redis stopped"
Fi
;;
*)
echo "Please use Start or stop as first argument"
;;
Esac










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.