最近搭阿里云redis集群遇到的坑https://my.oschina.net/u/3647713/blog/1941842到安装目录: cd /usr/local/ 下载redis: wget http://download.redis.io/releases/redis-4.0.10.tar.gz 解压:tar -zxvf redis-4.0.10.tar.gz cd redis-4.0.10 编译:make && make install PREFIX=/usr/local/redis 搭建集群所需要的环境: yum install rubyyum install rubygemsyum install redis (报错redis requires Ruby version >= 2.2.2查看文章http://blog.51cto.com/jinchuang/2117479) 创建集群目录:mkdir /usr/local/redis_cluster mkdir /usr/local/redis_cluster/7000 mkdir /usr/local/redis_cluster/7001 mkdir /usr/local/redis_cluster/7002 mkdir /usr/local/redis_cluster/7003 mkdir /usr/local/redis_cluster/7004 mkdir /usr/local/redis_cluster/7005 复制: /usr/local/redis-4.0.10 下的redis.conf到/usr/local/redis/bincp redis.conf /usr/local/redis/bin/集群一7000端口 cd /usr/local/redis/bin vi redis.conf 修改端口为port 7000 cluster-enabled yes // 开启集群 bind 0.0.0.0 // 允许远程连接daemonize yes pidfile /var/run/redis_7000.pid 修改sudo cp ./* /usr/local/redis_cluster/7000 将目录下所有文件拷贝到文件7000下 集群二7001端口 vi redis.conf 修改端口为port 7001 cluster-enabled yes // 开启集群bind 0.0.0.0 // 允许远程连接 daemonize yespidfile /var/run/redis_7001.pid 修改sudo cp ./* /usr/local/redis_cluster/7001集群三7002端口 vi redis.conf 修改端口为port 7002cluster-enabled yes // 开启集群 bind 0.0.0.0 // 允许远程连接daemonize yes pidfile /var/run/redis_7002.pid 修改sudo cp ./* /usr/local/redis_cluster/7002 集群四7003端口 vi redis.conf 修改端口为port 7003 cluster-enabled yes // 开启集群bind 0.0.0.0 // 允许远程连接 daemonize yespidfile /var/run/redis_7003.pid 修改 sudo cp ./* /usr/local/redis_cluster/7003 集群五7004端口 vi redis.conf 修改端口为port 7004cluster-enabled yes // 开启集群bind 0.0.0.0 // 允许远程连接daemonize yes pidfile /var/run/redis_7004.pid 修改 sudo cp ./* /usr/local/redis_cluster/7004 集群六7005端口 vi redis.conf修改端口为port 7005 cluster-enabled yes // 开启集群bind 0.0.0.0 // 允许远程连接 daemonize yes pidfile /var/run/redis_7005.pid 修改 sudo cp ./* /usr/local/redis_cluster/7005
依次道7000 7001 7002 7003 7004 7005目录下启动redis; 启动命令./redis-server redis.conf 在原先编译目录下src文件下创建集群 cd /usr/local/redis-4.0.10/src/ ./redis-trib.rb create --replicas 1 外网IP:7000 外网IP:7001 外网IP:7002 外网IP:7003 外网IP:7004 外网IP:7005