• Redis-部署主从


    环境

    系统 IP 软件 备注
    centos7 192.168.153.130 redis5.0.8
    centos7 192.168.153.131 redis5.0.8

    源码编译安装

    ]# wget http://download.redis.io/releases/redis-5.0.8.tar.gz
    ]# tar xf redis-5.0.8.tar.gz;cd redis-5.0.8
    ]# make && make install # make install 是为了能够在/usr/local/bin目录下产生redis-server/cli等文件
    

    主服务器配置文件修改

    ]# vim /opt/program/redis-5.0.8/redis.conf
    ...
    bind 192.168.153.130 127.0.0.1 #绑定本地网卡
    daemonize yes #可以后台运行
    port 6379
    pidfile /var/run/redis_6379.pid
    logfile "/opt/program/redis-5.0.8/redis_6379.log"
    
    ]# redis-server /opt/program/redis-5.0.8/redis.conf #启动redis-server
    

    从服务器配置文件修改

    ]# vim /opt/program/redis-5.0.8/redis.conf
    bind 192.168.153.131 127.0.0.1 #
    daemonize yes #可以后台运行
    port 6379
    pidfile /var/run/redis_6379.pid
    logfile "/opt/program/redis-5.0.8/redis_6379.log"
    
    replicaof 192.168.153.130 6379
    
    ]# redis-server /opt/program/redis-5.0.8/redis.conf #启动redis-server
    

    注意点

    • bind
    1. 只是为了设置接口地址,能够让其他机器通过接口地址访问
    2. 想要限制其他ip访问需要设置防火墙或者protected-mode
    • protected-mode 保护模式是否开启
    1. 'yes'生效条件,缺一不可
    ]# vim redis.conf
    bind 192.168.153.130 127.0.0.1
    protected-mode yes
    requirepass pass123
    
    1. 若设置保护模式,从服务器也需要更改配置文件
    ]# vim redis.conf
    replicaof 192.168.153.130 6379
    masterauth pass123 #增加此项
    
  • 相关阅读:
    setlocale
    c++的 程序实体 作用域 名空间 变量生存期概念理解
    本人的Ubuntu 10.04配置清单
    hadoopStreamming 编程 Angels
    级联 mapreduce (Cascading Mapreduce) Angels
    委托
    OPC和XML/SOAP/Web Services
    实例管理2(会话服务)
    实例管理3()
    操作(Operation)
  • 原文地址:https://www.cnblogs.com/wanwz/p/12794772.html
Copyright © 2020-2023  润新知