• centos 搭建redis主从


    centos 搭建redis主从

    !!! 由于这是在虚拟机中做的测试,配置过程中可能出现错误,记得看日志

    查看主从信息:  info replication

    搭建主从确保,两台服务器直接可以连通, ping 连接ok, redis 互相可以登录

    redis 主: 192.168.56.3      redis 从: 192.168.56.101 

    我的这两台服务器redis密码都设置为123456, redis.conf 中bind 已经注释

    1). 测试1:

    [root@localhost vagrant]# ping 192.168.56.101
    PING 192.168.56.101 (192.168.56.101) 56(84) bytes of data.
    64 bytes from 192.168.56.101: icmp_seq=1 ttl=64 time=0.149 ms
    64 bytes from 192.168.56.101: icmp_seq=2 ttl=64 time=0.163 ms
    64 bytes from 192.168.56.101: icmp_seq=3 ttl=64 time=0.152 ms
    64 bytes from 192.168.56.101: icmp_seq=4 ttl=64 time=0.173 ms
    ^C
    --- 192.168.56.101 ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 2999ms
    rtt min/avg/max/mdev = 0.149/0.159/0.173/0.013 ms
    [root@localhost vagrant]# 
    [root@localhost vagrant]# ping 192.168.56.3
    PING 192.168.56.3 (192.168.56.3) 56(84) bytes of data.
    64 bytes from 192.168.56.3: icmp_seq=1 ttl=64 time=0.175 ms
    64 bytes from 192.168.56.3: icmp_seq=2 ttl=64 time=0.134 ms
    64 bytes from 192.168.56.3: icmp_seq=3 ttl=64 time=0.149 ms
    64 bytes from 192.168.56.3: icmp_seq=4 ttl=64 time=0.140 ms
    ^C
    --- 192.168.56.3 ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 2999ms
    rtt min/avg/max/mdev = 0.134/0.149/0.175/0.019 ms
    [root@localhost vagrant]#

    测试2 , redis 互相登录:

    #在192.168.56.3 上登录 192.168.56.101
    
    [root@localhost vagrant]#  /usr/bin/redis-cli -h 192.168.56.101 -a 123456
    192.168.56.101:6379> keys *
    
    
    
    #在192.168.56.101 上登录 192.168.56.3
    
    [root@localhost vagrant]# /usr/bin/redis-cli -h 192.168.56.3 -a 123456
    192.168.56.3:6379> keys *

    2).  配置主从:

    在conf服务器上 redis.conf 中配置  

    slaveof 192.168.56.3 6379
    
    masterauth 123456

    3). 配置完毕,测试数据:

     redis 教程,基础使用

  • 相关阅读:
    Reverse linked list
    Implement Queue by Two Stacks
    Min Stack
    Search a 2D Matrix
    50. Pow(x, n)
    监控hdfs的一个目录,若有新文件,spark就开始处理这个文件,可以使用spark streaming textfilestream来监控该目录
    kafka2在重启消费者以后已经提交offset回退了 什么原因(待完善)
    Hybrid Recommender Systems: Survey and Experiments
    开源实时日志分析平台
    scala为什么要清理闭包
  • 原文地址:https://www.cnblogs.com/dafei4/p/12939097.html
Copyright © 2020-2023  润新知