Getting started with Redis-installation, getting started with redis
Redis Cluster Construction
Requirement: Create 6 nodes, 3 master and 3 slave nodes
127.0.0.1: 6379
127.0.0.1: 6380
127.0.0.1: 6381
127.0.0.1: 6382
127.0.0.1: 6383
127.0.0.1: 6384
1. Download The redis installation package
[Root @ redis1 ~] # Wget http://download.redis.io/releases/redis-3.0.0.tar.gz
2. Unzip and install
[Root @ redis1 ~] # Tar xf redis-3.0.0.tar.gz
[Root @ redis1 ~] # Cd redis-3.0.0
[Root @ redis1 redis-3.0.0] # make & make install
[Root @ redis1 ~] # MVS redis-3.0.0 redis
[Root @ redis1 ~] # Cd redis
[Root @ redis1 redis] # mkdir conf logs data
3. Create the redis conf file
######################################## #############
[Root @ redis1 redis] # cd conf
[Root @ redis1 conf] # vim redis_62.16.conf
# Include general configurations
Include/usr/local/yunji/redis/redis_global.conf
# Listening to tcp ports
Port 6379
# Aof file storage
Appendfilename "appendonly-6379.aof"
# Rdb file, used only for dynamic addition of slave Process
Dbfilename dump-6379.rdb
# Log files
Logfile "/usr/local/yunji/redis/logs/redis-6379.log"
# Cluster configuration file (automatically generated at startup)
Cluster-config-file nodes-6379.conf
# When the size of the currently written log file is a certain percentage of the size of the initial log file, the Rewrite is triggered.
# Deploy apsaradb for redis instances on the same machine and turn off auto-aof-rewrite to prevent all apsaradb for redis processes from performing rewrite instantly, occupying a large amount of memory
Auto-aof-rewrite-percentage 40
######################################## #############
Ps: create multiple nodes: cp redis_62.16.conf redis _ *****. conf, modify the corresponding port content
4. Start
[Root @ redis1 redis] # redis-server redis_62.16.conf
[Root @ redis1 redis] # redis-server redis_6380.conf
[Root @ redis1 redis] # redis-server redis_6381.conf
[Root @ redis1 redis] # redis-server redis_6382.conf
[Root @ redis1 redis] # redis-server redis_6383.conf
[Root @ redis1 redis] # redis-server redis_6384.conf
5. Check whether the process exists.
[Root @ redis1 redis] # ps-ef | grep redis
Root 14253 1 0 Sep24? 00:00:06 redis-server *: 6380 [cluster]
Root 14257 1 0 Sep24? 00:00:06 redis-server *: 6381 [cluster]
Root 14265 1 0 Sep24? 00:00:06 redis-server *: 6383 [cluster]
Root 14269 1 0 Sep24? 00:00:06 redis-server *: 6384 [cluster]
Root 15067 1 0 00:29? 00:00:04 redis-server *: 6379 [cluster]
Root 48175 1 0 00:56? 00:00:03 redis-server *: 6382 [cluster]
Root 48405 1 0? 00:00:03 redis-server *: 6385 [cluster]
Root 48497 1 0? 00:00:03 redis-server *: 6386 [cluster]
Root 49408 49329 0 00:00:00 pts/1 grep -- color = auto redis
Ps: Normally there should be 6 nodes of the process
6. Run the command to create a cluster. First install the dependency. Otherwise, the cluster fails to be created.
[Root @ redis1 redis] # yum install ruby rubygems-y
# Install gem-redis and upload it to linux
: Https://rubygems.org/gems/redis/versions/3.0.0
[Root @ redis1 redis] # gem install-l redis-3.0.0.gem
# Copy the cluster hypervisor to/usr/local/bin.
[Root @ redis1 redis] # cp redis/src/redis-trib.rb/usr/local/bin/redis-trib
7. Create a cluster
Redis-trib create -- replicas 1 127.0.0.1: 6379 127.0.0.1: 6380 127.0.0.1: 6381 127.0.0.1: 6382 127.0.0.1: 6383 127.0.0.1: 6384
The command has the following meanings:
# The command given to the redis-trib.rb program is create, Which means we want to create a new cluster.
# Option -- replicas 1 indicates that we want to create a slave node for each master node in the cluster.
# The other parameters that follow are the address list of the instance. We want the program to use the instance indicated by these addresses to create a new cluster.
# Simply put, the above commands mean that the redis-trib program should create a cluster containing three master nodes and three slave nodes.
# Next, redis-trib will print out an expected configuration for you. If you think it is okay, enter yes, redis-trib will apply this configuration to the cluster.
Enter the following information normally:
............
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
This step is complete ···!