Linux 离线安装Redis

1、下载Redis

下载地址:https://download.redis.io/releases/redis-4.0.10.tar.gz

2、安装C语言编译环境

[root@master ~]#

yum install -y centos-release-scl scl-utils-build
yum install -y devtoolset-8-toolchain

3、使用gcc8

[root@master ~]#

scl enable devtoolset-8 bash

4、查看gcc版本

[root@master ~]#

gcc  --version

输出结果:

gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

5、解压redis

[root@master ~]#

tar -xzvf /chinaskills/redis-4.0.10.tar.gz -C /usr/local/src/

6、重命名

[root@master ~]#

mv /usr/local/src/redis-4.0.10 /usr/local/src/redis

8、进入解压目录进行make

[root@master ~]#

cd /usr/local/src/redis/
make

9、跳过make test 继续make install

[root@master ~]#

make install

10、加载环境变量

[root@master ~]#

source /etc/profile

11、启动redis服务

[root@master ~]#

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

45148:M 19 Oct 19:00:28.596 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
45148:M 19 Oct 19:00:28.596 # Server initialized
45148:M 19 Oct 19:00:28.597 # 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.
45148:M 19 Oct 19:00:28.597 # 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.
45148:M 19 Oct 19:00:28.597 * Ready to accept connections

12、redis配置

[root@master ~]#

vi /usr/local/src/redis/redis.conf

配置内容:

bind 0.0.0.0
# 设置redis服务后台启动
daemonize yes

13、启动redis服务

[root@master ~]#

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

输出信息:

45202:C 19 Oct 19:19:24.314 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
45202:C 19 Oct 19:19:24.314 # Redis version=4.0.10, bits=64, commit=00000000, modified=0, pid=45202, just started
45202:C 19 Oct 19:19:24.314 # Configuration loaded