redis三主三従配置


サーバA:192.168.3.188 centos 7サーバB:192.168.3.189 centos 7 firewalldファイアウォールを閉じ、selinuxを閉じます.redisバージョン4.0.1、少なくとも6台はredis clusterをします
yum -y install wget vim tcl gcc make
mkdir –p /usr/local/redis
cd !$
wget http://download.redis.io/releases/redis-4.0.1.tar.gz
tar –xvf redis-4.0.1.tar.gz
make
make test-     
       
/usr/local/redis/redis-4.0.1/tests/integration
replication-2.tcl   after 10000
  redis       
cp -a src/redis-server src/redis-cli src/redis-sentinel src/redis-trib.rb src/redis-check-aof src/redis-check-rdb src/redis-benchmark /usr/local/bin/
mkdir cluster-redis
cd cluster-redis
mkdir {7000,7001,7002}

そのうちの1つはredis.confプロファイルの内容
bind 192.168.3.188
protected-mode yes
port 7000
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_7000.pid
loglevel notice
logfile "/usr/local/redis/cluster-redis/7000/redis_7000.log"
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump7000.rdb
dir /usr/local/redis/cluster-redis/7000/
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly yes
appendfilename "appendonly7000.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
cluster-enabled yes
cluster-config-file nodes-7000.conf
cluster-node-timeout 15000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

他のredisプロファイルは、対応するポートとデータベース名を変更すればよいので、redisを順次起動します.
redis-server /usr/local/redis/cluster-redis/7000/redis.conf
redis-server /usr/local/redis/cluster-redis/7001/redis.conf
redis-server /usr/local/redis/cluster-redis/7002/redis.conf——           redis  

次の2つの依存関係、zlibとopensslを事前にインストールします.
yum -y install zlib-devel
yum install openssl-devel -y
   ruby,ruby-2.3.4.tar.gz,       
./configure
Make && make install
Ruby –v    2.2.2  

redisをインストールし、インストールできない場合はgemソースを切り替え、次のリンクを見てgemソースを交換します.https://ruby.taobao.org/
Gem install redis

クラスタの起動
redis-trib.rb create --replicas 1 192.168.3.188:7000 192.168.3.188:7001 192.168.3.188:7002 192.168.3.189:7000 192.168.3.189:7001 192.168.3.189:7002

あるノードにログイン
redis-cli 192.168.3.188 -c -p 7001

クラスタの状態を確認
cluster info
cluster nodes