00 实验环境

  1. # 发行版信息
  2. [root@localhost ~]# cat /etc/redhat-release
  3. CentOS Linux release 7.6.1810 (Core)
  4. # 内核
  5. [root@localhost ~]# uname -r
  6. 3.10.0-957.el7.x86_64
  7. # 时间
  8. chery@cherysc ~ date
  9. 2019年 1月 9日 星期三 夜间

01 实验目的

在本机上通过编译安装的方式安装并配置redis

02 实验软件选择

020 redis选择版本

源码编译方式:redis-5.0.3.tar.gz
地址为:http://download.redis.io/releases/redis-5.0.3.tar.gz

03 准备安装

030 准备安装软件

  1. [root@redis01 ~]# mkdir -p /root/tools
  2. [root@redis01 ~]# cd /root/tools/
  3. [root@redis01 tools]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz

031 准0备依赖包(此方法已经放弃)

  1. yum install tcl jemalloc
  2. yum install -y

jemalloc 内存分配管理 ~~
如果不安装tcl,就在make test中报错:
make[1]: 进入目录“/root/tools/redis-5.0.3/src”
You need tcl 8.5 or newer in order to run the Redis test~~

031 开始编译安装依赖包包

更新:

04 开始安装

040 解压安装包

  1. [root@redis01 tools]# tar xf redis-5.0.3.tar.gz
  2. [root@redis01 tools]# ls
  3. Python-3.6.8 Python-3.6.8.tgz redis-5.0.3 redis-5.0.3.tar.gz
  4. [root@chery tools]# cd redis-5.0.3
  5. [root@chery Python-3.6.8]# ls
  6. aclocal.m4 configure Grammar Lib Makefile.pre.in Objects PCbuild Python Tools
  7. config.guess configure.ac Include LICENSE Misc Parser Programs README.rst
  8. config.sub Doc install-sh Mac Modules PC pyconfig.h.in setup.py

041 编译安装redis依赖包

  1. [root@redis01 tools]# cd redis-5.0.3/deps/
  2. [root@redis01 deps]# ls
  3. hiredis jemalloc linenoise lua Makefile README.md update-jemalloc.sh
  4. # 就是安装上述这几个
  5. [root@redis01 deps]# make hiredis jemalloc linenoise lua
  6. [root@redis01 deps]# cd ..

042 开始编译

  1. [root@redis01 redis-5.0.3]# make PREFIX=/opt/redis-5 install

PREFIX=/opt/redis-5这个地方配置和之前的python3的不一样

05 配置redis

050 创建软连接

  1. [root@redis01 redis-5.0.3]# cd /opt/redis-5/bin/
  2. [root@redis01 bin]# ls
  3. redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
  4. [root@redis01 bin]# cd /opt
  5. [root@redis01 opt]# ls
  6. python3 redis-5
  7. ## 开始创建软连接
  8. [root@redis01 opt]# ln -s redis-5 redis
  9. [root@redis01 opt]# ls
  10. python3 redis redis-5
  11. [root@redis01 opt]# ll
  12. total 0
  13. drwxr-xr-x. 6 root root 56 Jan 12 16:54 python3
  14. lrwxrwxrwx. 1 root root 7 Jan 14 17:37 redis -> redis-5
  15. drwxr-xr-x. 3 root root 17 Jan 14 17:36 redis-5

050添加全局变量(推荐)

当然也可以用软连接,不推荐

  1. [root@redis01 opt]# echo 'PATH=/opt/redis/bin:$PATH' >>/etc/profile
  2. [root@redis01 opt]# source /etc/profile
  3. [root@redis01 opt]# echo $PATH
  4. /opt/redis/bin:/opt/python3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
  1. [root@redis01 opt]# cd redis
  2. [root@redis01 redis]# vim redis-6379.conf
  3. ##编辑内容
  4. port 6379
  5. daemonize yes
  6. pidfile /data/6379/redis.pid
  7. loglevel notice
  8. logfile "/data/6379/redis.log"
  9. dir /data/6379
  10. protected-mode no # 此配置之前写的是yes,改成no是为了远程访问

051 创建一个log文件目录

  1. [root@redis01 redis]# mkdir -p /data/6379/

06 启动redis

检测命令

  1. [root@redis01 redis]# redis-server -v
  2. Redis server v=5.0.3 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=67220f391b5a2ba0
  3. [root@redis01 redis]# redis-cli -v
  4. redis-cli 5.0.3

开启服务

  1. [root@redis01 redis]# redis-server redis-6379.conf

连接测试

  1. [root@redis01 redis]# redis-cli
  2. 127.0.0.1:6379>

[参考]
1 https://blog.csdn.net/zhangshu123321/article/details/51440106
Ubuntu 14.04下Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”问题解决

2 https://www.cnblogs.com/cndavidwang/p/6429406.html 在CentOS 7中安装Redis 3.2.8

3 http://www.runoob.com/w3cnote/redis-external-network.html 配置 redis 外网可访问