In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Number of environment nodes IP:172.17.7.11 CPU: 12 core MEM:96G startup service: 6 use port: 7001~12IP:172.17.7.25 CPU: 12 core MEM:96G startup service quantity: 6 use port: 7001~12IP:172.17.7.26 CPU: 12 core MEM:96G startup service quantity: 6 use port: 7001~12kernel
Uname-a
Linux jp33e503-7-11.ptfuture.com 3.10.0-514.26.2.el7.x86_64 # 1 SMP Tue Jul 4 15:04:05 UTC 2017 x86 "64 GNU/Linux
Ststem version
More / etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
Software version
Redis-4.0.1
Software download
Wget http://download.redis.io/releases/redis-4.0.1.tar.gz
Install (executed by each of the three sets)
Mkdir / redis cd / redis wget-P / redis http://download.redis.io/releases/redis-4.0.1.tar.gz
Tar-xzf redis-4.0.1.tar.gz cd redis-4.0.1 make & & make install
Verify the installation:
[root@jp33e503-7-11 redis-4.0.1] # redis- tab key
Redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
The above command appears
Whereis redis-server
Redis-server: / usr/local/bin/redis-server
Copy redis-trib.rb to / usr/local/bin
Cd src/
Cp-rp redis-trib.rb / usr/local/bin/
Cluster build: create a directory
Mkdir-p / redis/cluster/700 {1.. 9}
Mkdir-p / redis/cluster/701 {0.2}
Configure redis Profil
[root@jp33e503-7-11 cluster] # pwd / redis/cluster
More redis.conf#redis background runs daemonize yes # pidfile file pidfile / var/run/redis_7001.pid # Jinting port port 7001 # enable cluster cluster-enabled yes # configuration file to start automatic generation of cluster-config-file / redis/cluster/7001/nodes_7001.conf # for the first time Request timeout cluster-node-timeout 5000 # aof log appendonly no # bind address Need another machine to ping address bind 172.17.7.11 copy configuration file
Rsync / redis/cluster/redis.conf / redis/cluster/7001/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7002/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7003/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7004/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7005/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7006/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7007/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7008/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7009/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7010/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7011/redis.conf & &
Rsync / redis/cluster/redis.conf / redis/cluster/7012/redis.conf
Modify port number
Sed-I "s sed 7001max 7001max g" / redis/cluster/7001/redis.conf & &
Sed-I "s Universe 7001 + 7002" / redis/cluster/7002/redis.conf & &
Sed-I "s _ g" / redis/cluster/7003/redis.conf & &
Sed-I "s _ g" / redis/cluster/7004/redis.conf & &
Sed-I "s _ g _
Sed-I "s sed 7001 + 7006" / redis/cluster/7006/redis.conf & &
Sed-I "s sed 7001 + 7007" / redis/cluster/7007/redis.conf & &
Sed-I "s _ g _
Sed-I "s Universe 7001 + 7009" / redis/cluster/7009/redis.conf & &
Sed-I "sCompact 7001Universe 7010Compact g" / redis/cluster/7010/redis.conf & &
Sed-I "sCompact 7001Universe 7011Universe g" / redis/cluster/7011/redis.conf & &
Sed-I "splash 7001 + 7012" / redis/cluster/7012/redis.conf
Verify the configuration
More / redis/cluster/7001/redis.conf | grep 70 & &
More / redis/cluster/7002/redis.conf | grep 70 & &
More / redis/cluster/7003/redis.conf | grep 70 & &
More / redis/cluster/7004/redis.conf | grep 70 & &
More / redis/cluster/7005/redis.conf | grep 70 & &
More / redis/cluster/7006/redis.conf | grep 70 & &
More / redis/cluster/7007/redis.conf | grep 70 & &
More / redis/cluster/7008/redis.conf | grep 70 & &
More / redis/cluster/7009/redis.conf | grep 70 & &
More / redis/cluster/7010/redis.conf | grep 70 & &
More / redis/cluster/7011/redis.conf | grep 70 & &
More / redis/cluster/7012/redis.conf | grep 70
Startup service (3 hosts are started separately)
Redis-server / redis/cluster/7001/redis.conf & & redis-server / redis/cluster/7002/redis.conf & & redis-server / redis/cluster/7003/redis.conf & & redis-server / redis/cluster/7004/redis.conf & & redis-server / redis/cluster/7005/redis.conf & & redis-server / redis/cluster/7006/redis.conf & & redis-server / redis/cluster/7007/redis.conf & & redis-server / redis/cluster/7008/redis.conf & & Redis-server / redis/cluster/7009/redis.conf & & redis-server / redis/cluster/7010/redis.conf & & redis-server / redis/cluster/7011/redis.conf & & redis-server / redis/cluster/7012/redis.conf
Check whether the startup is successful and the information
[root@jp33e503-7-11 cluster] # ps-ef | grep redis root 28364 10 13:33? 00:00:00 redis-server 172.17.11 grep redis root 7001 [cluster] root 29859 10 13:34? 00:00:00 redis-server 172.17.11 ps 7002 [cluster] root 29861 10 13:34? 00:00:00 redis-server 172.17.11 redis-server 7003 [cluster] root 29869 10 13:34? 00:00:00 redis-server 172.17. 7.11:7004 [cluster] root 29874 1 0 13:34? 00:00:00 redis-server 172.17.7.11:7005 [cluster] root 29879 1 0 13:34? 00:00:00 redis-server 172.17.7.11:7006 [cluster] root 29884 1 0 13:34? 00:00:00 redis-server 172.17.7.11:7007 [cluster] root 29889 1 0 13:34? 00:00:00 redis-server 172.17.7.11:7008 [cluster] Root 29891 10 13:34? 00:00:00 redis-server 172.17.7.11:7009 [cluster] root 29896 10 13:34? 00:00:00 redis-server 172.17.7.11:7010 [cluster] root 29901 10 13:34? 00:00:00 redis-server 172.17.7.11:7011 [cluster] root 29906 10 13:34? 00:00:00 redis-server 172.17.7.11:7012 [cluster]
Then configure the next one and modify the server listening IP address:
Set up a cluster
Redis officially provides a redis-trib.rb (under the src directory) tool for building clusters. It's obviously written by ruby, so you need a ruby environment.
Install ruby
Yum-y install ruby ruby-devel rubygems rpm-build
Install redis interface with gem
Gem install redis
Installation error:
[root@jp33e503-7-11 cluster] # gem install redisFetching: redis-4.0.0.gem ERROR: Error installing redis: redis requires Ruby version > = 2.2.2. # prompt that the ruby version is lower than the current version: [root@jp33e503-7-11 cluster] # ruby- vruby 2.0.0p648 (2015-12-16) [x86_64-linux] solution: wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gztar-xvzf ruby-2.4.1.tar.gz cd ruby-2.4.1./configuremake & & make installruby-v [root @ jp33e503-7-11 ~] # ruby-vruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
Execute again:
Gem install redis
Fetching: redis-4.0.0.gem (100%) Successfully installed redis-4.0.0Parsing documentation for redis-4.0.0Installing ri documentation for redis-4.0.0Done installing documentation for redis after 1 seconds1 gem installed to create clusters to ensure open ports
Run redis-trib.rb to view the cluster creation help
Usage: redis-trib create host1:port1... HostN:portN-replicas check host:port info host:port fix host:port-timeout reshard host:port-from-to-slots-yes -- timeout-- pipeline rebalance host:port-- weight-- auto-weights-- use-empty-masters-- timeout-- simulate-- pipeline-- threshold add-node New_host:new_port existing_host:existing_port-slave-master-id del-node host:port node_id set-timeout host:port milliseconds call host:port command arg arg.. Arg import host:port-from-copy-replace help (show this help) to create a cluster
# where-- replicas 1 means to assign 1 slave to each master
Redis-trib.rb create-- replicas 1 172.17.7.11Vl7002 172.17.7.11Vl7003 172.17.7.11VOL7004 172.17.7.11VOV 7006 172.17.7.11RV 7006 172.17.7.11RV 7007 172.17.7.11RV 7008 172.17.7.11Rd 7009 172.17.7.11Rd 7010 172.17.7.11 RV 7011 172.17.7.11 Rd 7011 172.17.7.11 Rd 7012 172. 17.7.25:7001 172.17.7.25:7002 172.17.7.25:7003 172.17.7.25:7004 172.17.7.25:7005 172.17.7.25:7006 172.17.7.25:7007 172.17.7.25:7008 172.17.7.25:7009 172.17.7.25:7010 172.17.7.25:7011 172.17.7.25:7012 172.17.7.26:7001 172.17.7 . 26:7002 172.17.7.26:7003 172.17.7.26:7004 172.17.7.26:7005 172.17.7.26:7006 172.17.7.26:7007 172.17.7.26:7008 172.17.7.26:7009 172.17.7.26:7010 172.17.7.26:7011 172.17.7.26:7012
> Creating cluster > Performing hash slots allocation on 36 nodes...Using 18 masters:172.17.7.11:7001172.17.7.25:7001172.17.7.26:7001172.17.7.11:7002172.17.7.25:7002172.17.7.26:7002172.17.7.11:7003172.17.7.25:7003172.17.7.26:7003172.17.7.11:7004172.17.7.25:7004172.17.7.26:7004172.17.7.11 : 7005172.17.7.25:7005172.17.7.26:7005172.17.7.11:7006172.17.7.25:7006172.17.7.26:7006Adding replica 172.17.7.25:7007 to 172.17.7.11:7001Adding replica 172.17.7.11:7007 to 172.17.7.25:7001Adding replica 172.17.7.11:7008 to 172.17.7.26:7001Adding replica 172.17.7.26:7007 to 172.17.7.11 : 7002Adding replica 172.17.7.26:7008 to 172.17.7.25:7002Adding replica 172.17.7.25:7008 to 172.17.7.26:7002Adding replica 172.17.7.25:7009 to 172.17.7.11:7003Adding replica 172.17.7.11:7009 to 172.17.7.25:7003Adding replica 172.17.7.11:7010 to 172.17.7.26:7003Adding replica 172.17.7.26:7009 to 172.17.7.11 : 7004Adding replica 172.17.7.26:7010 to 172.17.7.25:7004Adding replica 172.17.7.25:7010 to 172.17.7.26:7004Adding replica 172.17.7.25:7011 to 172.17.7.11:7005Adding replica 172.17.7.11:7011 to 172.17.7.25:7005Adding replica 172.17.7.11:7012 to 172.17.7.26:7005Adding replica 172.17.7.26:7011 to 172.17.7.11 : 7006Adding replica 172.17.7.26 slots:0 7012 to 172.17.7.25:7006Adding replica 172.7.25 masterM: 574bdafc37a1d63f9988480b1c360b71699b0d3a 172.17.7.26 slots:0-909 (910 slots) masterM: 0fdc365a3360390e7ee01b6e2c5f2f293142122c 172.17.7.11 7002 slots:2731-3640 (910 slots) masterM: 8e91fca9fddbe7ecdd4d97c7de160daf6c635a6d 172.17.7.11 slots:5461-6371 (911 slots) masterM: 2c38ebc64166f8bcba3c00830326d50051a7a96e 172.17.7.11 Slots:8192-9101 (910 slots) masterM: a841f6d12f8e8f0ed56479a596319675538fc474 172.17.7.11 a841f6d12f8e8f0ed56479a596319675538fc474 7005 slots:10923-11832 (910 slots) masterM: 49e4e848e2e09e6ef743777d59574740e2e95030 172.17.7.11 a841f6d12f8e8f0ed56479a596319675538fc474 7006 slots:13653-14563 (911 slots) masterS: 71f3fb407719262a844d53d1abd2c164cdca20bf 172.17.7.11 71f3fb407719262a844d53d1abd2c164cdca20bf 7007 replicates 32d5dfc35a27aed442b41138bb9b367507359100S: ab1fe94d17ac2f4810b277addd2dc973b5e708d3 172.17.7.11 replicates a57d14b025d5c8c37fc2711e109362b5b40b4d6e 7008. S: 3e773633e3f0761777e3f70ba0038c05a87a49b4 172.17.7.26:7011 replicates 49e4e848e2e09e6ef743777d59574740e2e95030S: c0c52c55b24d25f7f1cdc76fd9a68752789f3ea7 172.17.7.26:7012 replicates f59e48dcf034e3a961cc4999616e59fa03dc8a8cCan I set the above configuration? (type 'yes' to accept): yes > > Nodes configuration updated > > Assign a different config epoch to each node > > Sending CLUSTER MEET messages to join the clusterWaiting for the cluster to join. > > Performing Cluster Check (using node 172.17.7.11 master 7001) M: 574bdafc37a1d63f9988480b1c360b71699b0d3a 172.17.7.11 master 7001 slots:0-909 (910 slots) additional replica (s) S: 95cc9fab44f23e38c055bce23fddb19b813dca8a 172.17.7.11 master 7010 1 additional replica (s) M: 5baf8fcf69e3aaafe3a4d7eba997697335b6c3c1 172.17.7.25 master 7002 Slots:3641-4550 (910 slots) master 1 additional replica (s) S: 71f3fb407719262a844d53d1abd2c164cdca20bf 172.17.7.11 master 7007 slots: (0 slots) slave. Slots:13653-14563 (911 slots) master 1 additional replica (s) M: 6451851e996947f9e3f906c646664efb7242d451 172.17.7.25 6451851e996947f9e3f906c646664efb7242d451 7004 slots:9102-10011 (910 slots) master 1 additional replica (s) [OK] All nodes agree about slots configuration. > > Check for open slots... > Check slots coverage... [OK] All 16384slots covered. Test cluster
Set a key-value pair testKey--testValue on the 172.17.7.11 7001 machine. Because IP is bound, the h parameter cannot be omitted.
Redis-cli-h 172.17.7.11-c-p 7001172.17.7.11 Redirected to slot 7001 > set testkey testvalue- > Redirected to slot [4757] located at 172.17.7.26:7002OK172.17.7.26:7002 > get testkey "testvalue"
Get the value of testKey on 72.17.7.25 testKey 7001 and find that it is automatically directed to 72.17.7.26 7002, which means it is successful
[root@jp33e503-7-11 ~] # redis-cli-h 172.17.7.25-c-p 7001 172.17.7.25 get testkey- > Redirected to slot [4757] located at 172.17.7.26 get testkey- 7002 "testvalue"
At this point, the Redis cluster has been built.
Cluster operation check status redis-trib.rb check 172.17.7.11 slots:0 7001 > Performing Cluster Check (using node 172.17.7.11 slots:0 7001) M: 574bdafc37a1d63f9988480b1c360b71699b0d3a 172.17.7.11 slots:0-909 (910 slots) master 1 additional replica (s) S: 95cc9fab44f23e38c055bce23fddb19b813dca8a 172.17.7.11 master 7010 slots: (0 slots) slave replicates 8a645dd55e4abe59c3d480ebf0fd60494eaabe4aM: 8e91fca9fddbe7ecdd4d97c7de160daf6c635a6d 172.17.7.11 7003 slots:5461-6371 (911 slots) master 1 additional replica S) M: a841f6d12f8e8f0ed56479a596319675538fc474 172.17.7.11 master 7005 slots:10923-11832 (910 slots) master 1 additional replica (s) S: 8fefc4e249e0c54d326ed3fa263f10952ae94ac4 172.17.7.25 master 7010 slots: (0 slots) slave replicates 4ce13bdfc044a546ec7d03a346b39acda7bb4dd0M: 62b01ec5ecf4bd4596c4c004bf1c82f1afc6a407 172.17.7.26 slots 7002 slots:4551-5460 (910 slots) master 1 additional replica (s) M: 5baf8fcf69e3aaafe3a4d7eba997697335b6c3c1 172.17.7.25Rd 7002 slots:3641-4550 (910 slots) master 1 additional replica (s) slots:14564- 15473 (910 slots) master 1 additional replica (s) S: 11a8e35e3c9ea4c93dd36a96094881ff29fc1856 172.17.7.11 A little. Slots:10012-10922 (911 slots) master 1 additional replica (s) S: 24ef0015d8a38d7aeab5dc7373262ba078f9e13d 172.17.7.26 master 7007 slots: (0 slots) slave replicates 0fdc365a3360390e7ee01b6e2c5f2f293142122cM: 49e4e848e2e09e6ef743777d59574740e2e95030 172.17.7.11 slots:13653-14563 (911 slots) master 1 additional replica (s) M: 6451851e996947f9e3f906c646664efb7242d451 172.17.7.25 master 7004 slots:9102-10011 (910 slots) master 1 additional replica (s) [OK] All nodes agree about slots configuration. > > Check for open slots... > > Check Slots coverage... [OK] All 16384 slots covered. View all node information
Redis-cli-h 172.17.7.11-c-p 7001
172.17.7.11 7001 > cluster nodes
95cc9fab44f23e38c055bce23fddb19b813dca8a 172.17.7.11 95cc9fab44f23e38c055bce23fddb19b813dca8a 7010 17010 slave 8a645dd55e4abe59c3d480ebf0fd60494eaabe4a 01504596545000 27 connected8e91fca9fddbe7ecdd4d97c7de160daf6c635a6d 172.17.7.11 Vera 7003 master-01504596545502 3 connected 5461-6371a841f6d12f8e8f0ed56479a596319675538fc474 172.17.7.11 7005 master-01504596546103 5 connected 10923-11832. View cluster information
172.17.7.11 7001 > CLUSTER INFO
Cluster_state:okcluster_slots_assigned:16384cluster_slots_ok:16384cluster_slots_pfail:0cluster_slots_fail:0cluster_known_nodes:36cluster_size:18cluster_current_epoch:36cluster_my_epoch:1cluster_stats_messages_ping_sent:26628cluster_stats_messages_pong_sent:26948cluster_stats_messages_sent:53576cluster_stats_messages_ping_received:26913cluster_stats_messages_pong_received:26628cluster_stats_messages_meet_received:35cluster_stats_messages_received:53576 node command
# add the nodes where ip and port are located to the cluster cluster meet
# remove the node specified by node_id from the cluster. Cluster forget
# set the current node to the slave (slave node) cluster replicate of node_id
# Save node configuration file cluster saveconfig
Slot command
# assign one or more slot to the current node (assign). Cluster addslots [slot...]
# remove the assignment of one or more slots to the current node. Cluster delslots [slot...]
# remove all slots assigned to the current node, making the current node a node without any slots assigned. Cluster flushslots
# assign the slot slot to the node specified by node_id. If the slot is already assigned to another node, let the other node delete the slot first > and then assign it. Cluster setslot node
# migrate the slot slot of this node to the node specified by node_id. Cluster setslot migrating
# Import slot slot from the node specified by node_id to this node. Cluster setslot importing
# cancel the import (import) or migration (migrate) of slot slot. Cluster setslot stable
Key
# calculate which slot the key key should be placed on. Cluster keyslot
# returns the number of key-value pairs currently contained in slot slot. Cluster countkeysinslot
# returns the keys in count slot slots. Cluster getkeysinslot
Script start node
#! / bin/bash for i in 1 2 3 4 5 6 7 8 9 do redis-server / redis_cluster/700$ iCharter redis.confession; done
For i in 10 11 12 do redis-server / redis_cluster/70$ iAccord redis.confession; done
Start the cluster #! / bin/bashredis-trib.rb create-- replicas 1 172.17.7.11 7001 172.17.7.11 7003 172.17.7.11 7003 172.17.7.11 7004 172.17.7.11 7005 172.17.7.11 7006 172.17.7.11 7007 172.17.7.11 7008 172.17.7.11 7009 172.17.7.11 7010 172.17.7.11 172.17.7.11 7011 172.17.7.11 .17.7.11: 7012 172.17.7.25:7001 172.17.7.25:7002 172.17.7.25:7003 172.17.7.25:7004 172.17.7.25:7005 172.17.7.25:7006 172.17.7.25:7007 172.17.7.25:7008 172.17.7.25:7009 172.17.7.25:7010 172.17.7.25:7011 172.17.7.25:7012 172.17. 7.26Vera 7001 172.17.26RV 7003 172.17.7.26RV 7004 172.17.7.26WR 7006 172.17.7.26RV 7007 172.17.26RV 7008 172.7.26RV 7009 172.7.26RV 7010 172.17.7.26RV 7011 172.17.7.26RV 7012 close cluster #! / bin/bashfor I in 11 25 26do For j in 1 2 3 4 5 6 7 8 9 do redis-cli-c-h 172.17.7. Donedonefor i in 11 25 26do for j in 10 11 12 do redis-cli-c-h 172.17.7. I-p 70$ j shutdown; donedone
For the first time to install and experience the process, the official downloaded source package contains thread automation scripts, install a single service and create a cluster, you can consider using:
Script location: redis-4.0.1/utils
Ls
[root@ts-100-20 utils] # ls
Build-static-symbols.tcl generate-command-help.rb install_server.sh redis_init_script.tpl whatisdoing.sh
Cluster_fail_time.tcl graphs lru redis-sha1.rb
Corrupt_rdb.c hashtable redis-copy.rb releasetools
Create-cluster hyperloglog redis_init_script speed-regression.tcl
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.