In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to build a redis cluster under centos". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Essential tools:
Redis-3.0.0.tar
Redis-3.0.0.gem (ruby and redis interfaces)
Analysis:
First of all, the number of clusters requires a cardinality. Here we build a simple redis cluster (6 redis instances are clustered).
Operate on one server, so only 6 different port numbers are required. They are: 7001, 7002, 7003, 7004, 7005, 7006.
Steps:
1. Upload the redis-3.0.0.tar to the server (specify your own software directory) and extract the redis-3.0.0.tar.
2. Install c language environment (after installing centos, it comes with c language environment)
Yum install gcc-c++
3. Enter the redis-3.0.0 directory
Make
4. Install redis to the / usr/local/redis directory
Make install prefix=/usr/local/redis
5. Check whether the installation is successful (just appear the bin directory)
6. Start redis at the front end (enter the bin directory in the figure above)
. / redis-server (on)
. / redis-cli shutdown (off)
7. Start the backend
You need to copy the redis.conf file in the source package (under the redis-3.0.0 directory) after redis is decompressed to the bin directory.
To modify the redis.conf file and change daemonize to yes, you must first use vim redis.conf.
Start redis using the command backend
Execute. / redis-server redis.conf under the bin directory
Check to see if the startup is successful
How to turn off the backend startup:
. / redis-cli shutdown
The above is a separate redis installation, and then set up a cluster!
Install ruby
Yum install rubyyum install rubygems
Upload the following files to the linux system
Redis-3.0.0.gem (ruby and redis interfaces)
Go to the directory and execute: gem install redis-3.0.0.gem
Copy the following files in the src directory under the redis-3.0.0 package to / usr/local/redis/redis-cluster/
Premise: create a new redis-cluster directory first
At least three hosts are needed to build a cluster, and at least six machines are needed if each host is configured with another slave.
The port design is as follows: 7001-7006
Step 1: copy a 7001 machine
Go to the / usr/local/redis/ directory and execute cp bin. / redis-cluster/7001-r
Step 2: if there is a persistent file, delete it
Rm-rf appendonly.aof dump.rdb
Step 3: set cluster parameters
Step 4: modify the port
Step 5: copy the 7002-7006 machine
Give the directory structure under my desktop system:
Next, set one button to start all redis or close the redis group:
First, create a new file, you can use vim to open a file that does not exist, and then save it. (the start-all.sh and shutdow-all.sh above are my new ones.)
Start-all.sh:
Cd 7001./redis-server redis.confcd.. cd 7002./redis-server redis.confcd.. cd 7003./redis-server redis.confcd.. cd 7004./redis-server redis.confcd.. cd 7005./redis-server redis.confcd.. cd 7006./redis-server redis.confcd..
Shutdow-all.sh:
Cd 7001./redis-cli-p 7001 shutdowncd.. cd 7002./redis-cli-p 7002 shutdowncd.. cd 7003./redis-cli-p 7003 shutdowncd.. cd 7004./redis-cli-p 7004 shutdowncd.. cd 7005./redis-cli-p 7005 shutdowncd. .cd 7006./redis-cli-p 7006 shutdowncd..
Next, modify the two file permissions to make them bootable script files.
Chmod upright x start-all.shchmod upright x shutdown-all.sh
Next, connect these clusters with ruby to manage them.
/ redis-trib.rb create-- replicas 1 192.168.78.133-7001 192.168.78.133-7002 192.168.78.133-7003 192.168.78.133-7003 192.168.78.133-7004 192.168.78.133-7005 192.168.78.133-7006
Appear:
Connecting to node 192.168.242.137okconnecting to node 7002: okconnecting to node 192.168.242.137connecting to node 7003: okconnecting to node 192.168.242.137connecting to node 7004: okconnecting to node 192.168.242.137connecting to node 7005: okconnecting to node 192.168.242.137connecting to node 7006: ok > > performing hash slots allocation on 6 nodes...using 3 masters:192.168.242.137:7001192.168.242.137:7002192.168.242.137:7003adding replica 192 .168.242.137: 7004 to 192.168.242.137:7001adding replica 192.168.242.137V 7005 to 192.168.242.137:7002adding replica 192.168.242.137V 7006 to 192.168.242.137V 7003m: 8240cd0fe6d6f842faa42b0174fe7c5ddcf7ae24 192.168.242.137V 7001 slots:0-5460 (5461 slots) masterm: 4f52a974f64343fd9f1ee0388490b3c0647a4db7 192.168.242.137to 7002 slots:5461-10922 (5462 slots) masterm: cb7c5def8f61df2016b38972396a8d1f349208c2 192.168.242.137V 7003 slots:10923-16383 (5461 slots) Masters: 66adf006fed43b3b5e499ce2ff1949a756504a16 192.168.242.137:7004 replicates 8240cd0fe6d6f842faa42b0174fe7c5ddcf7ae24s: cbb0c9bc4b27dd85511a7ef2d01bec90e692793b 192.168.242.137:7005 replicates 4f52a974f64343fd9f1ee0388490b3c0647a4db7s: a908736eadd1cd06e86fdff8b2749a6f46b38c00 192.168.242.137:7006 replicates cb7c5def8f61df2016b38972396a8d1f349208c2can 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 192.168.242.137 masterm 7001) m: 8240cd0fe6d6f842faa42b0174fe7c5ddcf7ae24 192.168.242.137 masterm 7001 slots:0-5460 (5461 slots) masterm: 4f52a974f64343fd9f1ee0388490b3c0647a4db7 192.168.242.137 masterm 7002 slots:5461-10922 (5462 slots) masterm: cb7c5def8f61df2016b38972396a8d1f349208c2 192.168.242.137nodes configuration updated 7003 slots:10923-16383 (5461 slots) masterm: 66adf006fed43b3b5e499ce2ff1949a756504a16 192 .168.242.137: 7004 slots: (0 slots) master replicates 8240cd0fe6d6f842faa42b0174fe7c5ddcf7ae24m: cbb0c9bc4b27dd85511a7ef2d01bec90e692793b 192.168.242.137slots 7005 slots: (0 slots) master replicates 4f52a974f64343fd9f1ee0388490b3c0647a4db7m: a908736eadd1cd06e86fdff8b2749a6f46b38c00 192.168.242.137slots 7006 slots: (0 slots) master replicates cb7c5def8f61df2016b38972396a8d1f349208c2 [ok] all nodes agree about slots configuration. > > check for open slots... > > check slots coverage... [ok] all 16384 slots covered.
Then it means success!
For a test, go to the 7001 directory and execute:. / redis-cli-h 192.168.242.137-p 7001-c
This is the end of the content of "how to build a redis cluster under centos". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.