zoukankan      html  css  js  c++  java
  • redis 集群部署

    redis 部署生产中一般存在三种:

    1、单机

    2、哨兵(主从)

    3、集群

    今天主要整理的是集群部分,在产生环境应该的比较多,集群中至少需要3个主数据库才能正常运行。

    部署版本与环境

    linux:redhat 7.0

    redis:redis-4.0.6

    rudy(默认redhat7.0自带的2.0.0)

    安装redis

    redis-4.0.6.tar.gz
    cd redis-4.0.6

    make

    make install

    安装很简单.然后建立以下目录,将redis.conf复制到目录下

    redis-4.0.6
    redis-4.0.6-01
    redis-4.0.6-02

    redis.conf文件说明:

    cluster-enabled yes    #开启集群功能
    cluster-config-file nodes-6379.conf  #记录集群状态

    port 6379  #修改端口

    dir "/tmp   #路径

    dbfilename "dump.rdb"  #数据库名称

    daemonize yes   #如果为yes的话,后台运行

    基本的配置修改以上项就可以了。

    redis 中提供了一个辅助工具redis-trib.rb 可以很简单的完成集群初始化,在使用这个工具前提要安装ruby.  然后安装一个插件

    1、在线安装插件

    gem install redis

    2、离线安装插件

    手动下载https://rubygems.org/  redis插件  版本选择redis-3.3.5.gem。

    gem install redis-3.3.5.gem

    启动各节点redis

    redis-server redis.conf   #启动

    redis-cli  -p 6379  #登录

    info cluster   #查看节点

    #Cluster

    cluster_enabled:1    #1表示集群正常使用了

    开始初始化集群

     cd redis-4.0.6/src
    ./redis-trib.rb create 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381
    >>> Creating cluster
    >>> Performing hash slots allocation on 3 nodes...
    Using 3 masters:
    127.0.0.1:6379
    127.0.0.1:6380
    127.0.0.1:6381
    M: 4e7acc44a19f39ee620944387327ca3fe4f54422 127.0.0.1:6379
       slots:0-5460 (5461 slots) master
    M: 4d685b9d12ceff9905bdb05fc3b83be481676ebb 127.0.0.1:6380
       slots:5461-10922 (5462 slots) master
    M: a388a5042ce4c578454569b94e5297c14dd99d89 127.0.0.1:6381
       slots:10923-16383 (5461 slots) master
    Can I set the above configuration? (type 'yes' to accept):
    >>> Nodes configuration updated
    >>> Assign a different config epoch to each node
    >>> Sending CLUSTER MEET messages to join the cluster
    Waiting for the cluster to join..
    >>> Performing Cluster Check (using node 127.0.0.1:6379)
    M: 4e7acc44a19f39ee620944387327ca3fe4f54422 127.0.0.1:6379
       slots:0-5460 (5461 slots) master
       0 additional replica(s)
    M: 4d685b9d12ceff9905bdb05fc3b83be481676ebb 127.0.0.1:6380
       slots:5461-10922 (5462 slots) master
       0 additional replica(s)
    M: a388a5042ce4c578454569b94e5297c14dd99d89 127.0.0.1:6381
       slots:10923-16383 (5461 slots) master
       0 additional replica(s)
    [OK] All nodes agree about slots configuration.
    >>> Check for open slots...
    >>> Check slots coverage...
    [OK] All 16384 slots covered.

    到这里集群就部署完毕了。

  • 相关阅读:
    vmware ubuntu 异常关机无法连接到网络
    Speed up GCC link
    常用的一些解压命令
    Log4j 漏洞复现
    Test Case Design method Boundary value analysis and Equivalence partitioning
    CCA (Citrix Certified Administrator) exam of “Implementing Citrix XenDesktop 4”
    What is Key Word driven Testing?
    SAP AGS面试小结
    腾讯2013终端实习生一面
    指针的引用
  • 原文地址:https://www.cnblogs.com/mrice/p/10730309.html
Copyright © 2011-2022 走看看