Redis cluster configuration

Source: Internet
Author: User
Tags redis cluster

1. Download the tar package

redis-3.2.8.tar.gz

2. decompress the package to the specified directory.

sudo tar -xzvf redis-3.2.8.tar.gz -C /soft

3. Install the GCC compiler

sudo yum install -y gcc

4. Compile and install redis

$> Su root $> Cd ~ /Redis-3.2.8 # specify the installation directory $> make prefix =/soft/redis-3.2.8 install

5. Set soft connections and configure Environment Variables

Cluster construction:

1. Create the conf directory under/soft/redis

// Create six directories in conf: 7000-70005
For (I = 7000; I <7006; I ++); Do mkdir $ I; done;

2. template configuration file, redis. conf

################################## NETWORK #####################################bind 192.168.137.101protected-mode noport 7000tcp-backlog 511timeout 0tcp-keepalive 300################################# GENERAL #####################################daemonize yessupervised nopidfile /var/run/redis_7000.pidloglevel noticelogfile ""databases 16################################ SNAPSHOTTING  ################################save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump_7000.rdbdir /home/centos/redis_dbfile################################# REPLICATION #################################slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100################################## SECURITY ###################################################################### LIMITS ################################################################## APPEND ONLY MODE ###############################appendonly noappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yes################################ LUA SCRIPTING  ###############################lua-time-limit 5000################################ REDIS CLUSTER  ###############################cluster-enabled yescluster-config-file nodes-7000.conf################################## SLOW LOG ###################################slowlog-log-slower-than 10000slowlog-max-len 128################################ LATENCY MONITOR ##############################latency-monitor-threshold 0############################# EVENT NOTIFICATION ##############################notify-keyspace-events ""############################### ADVANCED CONFIG ###############################hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes

3. Move the configuration to directories.

for(( i=7000;i<7006 ;i++)) ;do cp ./redis.conf $i ;done;

4. Modify

for(( i=7000;i<7006 ;i++)) ;do sed -i s/7000/$i/g $i/redis.conf  ;done;

5. Install the gem and integrate the redis cluster into the cluster.

// Install gem
Sudo Yum install-y gem
// Delete the old gem
Sudo gem sources -- remove https://rubygems.org/
// Add a new gem Source
Sudo gem sources-A https://gems.ruby-china.com/
// Use gem to install redis 3.0.0
Sudo gem install redis -- version 3.0.0

6. Add the redis process on each host to the cluster tribe

// Only change the operation for the first time
/Home/centos/redis-3.2.8/src/redis-trib.rb create -- replicas 1 192.168.137.101: 7000 192.168.137.101: 7001 192.168.137.101: 7002 192.168.137.101: 7003 192.168.137.101: 7004 192.168.137.101: 7005

Yes

7. Start the client to connect to the Cluster

redis-cli -c -h 192.168.231.101 -p 70000

8. Test cluster redirection through key operations

 

Management Cluster:

1. Start the redis Cluster

for x in 0 1 2 3 4 5 ; do redis-server 700$x/redis.conf ;done

2. Kill the redis Process

$>su root$>netstat -anop |grep 700 |grep LIST | awk ‘{print $7}‘ | awk-F / ‘{print $1}‘ | kill -9 `xargs`

3. View All redis Processes

netstat -anop |grep 700 |grep LIST

 

Redis cluster configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.