In today's concurrent environment, it is best to cache queries for large volumes of data using Redis to build clusters
(Personal like Redis, memcache not cold)
Redis is a cluster feature added after 3.0, very powerful
There should be at least three nodes in the cluster, with one backup node per node. It's going to take at least 6 servers .
Considering that some friends of the computer configuration is not very high, run multiple virtual machines will be cards, this side release pseudo-distributed and distributed
(Configured 2 years ago)
The premise is to install a single case of Redis (not much to say here)
Requires 6 redis instances
Steps to build a cluster:
Create a folder under/usr/local This is what I changed the original single redis name into a redis01/bin. Delete dump file Modify Port open Comment copy multiple copies
(only one is needed in real environment, then the remaining 5 machines repeat the above operation.)specifies that the port7001to the7006This is the occupancy rate in the real world.in theRedisunder the source foldersrcdirectory. redis-trib.rb, this ruby scriptThe fourth step:redis-trib.rbfiles are copied to theRedis-clusterdirectory.
(in real-world situations, just put it on one of your nodes, he will automatically traverse the other nodes, and I'll do it on 01) before you execute a Ruby script, you need to install a ruby environment, or you can't load Yum install ruby Yum Install RubyGems Installing redis-trib.rb running a dependent Ruby package This gem can be downloaded online, many(Just run on one of the machines in the real world) go to their Redis folder and start eachRedisExampleStart successful useredis-trib.rbCreate a clusterwhether pseudo-distributed or not, this only needs to be started onceSuccess! Link The first node below demonstrates using Jedis to read and write the cache of course, join spring must use a singleton
1 @Test2 Public voidTestcluster ()throwsException {3setNewHashset<>();4Nodes.Add (NewHostandport ("192.168.1.193", 7001));5Nodes.Add (NewHostandport ("192.168.1.194", 7002));6Nodes.Add (NewHostandport ("192.168.1.195", 7003));7Nodes.Add (NewHostandport ("192.168.1.196", 7004));8Nodes.Add (NewHostandport ("192.168.1.197", 7005));9Nodes.Add (NewHostandport ("192.168.1.198", 7006));TenJediscluster Jediscluster =Newjediscluster (nodes); OneJediscluster.set ("name", "Lee"); AJediscluster.set ("Age", "18"); -String name = Jediscluster.get ("name"); -String value = Jediscluster.get ("Age"); the System.out.println (name); - System.out.println (value); - jediscluster.close (); -}
Operation Result:
You can see that the IP is not the same when you fetch data from the Redis client
Redis one or two-build a clustered cache server