最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】CentOS中安装和运行redis

CentOS crifan 2234浏览 0评论

折腾:

【已解决】把Celery+Redis集成到在线Flask中且用supervisor去管理后台服务

期间,需要去CentOS服务器中,安装redis。

以供后面celery作为broker,实现Flask的中的异步延时任务。

centos 7 install redis

Install and Configure Redis on CentOS 7

How to Install and Secure Redis in Centos7 | DigitalOcean

Centos 7下使用yum安装redis – 简书

Centos 7 安装 Redis – CSDN博客

centos7安装redis – 白桦hsu的个人空间

直接去安装:

<code>(robotDemo-dwdcgdaG) [root@xxx-general-01 robotDemo]# yum -y install redis
Loaded plugins: fastestmirror
base                                                                                                                                                               | 3.6 kB  00:00:00     
epel                                                                                                                                                               | 4.7 kB  00:00:00     
extras                                                                                                                                                             | 3.4 kB  00:00:00     
mongodb-org                                                                                                                                                        | 2.5 kB  00:00:00     
nux-dextop                                                                                                                                                         | 2.9 kB  00:00:00     
updates                                                                                                                                                            | 3.4 kB  00:00:00     
(1/9): base/7/x86_64/group_gz                                                                                                                                      | 166 kB  00:00:00     
(2/9): epel/x86_64/group_gz                                                                                                                                        |  84 kB  00:00:00     
(3/9): epel/x86_64/updateinfo                                                                                                                                      | 924 kB  00:00:00     
(4/9): extras/7/x86_64/primary_db                                                                                                                                  | 104 kB  00:00:00     
(5/9): updates/7/x86_64/primary_db                                                                                                                                 | 1.0 MB  00:00:00     
(6/9): epel/x86_64/primary_db                                                                                                                                      | 6.4 MB  00:00:00     
(7/9): mongodb-org/primary_db                                                                                                                                      |  86 kB  00:00:00     
(8/9): base/7/x86_64/primary_db                                                                                                                                    | 5.9 MB  00:00:00     
(9/9): nux-dextop/x86_64/primary_db                                                                                                                                | 1.7 MB  00:01:29     
Determining fastest mirrors
 * nux-dextop: mirror.li.nux.ro
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package redis.x86_64 0:3.2.10-2.el7 will be installed
--&gt; Processing Dependency: libjemalloc.so.1()(64bit) for package: redis-3.2.10-2.el7.x86_64
--&gt; Running transaction check
---&gt; Package jemalloc.x86_64 0:3.6.0-1.el7 will be installed
--&gt; Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================================
 Package                                      Arch                                       Version                                           Repository                                Size
==========================================================================================================================================================================================
Installing:
 redis                                        x86_64                                     3.2.10-2.el7                                      epel                                     545 k
Installing for dependencies:
 jemalloc                                     x86_64                                     3.6.0-1.el7                                       epel                                     105 k

Transaction Summary
==========================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 650 k
Installed size: 1.7 M
Downloading packages:
(1/2): jemalloc-3.6.0-1.el7.x86_64.rpm                                                                                                                             | 105 kB  00:00:00     
(2/2): redis-3.2.10-2.el7.x86_64.rpm                                                                                                                               | 545 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                     4.2 MB/s | 650 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : jemalloc-3.6.0-1.el7.x86_64                                                                                                                                            1/2 
  Installing : redis-3.2.10-2.el7.x86_64                                                                                                                                              2/2 
  Verifying  : redis-3.2.10-2.el7.x86_64                                                                                                                                              1/2 
  Verifying  : jemalloc-3.6.0-1.el7.x86_64                                                                                                                                            2/2 

Installed:
  redis.x86_64 0:3.2.10-2.el7                                                                                                                                                             

Dependency Installed:
  jemalloc.x86_64 0:3.6.0-1.el7                                                                                                                                                           

Complete!
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# redis-
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli        redis-sentinel   redis-server     
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# redis-*
bash: redis-*: command not found
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# redis-server --version
Redis server v=3.2.10 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=c8b45a0ec7dc67c6
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# redis-cli --version
redis-cli 3.2.10
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# which redis-server
/usr/bin/redis-server
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# ll /usr/bin/redis-*
-rwxr-xr-x 1 root root  86864 Aug 18  2017 /usr/bin/redis-benchmark
-rwxr-xr-x 1 root root  15432 Aug 18  2017 /usr/bin/redis-check-aof
lrwxrwxrwx 1 root root     12 May 14 15:59 /usr/bin/redis-check-rdb -&gt; redis-server
-rwxr-xr-x 1 root root 173376 Aug 18  2017 /usr/bin/redis-cli
lrwxrwxrwx 1 root root     12 May 14 15:59 /usr/bin/redis-sentinel -&gt; redis-server
-rwxr-xr-x 1 root root 979464 Aug 18  2017 /usr/bin/redis-server
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# 
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# ll /etc/redis*
-rw-r----- 1 redis root 46729 Aug 18  2017 /etc/redis.conf
-rw-r----- 1 redis root  7853 Aug 18  2017 /etc/redis-sentinel.conf
</code>

然后再去试试

<code>(robotDemo-dwdcgdaG) [root@xx-xx-01 robotDemo]# redis-server &amp;
[1] 10953
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# 10953:C 14 May 16:04:12.349 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.10 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 10953
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

10953:M 14 May 16:04:12.351 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
10953:M 14 May 16:04:12.351 # Server started, Redis version 3.2.10
10953:M 14 May 16:04:12.351 # 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.
10953:M 14 May 16:04:12.351 # 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 &gt; /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.
10953:M 14 May 16:04:12.351 * The server is now ready to accept connections on port 6379

(robotDemo-dwdcgdaG) [root@x-01 robotDemo]# redis-cli ping
PONG
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# 
</code>

是没问题的。

再去看看进程:

<code>(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# ps -ef | grep redis
root     10953  9832  0 16:04 pts/2    00:00:00 redis-server *:6379
root     10958  9832  0 16:05 pts/2    00:00:00 grep --color=auto redis
(robotDemo-dwdcgdaG) [root@xx-general-01 robotDemo]# netstat -lanp | grep redis 
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      10953/redis-server  
tcp6       0      0 :::6379                 :::*                    LISTEN      10953/redis-server 
</code>

再去设置开机启动

此处决定:不用通过systemctl去设置redis

因为后续可以用supervisor去启动redis。

转载请注明:在路上 » 【已解决】CentOS中安装和运行redis

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.171 seconds, using 22.08MB memory