redis cluster version installation

1. Installation 

Installation introduction: Install 6 nodes, 3 master nodes, and 3 slave nodes. Since redis requires 3 master nodes by default, if you want each master node to have a slave node, this is the minimum configuration requirement. The ports are all 6379.

Note: During installation, attention should be paid to ensure that the active and standby machines are on different physical machines.

 

1.1. Installation preparation

Software: redis-3.2.5

Create a redis user and extract redis-3.2.5.tar.gz to the /home/redis/ directory.

wget http://download.redis.io/releases/redis-3.2.5.tar.gz

3.2.5 is the official recommended stable release version

 

1.2, modify the configuration

 

All 6 nodes modify the redis.conf file in the redis-3.2.5 directory

 

daemonize yes # redis is not started in the background by default, here is modified to start in the background
cluster-enabled yes # Allow redis to support cluster mode
cluster-config-file nodes.conf # node configuration file
cluster-node-timeout 15000 # Node timeout in milliseconds
appendonly yes
dir /data/redis/ #redis backup file storage location
maxmemory 21474836480 #redis maximum memory usage is 20G

 (maxmemory-policy noeviction ,don't expire at all, just return an error on write operations)

 

and execute on 6 nodes

 make

   make install

 

1.3, start the instance

Execute src/redis-server redis.conf on 6 nodes respectively, and start 6 redis instances on 6 nodes

 

1.4, build a redis cluster

Select a node and operate the following command.

Install ruby ​​environment

yum -y install ruby

yum -y install rubygem

 

Install ruby's redis api

gem install -l ./redis-3.2.2.gem

 

Start the cluster.

./redis-trib.rb create --replicas 1 xxx.xxx.xx.140:6379 xxx.xxx.xx.141:6379 xxx.xxx.xx.143:6379 xxx.xxx.xx.145:6379 xxx.xxx.xx.147:6379 xxx.xxx.xx.148:6379

--replicas 1 means that we want to create a slave node for each master node in the cluster. Since a redis cluster requires at least 3 master nodes, if we need a slave node for each master node, then a minimum of 6 machines (or say 6 instances). 145, 147, and 148 will be the master nodes, and 140, 141, and 143 will be called slave nodes of the master node in turn. (It seems that the last 3 are the main ones, and the first 3 are spares)

 

1.5. Test cluster

./redis-cli -c

 

1.6, stop the redis instance

At this stage, the running status of the redis server is monitored. We use the command script that comes with redis to explain the corresponding parameter items by ourselves.

$ ps -ef | grep redis
redis    15540     1  0 Jun23 ?        00:17:18 src/redis-server *:6379 [cluster]

$ kill -9  15540

 

 

2. Monitoring

2.1. Monitoring content

At this stage, the running status of the redis server is monitored. We use the command script that comes with redis to explain the corresponding parameter items by ourselves.

 

[redis@kzx-zczq13 redis-3.2.5]$ src/redis-cli -c
127.0.0.1:6379> info
# Server
redis_version:3.2.5
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:c1345887f338f67c
redis_mode:cluster
os:Linux 2.6.32-431.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:15540
run_id:898d9c378eac7b4db48fa83f0ccb9c9998a8f295
tcp_port:6379
uptime_in_seconds:1037501
uptime_in_days:12
hz:10
lru_clock:8093545
config_file:/home/redis/redis-3.2.5/redis.conf
 
# Clients
connected_clients:2
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
 
# Memory
used_memory:9513768
used_memory_human:9.07M
used_memory_rss:16265216
used_memory_peak:9513768
used_memory_peak_human:9.07M
used_memory_lua:36864
mem_fragmentation_ratio:1.71
mem_allocator:jemalloc-3.6.0
 
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1467710054
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:1
rdb_current_bgsave_time_sec:-1
aof_enabled:1
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:0
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_current_size:1958322
aof_base_size:0
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0
 
# Stats
total_connections_received:7
total_commands_processed:142817
instantaneous_ops_per_sec:0
total_net_input_bytes:3407347
total_net_output_bytes:40598277
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.05
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:857
migrate_cached_sockets:0
 
# Replication
role:slave
master_host:22.104.166.77
master_port:6379
master_link_status:up
master_last_io_seconds_ago:2
master_sync_in_progress:0
slave_repl_offset:3406433
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
 
# CPU
used_cpu_sys:679.89
used_cpu_user:358.52
used_cpu_sys_children:0.23
used_cpu_user_children:0.44
 
# Cluster
cluster_enabled:1
 
# Keyspace
db0:keys=38782,expires=0,avg_ttl=0
 

 

2.2、查看主从信息

 

127.0.0.1:6379> cluster nodes
455c329c3d3d4d00d6711dba5d350b832209ae56 22.104.166.73:6379 slave 4138a8dbfff68cb73e6acb11e7a3b93344b7f6d2 0 1467711490518 5 connected
dbcb30cb58cbc8fcc138a43b64aac60f63fe8e7c 22.104.166.72:6379 slave 8094e32bfd639448bca02ef5189cd62bca78b7ad 0 1467711491519 4 connected
7c7f42d7442f8037acfb7695ebf182548cae82e0 22.104.166.74:6379 myself,slave 036b37d9e680d79f196b63d2bc1d31ee65a72310 0 0 3 connected
8094e32bfd639448bca02ef5189cd62bca78b7ad 22.104.166.75:6379 master - 0 1467711488512 4 connected 10923-16383
4138a8dbfff68cb73e6acb11e7a3b93344b7f6d2 22.104.166.76:6379 master - 0 1467711492521 5 connected 5461-10922
036b37d9e680d79f196b63d2bc1d31ee65a72310 22.104.166.77:6379 master - 0 1467711485504 6 connected 0-5460
 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326987735&siteId=291194637