Redis configuration, startup, operation and shutdown

Redis configuration, startup, operation and shutdown

1. Start Redis

   1. The default configuration starts

     Execute the redis-server command to start Redis according to the configuration in the default redis.conf configuration file, as follows:

    Because the default configuration cannot customize the configuration. So this method will not be used in the production environment

   2. Run configuration startup

    Add the configuration name and value to be modified after the command redis-server (multiple pairs can be set), if there is no setting, the default configuration will be used.

     For example: redis-server --port 6389 --timeout 3000

   Although the configuration can be customized. However, if the modified configuration is more, it should be saved in the configuration file, and this method is not recommended.

(config file startup

    Write the configuration file to the specified redis.conf file, and specify the path of the configuration file after the redis-server command during startup, then redis will start according to the configuration of the configuration file redis.conf. For example: redis-server redis.conf

2. Redis command line client redis-cli

    1 How redis-cli connects to the server

     (1) Cluster interactive

         redis-cli -c -h 10.3.34.101 -p 7000

     (2) Stand-alone interactive mode

redis-cli -c -h 10.3.34.101 -p 7000

     (3) Command method

redis-cli -c -h 10.3.34.101 -p 7000 set aaa 1

    

     The above command, if there is no -h parameter, the default connection is 127.0.0.1, if there is no -p parameter, the default connection is 6370 port

3. Stop the Redis service

(1) After connecting to the server through redis-cli, execute the shutdown command to stop the redis service.

(2) In addition to shutting down the redis server using the shutdown command, you can also shut down the redis service by using kill+process number.

(3) Do not use the Kill 9 method to close the redis process, so that redis will not perform persistent operations. In addition, resources such as buffers will not be closed gracefully, and in extreme cases, AOF and replication will lose data.

(4) There is also a parameter for shutdown, which represents whether to produce persistent files before shutting down the redis service

     shutdown  save|nosave


Guess you like

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