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

    redis 主:
    
    将主从redis配置文件redis.conf中的aemonize no 改为 yes
    
    
    jrhrpt01:/etc/redis# grep port redis.conf 
    # Accept connections on the specified port, default is 6379.
    # If port 0 is specified Redis will not listen on a TCP socket.
    port 6379
    
    jrhrpt01:/etc/redis# grep slaveof  redis.conf 
    # Master-Slave replication. Use slaveof to make a Redis instance a copy of
    # slaveof <masterip> <masterport>
    
    redis 从:
    
    jrhrpt02:/etc/redis# grep slaveof  redis.conf 
    # Master-Slave replication. Use slaveof to make a Redis instance a copy of
    # slaveof <masterip> <masterport>
    slaveof 11.40.69.216 6379  ---redis 主
    
    
    # If the master is password protected (using the "requirepass" configuration
    # directive below) it is possible to tell the slave to authenticate before
    # starting the replication synchronization process, otherwise the master will
    # refuse the slave request.
    #
    #masterauth <master-password>
    masterauth xxxxx
    
    
    
    
    启动redis:
    redis-server /etc/redis.conf
    
    
    测试:
    主
    test-redis:/root# cat a1.pl 
    use Redis;
    my $r = Redis->new( server => "192.168.32.167:6379",reconnect => 1,every=>60);
     $r = Redis->new( password =>  'xxxxx' );
      $r->set('zhoucui','111222333');
      $r->save;
      $r->quit;
    perl a1.pl
    
    
    
    从:
    test-redis2:/data01/redis# redis-server --/etc/redis.conf^C
    test-redis2:/data01/redis# redis-cli 
    127.0.0.1:6379> auth 'xxx'
    OK
    127.0.0.1:6379> get zhoucui
    "111222333"
    127.0.0.1:6379> 

  • 相关阅读:
    C语言考点例题解析
    五笔打字
    常用快捷键
    网络基础知识
    人口增长
    8 封装
    9 绑定方法和非绑定方法
    6 抽象类
    7 多态和多态性
    5 组合
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351683.html
Copyright © 2011-2022 走看看