Linux下安装Redis

  1. 下载上传 Redis安装包官网

image-20201101171009159

  1. 解压包

    tar -zxf redis-5.0.4.tar.gz
    
  2. 进入解压后的文件,可以看到我们redis的配置文件

[root@ysl opt]# cd redis-5.0.4/
[root@ysl redis-5.0.4]# ll
total 256
-rw-rw-r--  1 root root 99445 Mar 19  2019 00-RELEASENOTES
-rw-rw-r--  1 root root    53 Mar 19  2019 BUGS
-rw-rw-r--  1 root root  1894 Mar 19  2019 CONTRIBUTING
-rw-rw-r--  1 root root  1487 Mar 19  2019 COPYING
drwxrwxr-x  6 root root   192 Nov  1 17:04 deps
-rw-rw-r--  1 root root    11 Mar 19  2019 INSTALL
-rw-rw-r--  1 root root   151 Mar 19  2019 Makefile
-rw-rw-r--  1 root root  4223 Mar 19  2019 MANIFESTO
-rw-rw-r--  1 root root 20555 Mar 19  2019 README.md
-rw-rw-r--  1 root root 62155 Mar 19  2019 redis.conf
-rwxrwxr-x  1 root root   275 Mar 19  2019 runtest
-rwxrwxr-x  1 root root   280 Mar 19  2019 runtest-cluster
-rwxrwxr-x  1 root root   281 Mar 19  2019 runtest-sentinel
-rw-rw-r--  1 root root  9710 Mar 19  2019 sentinel.conf
drwxrwxr-x  3 root root  8192 Nov  1 17:05 src
drwxrwxr-x 10 root root   167 Mar 19  2019 tests
drwxrwxr-x  8 root root  4096 Mar 19  2019 utils

  1. 基本的环境安装
yum install gcc-c++
  1. 安装redis

    make
    make install
    
  2. 安装成功的后

    image-20201101172121938

  3. 创建 bin 与 etc 文件夹,将启动文件和配置文件放在此文件夹下

[root@ysl redis-5.0.4]# mkdir etc bin  #创建文件夹
[root@ysl redis-5.0.4]# cp redis.conf etc/redis.conf  # 复制配置文件到etc文件夹下
[root@ysl redis-5.0.4]# cd src/ 
[root@ysl src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server /opt/redis/bin/  复制启动文件、客户端文件等到etc文件夹下
[root@ysl src]# 
  1. 在bin文件夹下启动redis

    ./ redis-server
    

    image-20201101173401661

    1. 配置配置文件

      daemonize no 改为 yes 后台运行

      protected-mode yes 改为no 可以不用输入密码登陆

      bind 127.0.0.1 表示只可以本机访问,要是远程访问需要注释掉(前面加#号)

image-20201101173601793

image-20201101173607318

  1. 带配置文件后台启动

    ./redis-server ../etc/redis.conf
    
    1. 客户端登陆
    redis-cli -p 6379
    
原文地址:https://www.cnblogs.com/shiyisy/p/13910722.html