In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Principle
Cluster technology is the main technology for building highly concurrent websites. The greatest pressure to visit a website is to query the database when visiting a page and respond accordingly. Redis has supported the cluster function since version 3.0. to make the cluster work properly, there must be at least three master nodes.
Redis clustering is based on the concept of hash slot (hash slot). Redis only integrates 16384 slots. When placing a KYE in redis, redis will calculate a value for this KEY using crc16 algorithm, and then surplus this value to 16383, so that each KEY will correspond to a number between 0 and 16383, and redis will allocate hash slots to different nodes according to the number of nodes.
When you want to take the value of a certain KEY, redis will calculate a value through the KYE name you want to get, calculate a value through crc16, and then make a remainder with 16383, find the corresponding node through the remainder, and then find the key value on this node.
Redis continues the feature of read-write separation. Each master node has a slave node, and a slave node can also have a slave node.
The master node is responsible for writing and the slave node is responsible for reading data in memory.
Node and Node listen to each other. Once Node exits, the other Node will automatically share the slot of Node.
Their own slot will not be reassigned, which does not affect the use of other slot
Environment
Three machines A machine can open multiple redis with multiple ports
192.168.123.160:6379192.168.123.160:6380192.168.123.170:6379192.168.123.170:6380192.168.123.180:6379192.168.123.180:6380
The redis cluster tool is included in the Redis installation package
Installation packages required for cluster tools
Zlib-1.2.8.tar.gz http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz
Ruby-2.2.9.tar.gz https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.9.tar.gz
Rubygems-2.5.1.tgz https://rubygems.global.ssl.fastly.net/rubygems/rubygems-2.5.1.tgz
Redis-3.2.2.gem https://rubygems.global.ssl.fastly.net/gems/redis-3.2.2.gem
Redis-3.2.3.tar.gz http://download.redis.io/releases/redis-3.2.3.tar.gz
Configuration
Install zlib
Gunzip zlib-1.2.8.tar.gztar-xvf zlib-1.2.8.tarcd zlib-1.2.8./configuremakemake install
Install ruby
Because the version of yum installation is lower, the higher version of redis cluster is not supported, so we use the high version of
Tar-zxvf ruby-2.2.9.tar.gzcd ruby-2.2.4./configure-prefix=/usr/local/rubymakemaek install cp ruby / bin
Install rubygems
Tar-zxvf rubygems-2.5.1.tgzcd rubygems-2.5.1ruby setup.rbcp bin/gem / bin
Install gem-redis
Gem install-l redis-3.2.2.gem
Redis (all 3 servers need to be installed)
Tar-zxvf redis-3.2.3.tar.gzcd redis-3.2.3make
Configuration file for redis
Redis.conf needs to be modified.
Bind 0.0.0.0 # address that the redis service listens to. If the test is changed to a local address, the port 6379 # startup port will be better. If it is a redis-6380.conf configuration file, change it to 6380daemonize yes # change it to yes, and let redis run pidfile / var/run/redis_6379.pid # in the background. If it is a redis-6380.conf configuration file, Modify the bit redis_6380.pidlogfile / usr/local/redis/logs/redis-6379.log # if it is a redis-6380.conf configuration file, change it to redis_6380.pidcluster-enabled yes # enable the cluster cluster-config-file nodes-51-6379.conf # if it is a redis-6380.conf configuration file, change it to nodes-51-6380.conf
Redis cluster
Copy the tool cp src/redis-server / usr/local/redis/cp src/redis-cli / usr/local/rediscp src/redis-trib.rb / usr/local/redis in the source package
Start redis and create a cluster
Redis-server redis.conf # needs to be started on each machine. Multiple configuration files redis-trib.rb create-replicas 1 192.168.123.160 redis-trib.rb create 6379 192.168.123.160 redis-trib.rb create 6380 192.168.123.170 redis-trib.rb create 6380 192.168.123.180 redis-trib.rb create 6379 192.168.123.180 redis-trib.rb create 6380 # create clusters
Then type yes.
View cluster nodes
Redis-trib.rb check 192.168.123.160:6379
The above information appears, indicating that the cluster has been installed successfully
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.