zoukankan      html  css  js  c++  java
  • redis 主从

    redis主从:
    
    ```python
    # 进入桌面conf目录 创建两个配置文件, 内容如下:
    
    # redis.conf
    daemonize yes
    pidfile ./redis-server.pid
    port 6377
    bind 10.211.55.15
    
    
    # slave.conf
    daemonize yes
    pidfile ./redis-server-slave.pid
    port 6378
    bind 10.211.55.15
    slaveof 10.211.55.15 6377
    ```
    
    ```python
    # 启动 主/从 redis服务
    redis-server redis.conf
    redis-server slave.conf
    
    # 测试主从读写
    redis-cli -h 10.211.55.15 -p 6377
    set/get
    
    redis-cli -h 10.211.55.15 -p 6378
    get        # 无法set
    
    # django中使用:
    # 配置
    CACHES = {
        "write": {  # 主服务
            "BACKEND": "django_redis.cache.RedisCache",
            "LOCATION": "redis://10.211.55.15:6377/10",
            "OPTIONS": {
                "CLIENT_CLASS": "django_redis.client.DefaultClient",
            }
        },
        "read": {  # 从服务
            "BACKEND": "django_redis.cache.RedisCache",
            "LOCATION": "redis://10.211.55.15:6378/10",
            "OPTIONS": {
                "CLIENT_CLASS": "django_redis.client.DefaultClient",
            }
        },
    }
    
    # 测试
    from django_redis import get_redis_connection
    w_client = get_redis_connection('write')
    r_client = get_redis_connection('read')
    ```
  • 相关阅读:
    KMP算法
    找出第二大的数
    webpack 3 优化
    CocoaPods安装
    自适应水平垂直居中
    找出两个数组中都有,并且重复次数最多的元素
    swift 笔记
    Promise 用es5的基础实现
    $.ajax仿axios封装
    js基础拖拽效果
  • 原文地址:https://www.cnblogs.com/mldsh/p/13624883.html
Copyright © 2011-2022 走看看