Install Redis7 tutorial under CentOS

Redis installation and configuration

1. Environmental preparation

  1. Operating system: CentOS 7

    How to determine the number of linux?

    getconf LONG_BIT
    # 需要为 64
    
  2. install gcc

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

Two, install redis7

  1. Download redis7 locally

    https://redis.io/download/

  2. Upload to the /opt directory through XShell

  3. unzip

    tar -zxvf redis-7.0.9.tar.gz
    
  4. Execute make && make install

    cd /opt/redis-7.0.9
    make && make install
    
  5. View the installation directory

    cd /usr/local/bin
    
  6. copy configuration file

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

    After modifying the configuration file, you need to restart

  7. Modify the configuration file redis7.conf we copied

    # 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. start service

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

    redis-cli -a 1234 -p 6379
    
  10. Ping returns PONG success

    ping
    # 返回 PONG 则成功
    
  11. close redis

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

Guess you like

Origin blog.csdn.net/weixin_52372879/article/details/129672935