linux环境下安装redis

一. 官网下载redis稳定版

https://redis.io/download

二. 将下载的文件传到linux系统中,自己建立目录

我这里用的winSCP,目录是usr/local/redis
linux下创建目录命令: mkdir 目录名称

[root@iz2zeeh47kp5evidpgzz7gz /]# cd /usr/local/redis
[root@iz2zeeh47kp5evidpgzz7gz redis]# ls
redis-5.0.5.tar.gz
[root@iz2zeeh47kp5evidpgzz7gz redis]# 

三.解压redis,进入解压后的目录进行编译安装

[root@iz2zeeh47kp5evidpgzz7gz redis]# tar xzf redis-5.0.5.tar.gz
[root@iz2zeeh47kp5evidpgzz7gz redis]# ls
redis-5.0.5  redis-5.0.5.tar.gz
[root@iz2zeeh47kp5evidpgzz7gz redis]# cd redis-5.0.5
[root@iz2zeeh47kp5evidpgzz7gz redis-5.0.5]# make
[root@iz2zeeh47kp5evidpgzz7gz redis-5.0.5]# cd src
[root@iz2zeeh47kp5evidpgzz7gz src]# sudo make install

四. 启动redis服务

[root@iz2zeeh47kp5evidpgzz7gz src]# redis-server
6435:C 18 May 2019 10:19:29.457 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6435:C 18 May 2019 10:19:29.457 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=6435, just started
6435:C 18 May 2019 10:19:29.457 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 6435
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

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

服务端默认是运行在前台的,如果是用的阿里云服务器记得在安全组添加放行,默认端口是6739

五. 测试是否成功启动redis

[root@iz2zeeh47kp5evidpgzz7gz ~]# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set name zhangfei
OK
127.0.0.1:6379> get name
"zhangfei"
127.0.0.1:6379> del name
(integer) 1

你可能感兴趣的:(linux,数据库)