Redis学习笔记(一)安装

一、Redis简介

  Redis是完全开源的,遵守BSD协议,是一个高性能的key-value数据库。
  Redis 与其他 key - value 缓存产品有以下三个特点:
        1)Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用。
        2)Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存储。
        3)Redis支持数据的备份,即master-slave模式的数据备份。

二、Redis安装
1)Windows系统安装:
下载地址:https://github.com/tporadowski/redis/releases
根据自己的系统平台选择下载。这里选择的是Redis-x64-5.0.10.zip。

解压缩,打开文件夹,内容如下:

打开命令行窗口,cd到解压后的目录下,执行:redis-server.exe config-windows-config

另打开一个命令行窗口,cd到解压后的文件夹下,执行:redis-cli.exe -h localhost -p 6379

2)Linux系统安装(官方推荐):
下载地址:https://redis.io/
可以下载最新版本:

        或者:
        # cd /opt
        # wget https://download.redis.io/releases/redis-6.0.9.tar.gz
        # tar -zxf redis-6.0.9.tar.gz
        # cd redis-6.0.9
        # make
        # make install
        若出现错误
        make[1]: *** [server.o] 错误 1
        make[1]: 离开目录“/opt/redis-6.0.9/src”
        make: *** [install] 错误 2
        原因是因为gcc版本过低,yum安装的gcc是4.8.5的。因此需要升级gcc,升级过程如下:
        
        yum -y install centos-release-scl
        yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
        scl enable devtoolset-9 bash
        echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile

        重新执行make && make install
  
        若出现错误
        zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: 没有那个文件或目录
        50 | #include <jemalloc/jemalloc.h>
        |          ^~~~~~~~~~~~~~~~~~~~~
        compilation terminated.
        make[1]: *** [adlist.o] 错误 1
        make[1]: 离开目录“/opt/redis-6.0.9/src”
        make: *** [all] 错误 2
        可以执行命令:make MALLOC=libc

        # cd /usr/local/bin/
        # mkdir configs
        # cp /opt/redis-6.0.9/redis.conf configs/redis.conf
        # 修改配置文件,redis后台启动
        # vim configs/redis.conf
        # daemonize no  -> daemonize yes
        # 保存修改
        # redis-server configs/redis.config
        # redis-cli -h 127.0.0.1 -p 6379
        127.0.0.1:6379> ping
        PONG
原文地址:https://www.cnblogs.com/huige185/p/14071435.html