# Redis 4.0.1 链接:https://pan.baidu.com/s/1z0VWbPmrYlcjA-WEqrjjEg 提取码:um77 复制这段内容后打开百度网盘手机App,操作更方便哦 ## Centos7(kernel:3.10.0693.11.1.el7.x86_64) ## 192.168.1.111 ## 192.168.1.112 ## 192.168.1.113 #### 192.168.1.111: 1) mv redis-4.0.1.tar.gz /usr/local/ 2) tar -zxvf redis-4.0.1.tar.gz 3) cd /usr/local 3) yum install rsync 4) rsync -avz --delete -e 'ssh' /usr/local/redis-4.0.1/ 192.168.1.112:/usr/local/redis-4.0.1/ 5) rsync -avz --delete -e 'ssh' /usr/local/redis-4.0.1/ 192.168.1.113:/usr/local/redis-4.0.1/ 6) cd redis-4.0.1 7) make 8) cd src 9) mkdir -p /root/app/redis 10)mkdir -p /root/app/redis/bin /root/app/redis/etc /root/app/redis/logs /root/app/redis/data 11)cp mkreleasehdr.sh redis-check-aof redis-cli redis-server redis-benchmark redis-check-rdb redis-sentinel redis-trib.rb /root/app/redis/bin/ 12)上传配置文件redis.7000.conf和redis.7001.conf到/root/app/redis/etc 13)mkdir -p /root/app/redis/data/7000 14)mkdir -p /root/app/redis/data/7001 15)rsync -avz --delete -e 'ssh' /root/app/ 192.168.1.112:/root/app/ 16)rsync -avz --delete -e 'ssh' /root/app/ 192.168.1.113:/root/app/ 17)上传redis服务启动文件redis_7000和redis_7001到 /etc/init.d 18) rsync -avz --delete -e 'ssh' /etc/init.d/redis_7000 192.168.1.112:/etc/init.d/redis_7000 19) rsync -avz --delete -e 'ssh' /etc/init.d/redis_7000 192.168.1.113:/etc/init.d/redis_7000 20) rsync -avz --delete -e 'ssh' /etc/init.d/redis_7001 192.168.1.112:/etc/init.d/redis_7001 21) rsync -avz --delete -e 'ssh' /etc/init.d/redis_7001 192.168.1.113:/etc/init.d/redis_7001 22)chmod -R 777 /root/app/ 23)chmod 777 /etc/init.d/redis_7000 24)chmod 777 /etc/init.d/redis_7001 25)service redis_7000 start 26)service redis_7001 start 27)检查各节点是否启动 查看进程 ps -ef | grep redis 查看端口 netstat -tnlp | grep redis 28)安装Ruby(ruby-2.4.1.tar.gz) yum install -y zlib-devel yum install -y openssl-devel tar xzvf ruby-2.4.1.tar.gz 29)cd ruby-2.4.1 30)./configure --prefix=/usr/local --disable-install-doc --with-opt-dir=/usr/local/lib && make && make install 31)安装redis cluster依赖包 gem install redis 32)systemctl stop firewalld.service 33)cd /root/app/redis/bin ./redis-trib.rb create --replicas 1 192.168.1.111:7000 192.168.1.111:7001 192.168.1.112:7000 192.168.1.112:7001 192.168.1.113:7000 192.168.1.113:7001 34)./redis-cli -h 192.168.1.111 -p 7000 192.168.1.111:7000> info Replication # Replication role:master connected_slaves:1 slave0:ip=192.168.1.112,port=7001,state=online,offset=45220,lag=1 master_replid:9e84b9b8a409ea2d3ec68ca038b3373dd531ed87 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:45220 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:45220 192.168.1.111:7000> # cluster nodes ![](https://img.kancloud.cn/37/3d/373db30475366d39a9dd14f040395531_1337x121.png)