ruby-2.4.0.tar.gz
rubygems-2.6.10.tgz
zlib-1.2.11.tar.gz
redis-3.3.2.gem
名称 | IP | 端口 | 节点属性 |
redisA | 192.168.6.128 | 6379 | 主节点 |
redisB | 192.168.6.128 | 9379 | 从节点 |
redisC | 192.168.6.129 | 6379 | 主节点 |
redisD | 192.168.6.129 | 9379 | 从节点 |
redisE | 192.168.6.130 | 6379 | 主节点 |
redisF | 192.168.6.130 | 9379 | 从节点 |
参照 来安装架构中的实例。
ruby-2.4.0
- # tar zxvf ruby-2.4.0.tar.gz
- # cd ruby-2.4.0
- # ./configure prefix=/usr/local/ruby
- # make
- # make install
- # echo 'export PATH="$PATH:/usr/local/ruby/bin"' >> /etc/profile
- # source /etc/profile
- # ruby -v
rubygems-2.6.10
- # tar zxvf rubygems-2.6.10.tgz
- # cd rubygems-2.6.10
- # ruby setup.rb
- # gem -v
zlib-1.2.11.tar.gz
- # tar zxvf zlib-1.2.11.tar.gz
- # cd zlib-1.2.11
- # ./configure --prefix=/usr/local/zlib
- # make
- # make install
为 ruby-2.4.0 包中的文件。
- # cd ruby-2.4.0/ext/zlib
- # ruby ./extconf.rb --with-zlib-dir=/usr/local/zlib
- # make
- # make install
返回信息:
redis-3.3.2.gem
- gem install -l redis-3.3.2.gem
返回信息:
- # cp redis.conf redis-cluster.conf
- # vi redis-cluster.conf
编辑配置文件:
1)更改的内容:
- daemonize no 更改为 daemonize yes
- logfile "" 更改为 logfile "/root/redisA/logs/redis.log" # 需要创建 logs 目录
- dir ./ 更改为 dir /root/redisA/data #需要创建 data 目录
- appendonly no 更改为 appendonly yes
2)去掉注释的内容
- # cluster-enabled yes
- # cluster-config-file nodes-6379.conf
- # cluster-node-timeout 15000
- # cluster-slave-validity-factor 10
- # cluster-migration-barrier 1
- # cluster-require-full-coverage yes
- # ./src/redis-server redis-cluster.conf
- # ps -ef|grep redis|grep -v grep
- # ./src/redis-trib.rb create --replicas 1 192.168.6.128:6379 192.168.6.128:9379 192.168.6.129:6379 192.168.6.129:9379 192.168.6.130:6379 192.168.6.130:9379
--replicas 1 表示每个主节点下有一个从节点。
默认是前三个为主节点,后三个为从节点。
默认情况下不能从 slaves 读取数据,但建立连接后,执行一次命令 READONLY,该 slaves 即可读取数据。
- >>> Creating cluster
- Connecting to node 192.168.6.128:6379: OK
- Connecting to node 192.168.6.128:9379: OK
- Connecting to node 192.168.6.129:6379: OK
- Connecting to node 192.168.6.129:9379: OK
- Connecting to node 192.168.6.130:6379: OK
- Connecting to node 192.168.6.130:9379: OK
- >>> Performing hash slots allocation on 6 nodes...
- Using 3 masters:
- 192.168.6.128:6379
- 192.168.6.129:6379
- 192.168.6.130:6379
- Adding replica 192.168.6.129:9379 to 192.168.6.128:6379
- Adding replica 192.168.6.128:9379 to 192.168.6.129:6379
- Adding replica 192.168.6.130:9379 to 192.168.6.130:6379
- M: 31f6b90cfe190d94f39bef42449bdb7efe1b85b0 192.168.6.128:6379
- slots:0-5460 (5461 slots) master
- S: 02c6f0321ebbaf52fe42dd372e5daf179ca77853 192.168.6.128:9379
- replicates 90fec8236d68d9e89262a1ae101056fa1da6df25
- M: 90fec8236d68d9e89262a1ae101056fa1da6df25 192.168.6.129:6379
- slots:5461-10922 (5462 slots) master
- S: 5cf4bd75f93514e1895f8bb5bb7042ae23f277e7 192.168.6.129:9379
- replicates 31f6b90cfe190d94f39bef42449bdb7efe1b85b0
- M: 82889edd96156daa109e84868ceda24a0272ee82 192.168.6.130:6379
- slots:10923-16383 (5461 slots) master
- S: 9e238a85863ea02fc534fc870db4f47fd79b9ef6 192.168.6.130:9379
- replicates 82889edd96156daa109e84868ceda24a0272ee82
- Can I set the above configuration? (type 'yes' to accept): yes
- >>> Nodes configuration updated
- >>> Assign a different config epoch to each node
- >>> Sending CLUSTER MEET messages to join the cluster
- Waiting for the cluster to join.....
- >>> Performing Cluster Check (using node 192.168.6.128:6379)
- M: 31f6b90cfe190d94f39bef42449bdb7efe1b85b0 192.168.6.128:6379
- slots:0-5460 (5461 slots) master
- 1 additional replica(s)
- M: 90fec8236d68d9e89262a1ae101056fa1da6df25 192.168.6.129:6379
- slots:5461-10922 (5462 slots) master
- 1 additional replica(s)
- S: 5cf4bd75f93514e1895f8bb5bb7042ae23f277e7 192.168.6.129:9379
- slots: (0 slots) slave
- replicates 31f6b90cfe190d94f39bef42449bdb7efe1b85b0
- S: 9e238a85863ea02fc534fc870db4f47fd79b9ef6 192.168.6.130:9379
- slots: (0 slots) slave
- replicates 82889edd96156daa109e84868ceda24a0272ee82
- M: 82889edd96156daa109e84868ceda24a0272ee82 192.168.6.130:6379
- slots:10923-16383 (5461 slots) master
- 1 additional replica(s)
- S: 02c6f0321ebbaf52fe42dd372e5daf179ca77853 192.168.6.128:9379
- slots: (0 slots) slave
- replicates 90fec8236d68d9e89262a1ae101056fa1da6df25
- [OK] All nodes agree about slots configuration.
- >>> Check for open slots...
- >>> Check slots coverage...
- [OK] All 16384 slots covered.
- # ./src/redis-cli -c -h 192.168.6.128 -p 6379
连接成功则返回:
1)连接 192.168.6.128 的 6379 端口,并存入数据
2)连接 192.168.6.130 的 9379 端口,并读取数据
来源: http://www.cnblogs.com/RUReady/p/6439763.html