Ali cloud centos7 install redis 5 under

First, install redis

Step One: Download the installation package redis redis-5.0.7.tar.gz

Step two: extracting archive

   #tar -zxvf redis-5.0.7.tar.gz

The third step: yum install gcc dependent

   #yum install gcc

Step four: Jump to extract the directory redis

  #cd /usr/local/redis-5.0.7

 Rename mv /usr/local/redis-5.0.7 / usr / local / redis5

Step five: compile and install

   #make MALLOC=libc  

Step Six: The files in the /usr/local/redis-4.0.6/src directory to / usr / local / bin directory

   #cd src && make install

 

Two, three ways to start the redis

 

First switch to the redis src directory

# cd /usr/local/redis5/src

 

1, redis direct start

./redis-server

[root@iZwz991stxdwj560bfmadtZ src]# ./redis-server
18685:C 13 Dec 12:56:12.507 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18685:C 13 Dec 12:56:12.507 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18685, just started
18685:C 13 Dec 12:56:12.507 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.6 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 18685
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

18685:M 13 Dec 12:56:12.508 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
18685:M 13 Dec 12:56:12.508 # Server initialized
18685:M 13 Dec 12:56:12.508 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
18685:M 13 Dec 12:56:12.508 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
18685:M 13 Dec 12:56:12.508 * Ready to accept connections 

As Figure: redis started successfully, but this way need to have to start to open the window, you can not perform other operations, too convenient.

Press ctrl + c to close the window.

2, a background process started redis

The first step: Modify redis.conf file

will

daemonize no

change into

daemonize yes

Step Two: Specify the file to start redis.conf

1

./redis-server /usr/local/redis-4.0.6/redis.conf

The third step: Turn off redis process

First use ps -aux | grep redis redis process View

[root@iZwz991stxdwj560bfmadtZ src]# ps -aux | grep redis
root     18714  0.0  0.1 141752  2008 ?        Ssl  13:07   0:00 ./redis-server 127.0.0.1:6379
root     18719  0.0  0.0 112644   968 pts/0    R+   13:09   0:00 grep --color=auto redis

Use the kill command to kill the process

[root@iZwz991stxdwj560bfmadtZ src]# kill 18714

Please note that this is not a good plan to kill the process, it will result in / var / run / redis_ port number .pid file is not deleted properly

  

3, set the boot from the start redis

1, redis new directory in the / etc directory

mkdir redis

# mkdir redis

2, a document to be copied /usr/local/redis-5/redis.conf under / etc / redis directory, and named 6379.conf  

 # cp /usr/local/redis-4.0.6/redis.conf /etc/redis/6379.conf

Why this name: redis because you can run multiple programs on a single server, so that we can make different servers using different profiles. 

3, a copy of redis startup script into /etc/init.d directory

   # cp /usr/local/redisr/utils/redis_init_script /etc/init.d/redisd

    After redis startup script to the init.d directory, you can run the program automatically when the system starts, of course, the premise is that we will configure the service to the list of services. 

4, set the boot from the start redis

First switch to the directory /etc/init.d

Then execute the command from the start

# chkconfig redisd on
service redisd does not support chkconfig 

Look result is redisd does not support chkconfig

Solution:

Use vim editor redisd file, add the following two lines of comment in the first line, save and exit

# chkconfig:   2345 90 10
# description:  Redis is a persistent key-value database

Comment mean, redis service must be enabled or disabled at run level 2,3,4,5, priority is 90 start, shut down the priority is 10.

You can also use chkconfig --list to view the service. 

Boot from Kai execute the command again, success

 # chkconfig redisd on

Now in the form of direct services have been started and shut down the redis

start up:

service redisd start 

shut down:

Method 1: service redisd stop

Method 2: redis-cli SHUTDOWN

Published 107 original articles · won praise 29 · views 180 000 +

Guess you like

Origin blog.csdn.net/zhangyingchengqi/article/details/103438648