zoukankan      html  css  js  c++  java
  • redis集群的布置

    前期准备

      需要准备至上两台以上的而服务器,并且这两台服务器上必须安装redis

    第一步:

      在其中一台服务中创建三个文件,如下:

      

    #第一个,以7000.conf为名
    port 7000
    bind 172.16.0.14 #(通过ifconfig来获取,否则会出问题)
    daemonize yes
    pidfile 7000.pid
    cluster-enabled yes
    cluster-config-file 7000_node.conf
    cluster-node-timeout 15000
    appendonly yes
    
    #第二个,以7001.conf为名
    port 7001
    bind 172.16.0.14  #(通过ifconfig来获取,否则会出问题)
    daemonize yes
    pidfile 7001.pid
    cluster-enabled yes
    cluster-config-file 7001_node.conf
    cluster-node-timeout 15000
    appendonly yes
    
    #第三个,以7002.conf为名
    port 7002
    bind 172.16.0.14  #(通过ifconfig来获取,否则会出问题)
    daemonize yes
    pidfile 7002.pid
    cluster-enabled yes
    cluster-config-file 7002_node.conf
    cluster-node-timeout 15000
    appendonly yes
    

      完成以后分别执行以下三行代码 

    #第一步
    sudo redis-server 7000.conf
    #第二步
    sudo redis-server 7001.conf
    #第三部
    sudo redis-server 7002.conf
    

      若输入ps aux | grep redis出现如下效果则成功

      

     第二步

      在另一台机器上创建如下三个文件

      

    #第一个,以7003.conf为名
    port 7003
    bind 172.16.0.15 #(通过ifconfig来获取,否则会出问题)
    daemonize yes
    pidfile 7003.pid
    cluster-enabled yes
    cluster-config-file 7003_node.conf
    cluster-node-timeout 15000
    appendonly yes
    
    #第二个,以7004.conf为名
    port 7004
    bind 172.16.0.15  #(通过ifconfig来获取,否则会出问题)
    daemonize yes
    pidfile 7004.pid
    cluster-enabled yes
    cluster-config-file 7004_node.conf
    cluster-node-timeout 15000
    appendonly yes
    
    #第三个,以7005.conf为名
    port 7005
    bind 172.16.0.15  #(通过ifconfig来获取,否则会出问题)
    daemonize yes
    pidfile 7005.pid
    cluster-enabled yes
    cluster-config-file 7005_node.conf
    cluster-node-timeout 15000
    appendonly yes

    完成以后执行以下三行代码

    #第一步
    sudo redis-server 7003.conf
    #第二步
    sudo redis-server 7004.conf
    #第三部
    suod redis-server 7005.conf
    

      执行命令ps aux | grep redis 若出现如下效果,怎表示成功

      

    第三步

      前期工作做好以后

      将redis-trib.rb 移动到/usr/local/bin 中,而redis-trib.rb 一般在集成在redis安装包的 src 目录下

      当然,在使用它之前,你需要,安装ruby,执行以下命令 

    sudo apt-get install ruby
    

      然后执行如下命令

    redis-trib.rb create --replicas 1 172.16.199:7001  172.16.199:7002  172.16.199:7003  172.16.199:7004  172.16.199:7005  172.16.199:7000  
    

      然后可能会报如下错

     这是因为安装的ruby不是最新版本的

    解决方法如下:

    #第一步,查看源
    gem source -l 
    #如果是https://rabygems.org/
    #则需要进行更新源
    gem soures --add https://gems.ruby-china.com/ --remove https://rubygems.org/
    #下载下载依赖包
    sudo gem install redis
    #在执行一遍
    sudo apt-get install ruby
    #最后执行
    redis-trib.rb create ......#这一句,就可以搞定了
    

      如出现如下效果,则成功了

    搞定!!!!!!!!!

      

  • 相关阅读:
    正则表达式收藏
    c#mvc实现登录
    jQuery获取URL中的参数
    TortoiseSVN新人使用指南
    CheckBox获取一组及全选
    day45
    day44
    day43
    day43
    day42
  • 原文地址:https://www.cnblogs.com/117698ai/p/12218366.html
Copyright © 2011-2022 走看看