欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux 安装redis方法,及出现异常解决方法

程序员文章站 2022-07-14 15:40:40
...

官网地址:http://redis.io/

官网下载地址:http://redis.io/download

1. 下载Redis源码(tar.gz),并上传到Linux

2. 解压缩包:tar zxvf redis-2.8.17.tar.gz

3. 进入解压缩后的文件夹:cd redis-2.8.17

4. 编译源码:make

(1)若出现如下提示,则说明未安装gcc,使用命令安装gcc:yum install gcc

[[email protected] redis-2.8.17]# make
cd src && make all
make[1]: Entering directory `/root/redis-2.8.17/src‘
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/root/redis-2.8.17/src‘
make: *** [all] Error 2

(2)若出现如下提示,则将make改为make MALLOC=libc,推测是因为编译库的问题。

[[email protected] redis-2.8.17]# make
cd src && make all
make[1]: Entering directory `/root/redis-2.8.17/src‘
    CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/root/redis-2.8.17/src‘
make: *** [all] Error 2
  1. 安装编译后的文件:make install,redis可执行文件将被复制到/usr/local/bin/,但没有配置,手动复制配置:cp redis.conf /usr/local/bin

  2. 设置Redis密码,编辑刚刚复制的配置文件:vi redis.conf,解除requirepass参数的注释,并设置值,例如:requirepass ljx520

  3. 使用配置文件启动Redis数据库:./redis-server redis.conf

如果看到如下的界面,那么恭喜你,Redis已安装成功

16751:C 11 Jun 2019 10:46:09.333 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
16751:C 11 Jun 2019 10:46:09.333 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=16751, just started
16751:C 11 Jun 2019 10:46:09.333 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
16751:M 11 Jun 2019 10:46:09.334 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 16751
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

16751:M 11 Jun 2019 10:46:09.335 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
16751:M 11 Jun 2019 10:46:09.335 # Server initialized
16751:M 11 Jun 2019 10:46:09.335 # 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.
16751:M 11 Jun 2019 10:46:09.335 # 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.
16751:M 11 Jun 2019 10:46:09.335 * Ready to accept connections

原文:https://blog.csdn.net/wzygis/article/details/51705559

相关标签: redis安装