Redis Installation && Startup && Shutdown && Uninstall under Linux

Redis download address https://redis.io/download I use redis_3.2.11

The installation of Redis under Linux is very different from that under Windows, and it is the same as the usual software installation.

1 Download the Redis installation package

  Go to the redis official website to download the reids installation package. The redis official website only provides the Linux installation package by default, so don't worry about downloading the Windows installation package. The author downloaded redis-3.2.1.tar.gz. The downloaded source code is redis, and the source code installation method should be used to install redis.


Second install redis 

      1. Unzip: tar -zxvf redis-3.2.1.tar.gz

           

      2. Enter the decompressed directory and execute the compilation operation: make test 

          

If an error is reported : Redis need tcl 8.5 or newer

plan:

hadoop@stormspark:~/workspace/redis2.6.13/src$ make test
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1

[html]  view plain copy  
  1. wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz  
  2. sudo tar xzvf tcl8.6.1-src.tar.gz  -C /usr/local/  
  3. cd  /usr/local/tcl8.6.1/unix/  
  4. sudo ./configure  
  5. sudo make  
  6. sudo make install   


     3. After the compilation and test, the following information appears, which proves that there is no problem: the compiled command is placed in the src directory

     

 4. After the compilation is successful, execute the install operation: sudo make install

        

    5. At present, redis has been successfully installed. Redis related commands are stored in the ../redis-3.2.1/src directory, and the following files are generated in the /usr/local/bin/ directory:

        

 

Two redis uninstall

 1. Check whether reids is running, if it is running, close it first

         

  As can be seen from the figure, redis-server is currently running on port 6379

 2. If the redis-server service is running in the background, stop the redis-server service:

  Stop the redis-server service normally, use the reids client command: redis-cli shutdown

  

  If it can't be stopped, kill the process: kill -9 PID

  

    3. Delete the commands related to redis in the /usr/local/lib directory:

        

     4. Delete the redis-3.2.1 directory after redis decompression


Three redis startup

  After redis is successfully installed, the corresponding reids command file will be generated, all commands are in the src directory, and several reids-* commands will be generated in the /usr/local/bin directory, so that we are calling redis related commands You can not use an absolute path. There are many ways to start reids, background start, script start and so on.

  1. Redis background start: redis-server &

            This method does not specify a configuration file, the default configuration will be used, and a Warning: no config file .... will be printed.

           

   Press ctrl + C to exit the redis startup window. At this time, redis will not be closed, but will run in the background. You can view it with the command: ps aux | grep redis

            

      

       2. Specify the configuration file to start: redis-server ***/redis.conf

           After decompressing the original text of redis, there is a redis configuration template redis.conf in the directory, we can copy a copy, and then modify it into our own redis configuration file. Here I only modify one port number, modify the port number to 8080, and then use This configuration file starts the redis service

         

   Shut down using the command: redis-cli -p 8080 shutdown 

     3. Set boot up:

Four redis client client segment connections:

  After redis is successfully installed, the redis-cli client will be generated, and you can connect to the local or remote redis server through the redis-cli command. The redis-cli command has many parameters. Common options are -h -p -u -a , which correspond to ip address, port number, user name, and password. You can view the common options of redis-cli through redis-cli --help

  1. Connect to the local redis example:

   

        2. Connect to remote redis: 

           

Five close redis

       1. Shut down the local redis normally: redis-cli shutdown, close the local 6379 redis by default

          

            If it cannot be shut down normally, it can be shut down by killing the thread:

   

 2. Shut down the redis server remotely: redis-cli -h xxx.xxx.xxx.xxx -p xxxx -u xxxx -a xxxx shutdown

         


Guess you like

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