Redis cluster deployment steps and problem solving

Source: Internet
Author: User
Tags redis syslog redis cluster install redis redis server
1 release the comment of cluster-enabled Yes in Redis.config
2 Copy redis.conf files
Modify Port: 6380 6381 6382
3 Start 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> assigning 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 will be an error, so if you use the cluster addslots command, you need to assign all the slots to change the node write out.
6 using the cluster addslots command to allocate 16,384 slots it is cumbersome to write from 0 to 16,383 data, so use the cluster tools you need to redis yourself redis-trib.rd
7 Redis-trib.rd can automatically create clusters and allocate slot information.
8 using REDIS-TRIB.RD requires Ruby
9 Installing Ruby:
9.1 Installation 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 Ruby Mirror address, the Taobao as the primary mirror address, the cache.ruby-lang.org as a secondary mirror address, mainly because of domestic network instability
2) RVM list known view version of Ruby that can be installed
3) RVM Install 2.2 installation ruby2.2.1 version
4) RVM 2.2--default set up Ruby version
5) ruby-v View Ruby version
6) Gem-v View the version of the gem
10 Enter the Redis of the extract directory under the SRC Directory Execution 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 gem install Redis is reporting a connection error, you need to perform the following command to make the changes
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
Then execute again: 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 clusters 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 a cluster) bulk fragmentation (i.e., complete slot fragmentation and key-value migration)
15 to single slot slicing
If slot 4894 is on the 6380 corresponding node, now you need to move the slot to the 6382 node to perform the following command
14.1 CLUSTER setslot <slot> migrating <target_id> Migrate the slot slot for this node to the node specified in target_id (6382 node corresponding node name)
14.2 CLUSTER setslot <slot> importing <source_id> import slot source_id to this node from the node specified by slot (node name of 6380 node)
14.3 CLUSTER Getkeysinslot <slot> <count> returning keys in count slot slots
14.4 Migrate Target_id_ip target_id_port <key> 0 (representing database number) timeout
14.5 Cycles 3, 4 steps until all keys have been merged into TARGET_ID
14.6 execution on source_id node: cluster setslot <slot> node <target_id>
Execute on the target_id node: Cluster setslot <slot> node <target_id> The book says that the cluster setslot name can be executed on any node. However, it is right to see cluster nodes information in source_id after the operation is found to be performed only on the SOURCE_ID node cluster setslot
However, it is wrong to view cluster nodes information slot information at other nodes, after a long wait, the information is still not correct, then after the cluster setslot command is executed on target_id, the cluster of the nodes on the entire cluster Nodes information remains the same


16 problems encountered in deploying the Redis cluster:
16.1 occurs when installing software: insserv:starting Redis depends on Ondeman and therefor on system facility ' $all ' which
The reason is: before the deployment of redis-6379 set up the boot is configured/etc/init.d/redis and/etc/rc.d/redis
Add after #!/bin/sh in Redis file:
### 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 document 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 isn't running"
Else
pid=$ (Cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC-P $REDISPORT shutdown
While [-x/proc/${pid}]
Todo
echo "Waiting for Redis to shutdown ..."
Sleep 1
Done
echo "Redis stopped"
Fi
;;
*)
echo "Please use start or stop as the" "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.