• redis 集群搭建


    1.创建redis-cluster文件夹,拷贝reids下的bin目录全部文件到redis-cluster文件夹下

    cp -a redis/bin redis-cluster/redis01

    2.编辑redis01下的redis.conf,修改端口为7001,设置cluster-enabled yes

    3.拷贝redis01 =》redis02 =》redis03 04 05 06 并依次修改端口为7002-7006

    4.安装ruby相关环境

    yum install rubygems

    5.安装rvm(ruby的管理工具,使用yum install ruby无法安装2.0以上的ruby)

    gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

    curl -sSL https://get.rvm.io | bash -s stable

    find / -name rvm -print

    source /usr/local/rvm/scripts/rvm

    rvm install 2.4.1

    redis requires ruby version 2.2.2的问题,以上命令来自https://www.cnblogs.com/PatrickLiu/p/8454579.html

    6.安装ruby对redis的接口

    gem install redis

    7.拷贝  redis源码包/src/redis-trib.rb  到 redis-cluster文件夹下(切换为你自己的IP)

    ./redis-trib.rb create --replicas 1 192.168.101.102:7001 192.168.101.102:7002 192.168.101.102:7003 192.168.101.102:7004 192.168.101.102:7005 192.168.101.102:7006

    8.编写脚本

    如果在windows下编写再上传至linux的需要set ff=unix,否则执行报错

    启动

     1 #!/bin/bash
     2 cd /opt/module/redis-cluster/redis01/
     3 ./redis-server redis.conf
     4 cd /opt/module/redis-cluster/redis02/
     5 ./redis-server redis.conf
     6 cd /opt/module/redis-cluster/redis03/
     7 ./redis-server redis.conf
     8 cd /opt/module/redis-cluster/redis04/
     9 ./redis-server redis.conf
    10 cd /opt/module/redis-cluster/redis05/
    11 ./redis-server redis.conf
    12 cd /opt/module/redis-cluster/redis06/
    13 ./redis-server redis.conf

    停止

     1 #!/bin/bash
     2 cd /opt/module/redis-cluster/redis01/
     3 ./redis-cli -p 7001 shutdown
     4 cd /opt/module/redis-cluster/redis02/
     5 ./redis-cli -p 7002 shutdown
     6 cd /opt/module/redis-cluster/redis03/
     7 ./redis-cli -p 7003 shutdown
     8 cd /opt/module/redis-cluster/redis04/
     9 ./redis-cli -p 7004 shutdown
    10 cd /opt/module/redis-cluster/redis05/
    11 ./redis-cli -p 7005 shutdown
    12 cd /opt/module/redis-cluster/redis06/
    13 ./redis-cli -p 7006 shutdown

    切换为你的路径,修改权限后再执行

    9.执行完启动脚本后

    10.随便选择一个端口连接,连接集群时带上-c,可以执行redis01/redis-cli --help查看redis-cli的命令参数

  • 相关阅读:
    如何实现Appium每次运行可不用卸载手机上的Appium Settings 和Unlock
    jmeter参数化----绝对路径&相对路径
    python获取元素之byxpath()的八种方法
    uiautomatorviewer连接机器点击报错Unexpected error while obtaining UI hierarchy
    【Jmeter】使用 jmeter的_time函数获取时间
    博客作业第三周
    博客作业第二周
    博客作业第一周
    关于测试
    抽象工厂模式(AbstractFactory)
  • 原文地址:https://www.cnblogs.com/tele-share/p/11460680.html
Copyright © 2020-2023  润新知