Redis 3.0.2高可用集群(中)------ Redis-Cluster部署

         好,原文再续,书接上一回,上回我介绍了一下Redis的安装,这回我们来配一下集群------Redis Cluster

 

Redis-Cluster安装部署步骤

 

1.         下载zlib-1.2.8.tar.gzruby-2.2.2.tar.gzrubygems-2.4.8.tgzredis-3.2.1.gem(ruby安装包比较大、rubygem的文件格式不能上传,所以大家自己想办法,其他两个见附件)

 

2.          安装:

    1)        安装zlib

           a)        tar –zxvf  zlib-1.2.8.tar.gz

           b)        cd zlib-1.2.8

           c)      ./configure

           d)        make

           e)        make install

 

     2)         安装ruby

    a)        tar –zxvf  ruby-2.2.2.tar.gz

    b)      cd  ruby-2.2.2

    c)         ./configure -prefix=/usr/local/ruby

    d)       make

    e)         make  install

    f)        sudo cp ruby /usr/local/bin

 

      3)          安装rubygems

            a)       tar –zxvf  rubygems-2.4.8.tgz

            b)     cd rubygems-2.4.8

            c)      sudo ruby setup.rb 

            d)     sudo cp bin/gem /usr/local/bin  

      4)         安装ruby-redis-3.2.1.gem插件

             a)        gem install -l ruby-redis-3.2.1.gem

           

 

       5)        配置redis-cluster启动脚本 

              a)        cd /%redis_home%/src  redis-trib.rb  /usr/local/bin/redis-trib

 

 3.         部署

A10.92.21.17

实例1端口6379

实例2 端口7379

实例3 端口8379

B10.92.21.18

实例1端口6380

实例2 端口7380

实例3 端口8380

 

       1.         A/B mkdir  /opt/redis

       2.         cd /opt/redis

       3.         mkdir  6379/ 7379/ 8379/6380/ 7380/ 8380

       4.       cd 6379/ 7379/ 8379/6380/ 7380/ 8380

       5.       cp /%redis_home%/redis_conf  6379.conf/7379.conf/8379.conf

 

# include /path/to/local.conf
# include /path/to/other.conf
daemonize yes
pidfile /var/run/redis_6379/ 7379/ 8379/6380/ 7380/ 8380.pid
port 6379/ 7379/ 8379/6380/ 7380/ 8380
tcp-backlog 511
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1
# unixsocket /tmp/redis.sock
# unixsocketperm 700
timeout 0
tcp-keepalive 0
loglevel  notice 
logfile "/var/log/redis_6379/ 7379/ 8379/6380/ 7380/ 8380.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /opt/redis/6379/ 7379/ 8379/6380/ 7380/ 8380
# slaveof <masterip> <masterport>
# masterauth <master-password>
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
# repl-ping-slave-period 10
# repl-timeout 60
repl-disable-tcp-nodelay no
# repl-backlog-size 1mb
# repl-backlog-ttl 3600
slave-priority 100
# min-slaves-to-write 3
# min-slaves-max-lag 10
# min-slaves-max-lag is set to 10.
# requirepass foobared
# rename-command CONFIG ""
# maxclients 10000
# maxmemory <bytes>
# maxmemory-policy noeviction
# maxmemory-samples 5
appendonly yes
appendfilename "appendonly.aof"
# appendfsync always
appendfsync everysec
# appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
cluster-enabled yes
cluster-config-file nodes-6379/ 7379/ 8379/6380/ 7380/ 8380.conf
cluster-node-timeout 5000
# cluster-slave-validity-factor 10
# cluster-migration-barrier 1
# cluster-require-full-coverage yes
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
list-max-ziplist-entries 512
list-max-ziplist-value 64
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
 

 

      6.         编写实例启动脚本 stop.sh

 

killall redis-server

sudo rm /opt/redis/6379(6380)/*.aof
sudo rm /opt/redis/6379(6380)/node*

sudo rm /opt/redis/7379(7380)/*.aof
sudo rm /opt/redis/7379(7380)/node*

sudo rm /opt/redis/8379(8380)/*.aof
sudo rm /opt/redis/8379(8380)/node*
  7            编写实例启动脚本   startRedis.sh

 

redis-server /opt/redis/6379(6380)/6379(6380).conf
redis-server /opt/redis/7379(7380)/7379(7380).conf
redis-server /opt/redis/8379(8380)/8379(8380).conf

 

     8.          Chmod  777  -R  /opt/redis opt/redis目录赋权限

     9.        在opt/redis目录执行 stop.shstartRedis.sh即可进行多个实例的启动

     10.       redis-trib create --replicas 1 10.92.21.17:6379 10.92.21.17:7379  10.92.21.17:8379 10.92.21.18:6380 10.92.21.18:7380 10.92.21.18:8380

这里有个地方需要注意的,我不确定是不是个bug,如果 redis-trib create在A机上执行,那么把10.92.21.17改成127.0.0.1的同时把A的3个实例同时放到前三位,即redis-trib create --replicas 1 127.0.0.1:6379 127.0.0.1:7379  127.0.0.1:8379 10.92.21.18:6380 10.92.21.18:7380 10.92.21.18:8380的话就会启动不redis-cluster,会一直卡在waiting the cluster join.....

 

验证


Redis 3.0.2高可用集群(中)------ Redis-Cluster部署
 
Redis 3.0.2高可用集群(中)------ Redis-Cluster部署
 

 

你可能感兴趣的:(cluster)