CentOS下安装Redis7教程

Redis安装配置

一、环境准备

  1. 操作系统:CentOS 7

    如何确定linux是多少位的?

    getconf LONG_BIT
    # 需要为 64
    
  2. 安装gcc

    yum -y install gcc  
    # 查看版本
    gcc -v
    
    yum -y install gcc-c++ 
    

二、安装redis7

  1. 本地下载redis7

    https://redis.io/download/

  2. 通过XShell上传到 /opt 目录下

  3. 解压缩

    tar -zxvf redis-7.0.9.tar.gz
    
  4. 执行 make && make install

    cd /opt/redis-7.0.9
    make && make install
    
  5. 查看安装目录

    cd /usr/local/bin
    
  6. 拷贝配置文件

    cd /opt/redis-7.0.9
    mkdir /myredis
    cp redis.conf /myredis/redis7.conf
    

    修改完配置文件,需要重启

  7. 修改我们拷贝的配置文件 redis7.conf

    # 1、daemonize 修改为 yes
    daemonize yes
    # 2、protected-mode 修改为 no
    protected-mode no
    # 3、注释掉 bind 127.0.0.1 -::1
    # bind 127.0.0.1 -::1
    # 4、添加redis密码,将requirepass修改为自己设置的密码
    requirepass 1234
    
  8. 启动服务

    redis-server /myredis/redis7.conf
    
    ps -ef|grep redis|grep -v grep
    
  9. 连接 redis

    redis-cli -a 1234 -p 6379
    
  10. ping返回PONG成功

    ping
    # 返回 PONG 则成功
    
  11. 关闭redis

    # 单实例关闭
    redis-cli -a 1234 shutdwon
    # 多实例关闭,指定端口关闭
    redis-cli -p 6379 shutdown
    

猜你喜欢

转载自blog.csdn.net/weixin_52372879/article/details/129672935