Get the App
SLTechnology News&Howtos  ›  Database  › 

Reids configuration Cluster

Shulou Source: shulou.com Published: 2022-06-01 08:50:17 09月26日 Update

Why is there a cluster?

We have talked about the concept of master and slave before. One master can have more than one slave. If the number of visits at the same time is too large (1000W), the master service will definitely fail, and the data service will die or a natural disaster will occur.

Large companies will have a lot of servers (East China, South China, Central China, North China, Northwest, Southwest, Northeast, Taiwan, Hong Kong and Macao)

The concept of cluster

A cluster is a group of independent computers interconnected through a high-speed network that form a group and are managed in a single system mode. When a customer interacts with a cluster, the cluster is like an independent server. Cluster configuration is used to improve availability and scalability.

When the request arrives, it is first processed by the load balancing server and forwarded to another server.

Redis cluster

classification

Software level

Hardware level

Software level: there is only one computer, on which multiple redis services are started.

Hardware level: there are multiple physical computers, each with a redis or multiple redis services started.

Set up a cluster

Currently, there are two hosts, 172.16.179.130,172.16.179.131. The IP of this server should be changed to the actual value when it is used.

Reference reading

Set up http://www.cnblogs.com/wuxl360/p/5920330.html in redis cluster

[Python] build redis cluster http://blog.5ibc.net/p/51020.html

After configuring the cluster, do the following:

Python interaction

The installation package is as follows

Pip install redis-py-cluster

Redis-py-cluster source code address https://github.com/Grokzen/redis-py-cluster

Create a spare redis_cluster.py. The sample code is as follows

From rediscluster import * if _ _ name__ = ='_ _ main__': try: # build all the nodes, Redis will make the CRC16 algorithm Write keys and values to a node startup_nodes = [{'host':' 192.168.26.128, 'port':' 7000'}, {'host':' 192.168.26.130, 'port':' 7003'}, {'host':' 192.168.26.128, 'port':' 7001'} ] # build StrictRedisCluster object src=StrictRedisCluster (startup_nodes=startup_nodes,decode_responses=True) # set the key to name and the value to itheima result=src.set ('name','itheima') print (result) # get the key to name name = src.get (' name') print (name) except Exception as e: print (e)

Tags: Cluster region service level server computer configuration multiple data concept hardware node software reference independent balanced master-slave host function only Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Microsoft NVidia Docker Redmi