Skip to main content

Centos7.0 redis cluster installation

Centos7.0 redis cluster installation

1. Install [redis](/search?q=redis) (use redis3.2.1 version)

1. Install necessary packages

 
yum install gcc

2. Download the redis3.2.1 installation package

 #redis installer download directory (to personal preference)

cd /home/htld/tools



#Execute downloads

wget https://download.redis.io/releases/redis-3.2.1.tar.gz





3. Unzip the source code package

  #decompression

tar -zxvf redis-3.2.1.tar.gz





4. Enter the decompression directory and compile

  #Go to the redis-3.2.1 directory.

cd redis-3.2.1/



#compiling

make



After the make command is executed, this executable file will be generated in the src directory, which are redis-server, redis-cli, redis-benchmark, and redis-stat. Their functions are as follows:

  • redis-server: Daemon startup program of Redis server
  • redis-cli: Redis command line operation tool. Of course, you can also use telnet to operate according to its plain text protocol
  • redis-benchmark: Redis performance testing tool, test the read and write performance of Redis under your system and your configuration
  • redis-stat: Redis status detection tool, which can detect Redis current status parameters and delay conditions

5. Install redis

 
make install PREFIX=/usr/local/redis

2. Start redis

1. Copy redis-conf from the redis-3.2.1 file to the redis installation directory

 
cp /home/htld/tools/redis-3.2.1/redis.conf /usr/local/redis/

2. Then modify the redis.conf file

Centos7.0 redis cluster installation

3. Start redis in the bin directory

 
./redis-server ../redis.conf

4. Kill all redis nodes

 
pkill -9 redis

3. Construction of redis cluster

1. Install ruby ​​environment

1.1 Online installation

 
yum install ruby

2. Download redis-3.2.1.gem

Install ruby ​​packages

 
gem install redis-3.2.1.gem

3. Modify redis.conf

Centos7.0 redis cluster installation

Centos7.0 redis cluster installation

Centos7.0 redis cluster installation

4. Copy the redis-trib.rb command in the redis-3.2.1 directory

 
cp /home/htld/tools/redis-3.2.1/src/redis-trib.rb /usr/local/redis/bin/

5. In the same way, repeat the above steps on the other 5 servers.

6. After the redis installation and configuration of the 6 servers are successful, start the redis of the 6 servers separately.

   

cd /usr/local/redis/bin/

#priming command

./redis-server ../redis.conf



7. Randomly select a server and execute the create cluster command

 
./redis-trib.rb create --replicas 1 192.168.200.41:6379 192.168.200.42:6379 192.168.200.43:6379 192.168.200.44:6379 192.168.200.45:6379 192.168.200.46:6379

Centos7.0 redis cluster installation

8. On another server, detect the cluster again (optional)

 
./redis-trib.rb check 192.168.200.43:6379

Centos7.0 redis cluster installation