• redis主从配置


    1.主节点安装部署
    [root@localhost redis-4.0.14]# cd src
    [root@localhost src]# make PREFIX=/opt/redis-master-slave/master install
    [root@localhost src]# cp redis-trib.rb /opt/redis-master-slave/master/

    2.创建目录并修改相应权限
    [root@localhost src]# mkdir -p /opt/redis-master-slave/master/conf
    [root@localhost src]# mkdir -p /opt/redis-master-slave/master/logs
    [root@localhost src]# mkdir -p /opt/redis-master-slave/master/run
    [root@localhost src]# mkdir -p /opt/redis-master-slave/master/data


    3.从节点安装部署
    [root@localhost redis-4.0.14]# cd src
    [root@localhost src]# make PREFIX=/opt/redis-master-slave/slave install
    [root@localhost src]# cp redis-trib.rb /opt/redis-master-slave/slave/


    4.创建目录并修改相应权限
    [root@localhost src]# mkdir -p /opt/redis-master-slave/slave/conf
    [root@localhost src]# mkdir -p /opt/redis-master-slave/slave/logs
    [root@localhost src]# mkdir -p /opt/redis-master-slave/slave/run
    [root@localhost src]# mkdir -p /opt/redis-master-slave/slave/data



    5.主从节点分别启动
    主节点
    /opt/redis-master-slave/master/bin/redis-server /opt/redis-master-slave/master/conf/7001.conf
    从节点
    /opt/redis-master-slave/slave/bin/redis-server /opt/redis-master-slave/slave/conf/7002.conf

    主节点配置文件(7001.conf)内容:
    bind 192.168.1.85
    daemonize yes
    pidfile /opt/redis-master-slave/master/run/redis-7001.pid
    port 7001
    tcp-backlog 511
    timeout 300
    tcp-keepalive 300
    loglevel notice
    logfile "/opt/redis-master-slave/master/logs/redis-7001.log"
    databases 16
    save 900 1
    save 300 10
    save 60 10000
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    dir /opt/redis-master-slave/master/data
    slave-serve-stale-data yes
    slave-read-only yes
    repl-diskless-sync no
    repl-diskless-sync-delay 5
    repl-disable-tcp-nodelay no
    slave-priority 100
    appendonly yes
    appendfilename "appendonly.aof"
    appendfsync everysec
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    aof-load-truncated yes
    lua-time-limit 5000
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    latency-monitor-threshold 0
    notify-keyspace-events ""
    hash-max-ziplist-entries 512
    hash-max-ziplist-value 64
    list-max-ziplist-entries 512
    list-max-ziplist-value 64
    set-max-intset-entries 512
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
    hll-sparse-max-bytes 3000
    activerehashing yes
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit slave 256mb 64mb 60
    client-output-buffer-limit pubsub 32mb 8mb 60
    hz 10
    aof-rewrite-incremental-fsync yes
    # Generated by CONFIG REWRITE
    masterauth "hxlpasswd"
    requirepass "hxlpasswd"
    protected-mode yes


    从节点配置文件(7002.conf)内容:
    bind 192.168.1.85
    daemonize yes
    pidfile /opt/redis-master-slave/slave/run/redis-7002.pid
    port 7002
    tcp-backlog 511
    timeout 300
    tcp-keepalive 300
    loglevel notice
    logfile "/opt/redis-master-slave/slave/logs/redis-7002.log"
    databases 16
    save 900 1
    save 300 10
    save 60 10000
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    dir /opt/redis-master-slave/slave/data
    slave-serve-stale-data yes
    slave-read-only yes
    repl-diskless-sync no
    repl-diskless-sync-delay 5
    repl-disable-tcp-nodelay no
    slave-priority 100
    appendonly yes
    appendfilename "appendonly.aof"
    appendfsync everysec
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    aof-load-truncated yes
    lua-time-limit 5000
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    latency-monitor-threshold 0
    notify-keyspace-events ""
    hash-max-ziplist-entries 512
    hash-max-ziplist-value 64
    list-max-ziplist-entries 512
    list-max-ziplist-value 64
    set-max-intset-entries 512
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
    hll-sparse-max-bytes 3000
    activerehashing yes
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit slave 256mb 64mb 60
    client-output-buffer-limit pubsub 32mb 8mb 60
    hz 10
    aof-rewrite-incremental-fsync yes
    # Generated by CONFIG REWRITE
    masterauth "hxlpasswd"
    requirepass "hxlpasswd"
    protected-mode yes
    slaveof 192.168.1.85 7001


    6.验证
    主库设置key
    /opt/redis-master-slave/master/bin/redis-cli -h 192.168.1.85 -p 7001 -a hxlpasswd
    192.168.1.85:7001> set name hxl

    从库读取key
    /opt/redis-master-slave/slave/bin/redis-cli -h 192.168.1.85 -p 7002 -a hxlpasswd
    192.168.1.85:7002> get name
    "hxl"

  • 相关阅读:
    Selenium(一):元素定位
    白盒测试系列(五)条件组合覆盖
    LDAP(轻型目录访问协议)
    Spring Intorduce、History and Design Philosophy
    CORS
    mysql创建用户并授权某个数据库
    Introduce Servlet 、Filter
    web.xml的简单解释以及Hello1中web.xml的简单分析
    ANNOTATION and analyse hello1.java
    Analysis of container and Injection in Java, their history and future.
  • 原文地址:https://www.cnblogs.com/hxlasky/p/13744426.html
Copyright © 2020-2023  润新知