• redis4.0 cluster搭建


    
    cd /root/tools
    
    wget http://pnxcvm0bq.bkt.clouddn.com/redis-4.0.9.tar.gz
    
    tar -zxvf redis-4.0.9.tar.gz
    
    mkdir -p  /home/heron/redis-cluster/redis-6379
    
    cd redis-4.0.9
    
    make PREFIX=/home/heron/redis-cluster/redis-6379/  install
    
    mkdir /home/heron/redis-cluster/redis-6379/{conf,data,log,pid}
    
    wget http://pnxcvm0bq.bkt.clouddn.com/redis.conf
    
    mv redis.conf /home/heron/redis-cluster/redis-6379/conf/
    
    chown -R heron.heron /home/heron/redis-cluster/
    
    cat >> /home/heron/supervisor/conf/supervisord.conf << EOF
    
    [program:redis-6379]
    user=heron
    command=/home/heron/redis-cluster/redis-6379/bin/redis-server /home/heron/redis-cluster/redis-6379/conf/redis.conf
    directory=/home/heron/redis-cluster/redis-6379/
    
    EOF
    
    /home/heron/superctl update
    
    yum -y  install zlib ruby rubygems
    
    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
    
    rvm use 2.4.1
    
    ruby --version
    
    gem install redis
    
    cp -rp /root/tools/redis-4.0.9/src/redis-trib.rb  /usr/local/bin/
    
    cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6380
    cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6381
    cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6382
    cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6383 
    cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6384
    
    sed -i  's/6379/6380/g' /home/heron/redis-cluster/redis-6380/conf/redis.conf 
    sed -i  's/6379/6381/g' /home/heron/redis-cluster/redis-6381/conf/redis.conf 
    sed -i  's/6379/6382/g' /home/heron/redis-cluster/redis-6382/conf/redis.conf 
    sed -i  's/6379/6383/g' /home/heron/redis-cluster/redis-6383/conf/redis.conf 
    sed -i  's/6379/6384/g' /home/heron/redis-cluster/redis-6384/conf/redis.conf 
    
    sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6379/conf/redis.conf
    sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6380/conf/redis.conf
    sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6381/conf/redis.conf
    sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6382/conf/redis.conf
    sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6383/conf/redis.conf
    sed -i 's/#cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6384/conf/redis.conf
    
    sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6379/conf/redis.conf
    sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6380/conf/redis.conf
    sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6381/conf/redis.conf
    sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6382/conf/redis.conf
    sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6383/conf/redis.conf
    sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6384/conf/redis.conf
     
    cat >> /home/heron/supervisor/conf/supervisord.conf << EOF
    [program:redis-6380]
    user=heron
    command=/home/heron/redis-cluster/redis-6380/bin/redis-server /home/heron/redis-cluster/redis-6380/conf/redis.conf
    directory=/home/heron/redis-cluster/redis-6380/
    
    [program:redis-6381]
    user=heron
    command=/home/heron/redis-cluster/redis-6381/bin/redis-server /home/heron/redis-cluster/redis-6381/conf/redis.conf
    directory=/home/heron/redis-cluster/redis-6381/
    
    [program:redis-6382]
    user=heron
    command=/home/heron/redis-cluster/redis-6382/bin/redis-server /home/heron/redis-cluster/redis-6382/conf/redis.conf
    directory=/home/heron/redis-cluster/redis-6382/
    
    [program:redis-6383]
    user=heron
    command=/home/heron/redis-cluster/redis-6383/bin/redis-server /home/heron/redis-cluster/redis-6383/conf/redis.conf
    directory=/home/heron/redis-cluster/redis-6383/
    
    [program:redis-6384]
    user=heron
    command=/home/heron/redis-cluster/redis-6384/bin/redis-server /home/heron/redis-cluster/redis-6384/conf/redis.conf
    directory=/home/heron/redis-cluster/redis-6384/
    EOF
    
    chown -R heron.heron /home/heron/redis-cluster/
    
    /home/heron/superctl update
    
    /home/heron/superctl restart redis-6379
    
    /usr/local/bin/redis-trib.rb  create  --replicas  1 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384
    
    

    php连接参考:

        'redis_cluser_host'=>[
            '127.0.0.1:6379',
            '127.0.0.1:6380',
            '127.0.0.1:6381',
    	'127.0.0.1:6382',
    	'127.0.0.1:6383',
    	'127.0.0.1:6384',
        ],
    
    
    赵客缦胡缨,吴钩霜雪明。 银鞍照白马,飒沓如流星。
  • 相关阅读:
    应用程序池溢出问题
    弹窗上传图片
    第三方监测
    服务器架设方案
    python随笔录入月份的值,输出对应的季节
    用python计算直角三角形斜边长
    返回(统计)一个列表中出现次数最多的元素
    使用random函数实现randint函数的功能
    Spring
    ng build prod basehref /javaweb/angular/
  • 原文地址:https://www.cnblogs.com/boy215/p/10488666.html
Copyright © 2020-2023  润新知