Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Reids configuration Cluster

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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)

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report