redis cluster3.2.8 cluster construction

   Installation environment centos7 ip: 192.168.5.181

 

1. Download the installation package

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

 

2. Unzip, compile and install

tar xzf redis-3.2.8.tar.gz

cd redis-3.2.8

make && make install

 

3. Create a startup instance

  

cd /root
mkdir -p redis_cluster/6001
#Create a file
vi redis.conf
#The content is as follows:
        bind	192.168.5.181
        daemonize    yes
	port    6001
	pidfile  /var/run/redis_6001.pid
	cluster-enabled  yes
	cluster-config-file  nodes_6001.conf
	cluster-node-timeout  6000
	appendonly  yes
    
mkdir -p redis_cluster/6002
#Create a file
vi redis.conf
#The content is as follows:
        bind	192.168.5.181
        daemonize    yes
	port    6002
	pidfile  /var/run/redis_6002.pid
	cluster-enabled  yes
	cluster-config-file  nodes_6002.conf
	cluster-node-timeout  6000
	appendonly  yes

#Create 6003, 6004, 6005, 6006 in sequence The same as the above creation method, omitted here...


#Create a startup script:
cd /root/redis_cluster
vi start_all.sh
#The content is as follows
   cd 6001
   redis-server  6001/redis.conf
   cd ../6002
   redis-server  6002/redis.conf
   cd ../6003
   redis-server  6003/redis.conf
   cd ../6004
   redis-server  6004/redis.conf
   cd ../6005
   redis-server  6005/redis.conf
   cd ../6006
   redis-server  6006/redis.conf
   
chmod +x start_all.sh
   
./start_all.sh

 

   View the redis process:

  

ps -ef | grep redis

   The result is as follows

root     16623     1  0 16:19 ?        00:00:00 redis-server 127.0.0.1:6001 [cluster]
root     16625     1  0 16:19 ?        00:00:00 redis-server 127.0.0.1:6002 [cluster]
root     16629     1  0 16:19 ?        00:00:00 redis-server 127.0.0.1:6003 [cluster]
root     16631     1  0 16:19 ?        00:00:00 redis-server 127.0.0.1:6004 [cluster]
root     19355     1  0 16:24 ?        00:00:00 redis-server 127.0.0.1:6005 [cluster]
root     19398     1  0 16:24 ?        00:00:00 redis-server 127.0.0.1:6006 [cluster]

 

 4. Use redis-trib.rb to create a redis cluster

    Install the redis-trib.rb runtime environment ruby

yum -y install ruby ruby-devel rubygems rpm-build

 

   It takes about 30 seconds to install ruby's redis interface

gem install redis
cd /root/src/redis-3.2.8/src
cp redis-trib.rb /root/redis_cluster

   Make a startup script and start

vi start_cluster.sh
#content
redis-trib.rb  create  --replicas  1  192.168.5.181:6001    192.168.5.181:6002 192.168.5.181:6003 192.168.5.181:6004 192.168.5.181:6005 192.168.5.181:6006
  
chmod +x start_cluster.sh
./start_cluster.sh

   If there is no error in the startup, and the installation is successful

 

5. Test redis-cluster

    Check the current status of the cluster:

redis-cli -c -p 6001
	127.0.0.1:6001> cluster info

 

   Test the stored value:

127.0.0.1:6001> set niaho hello
127.0.0.1:6001> get nihao

 

 

 

    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326346635&siteId=291194637