Redis安装

环境

系统:CentOS 6.9 | CentOS 7.4
软件:redis-3.2.8.tar.gz

准备

  • 安装依赖包
    # yum install gcc
    

Redis安装

  • 下载二进制包
    地址:https://redis.io/download

  • 安装

    # tar -xzvf redis-3.2.8.tar.gz
    # mv redis-3.2.8 /usr/local/redis
    # cd /usr/local/redis
    # make
    
  • 配置环境变量

    # vim /etc/profile
    export PATH=/usr/local/redis/src:$PATH
    
    # source /etc/profile
    

Redis配置

  • 配置

    # ln -s /usr/local/redis/redis.conf /etc/
    
    # vim /etc/redis.conf
    bind 0.0.0.0
    daemonize yes
    dir /data/redis
    requirepass 123456
    
  • 创建文件夹

    # mkdir -p /data/redis
    

Redis启动

CentOS 6.9

  • 启动

    # /usr/local/redis/src/redis-server /etc/redis.conf
    
  • 开机启动

    # vim /etc/rc.local
    /usr/local/redis/src/redis-server /etc/redis.conf
    

CentOS 7.4

  • 添加启动服务

    # vim /usr/lib/systemd/system/redis.service
    [Unit]
    Description=Redis
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/usr/local/redis/src/redis-server /etc/redis.conf
    
    [Install]
    WantedBy=multi-user.target
    
  • 启动

    # systemctl enable redis.service
    # systemctl start redis.service
    

你可能感兴趣的:(Redis安装)