ITPub博客

首页 > 数据库 > NoSQL > Redis master and slave

Redis master and slave

原创 NoSQL 作者:21ca 时间:2017-03-16 10:38:42 0 删除 编辑
1. Download Redis zip package for Windows: https://github.com/ServiceStack/redis-windows

2. Copy redis.windos.conf to master.conf and slave.conf.

3. master.conf
    port: 6379

4. slave.conf
   port: 6378
    slaveof 127.0.0.1 6379

5. Start Redis
    redis-server.exe master.conf
    redis-server.exe slave.conf

6. Write to master and read from slave:
  1. public class RedisTest {
  2.     public static void main(String[] args) {
  3.         Jedis master = new Jedis("127.0.0.1", 6379);
  4.         Jedis slave = new Jedis("127.0.0.1", 6378);

  5.         master.set("name", "test");
  6.         
  7.         System.out.println(master.get("name"));
  8.         System.out.println(slave.get("name"));
  9.         
  10.         master.close();
  11.         slave.close();
  12.     }
  13. }


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10742815/viewspace-2135456/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: HDFS read and write
请登录后发表评论 登录
全部评论

注册时间:2009-03-24

  • 博文量
    58
  • 访问量
    104835