Rapid deployment of redis (active/standby)

(1) Rapid deployment of Redis

A Redis instance can be deployed with the default configuration by the following steps:

wget http://download.redis.io/releases/redis-3.2.4.tar.gz
tar xzf redis-3.2.4.tar.gz
cd redis-3.2.4
make
src/redis-server & <-- start redis with default configuration
src/redis-cli -p 6379 <-- access redis via terminal, default port 6379

(2) Modify the Redis.conf configuration

  •  The configuration of Redis is uniformly controlled by the redis.conf file in the root directory. The following is an example of the deployment port number 6381 to list the configuration items that need to be modified (for a detailed description of each configuration item, refer to redis.conf itself).
  • Add the configuration file of the 6381 instance (if deploying multiple instances, add the corresponding configuration file):
cp redis-3.2.4/redis.conf redis-3.2.4/redis6381.conf
  • Edit redis6381.conf, pay attention to the configuration of the following options:

   #1. The process file needs to be modified to deploy a single machine and multiple instances (it is recommended to distinguish by port number)

     pidfile "/var/run/redis6381.pid"

#2. Port number, you need to modify port 6381    to deploy single-machine multi-instance
   

   #3. Log level, it is recommended to default to it, printing details will lose a certain performance
   loglevel notice

   #4. The log file needs to be modified when deploying a single machine and multiple instances (it is recommended to distinguish by port number). In addition, you need to add write permission to the directory where the log is located.
   logfile "/var/log/redis/6381.log"

   #5.rdb persistence strategy, the default is
     save 900 1                         
     save 300 10
     save 60 10000

   #6.rdb persistent file, it needs to be modified to deploy single machine and multiple instances (it is recommended to distinguish by port number)
    dbfilename "dump6381.rdb"

   #7. Access password, if it is a master-slave structure, note that the slave password must be the same as the master
     masterauth <master-password>

   #8. Master-slave replication, specify the master address (the master does not need to be configured, the slave can configure this item )
    slaveof 127.0.0.1 6379
   #9. The maximum number of client connections                               
     maxclients 1000

   #10. Maximum occupied memory
     maxmemory 1gb

   #11. Cleaning policy
     maxmemory-policy allkeys-lru after the memory reaches the upper limit

   #12. Turn off aof persistence
     appendonly no    

   #13. Although aof is not used, it is best to modify it if you deploy a single machine with multiple instances (it is recommended to distinguish by port number)
     appendfilename "appendonly6381.a of"

(3) Start the Redis service

    (1) Start Redis by specifying the configuration file:

redis-3.2.4/src/redis-server ./../redis6381.conf &

 

    (2) Start multiple redis instances on a single machine:

           Copy the conf file, after modifying the port, use the new configuration file to start

(4) Use the client to connect to Redis

    Access Redis through the specified port, and different ports connect to different instances;

redis-3.2.4/src/redis-cli -p 6381  

 

 

 

 

 

 

 

 

 

Guess you like

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