centos安装redis步骤

时间:2022-03-31 16:44:50

1.官网或wget下载redis-4.0.9.tar.gz:

  cd /home/tar

  wget http://download.redis.io/releases/redis-4.0.9.tar.gz

  cp /homt/tar/redis-4.0.9.tar.gz /usr/local/redis

  tar -zxvf redis-4.0.9.tar.gz

2.make install

  cd /usr/local/redis/redis-4.0.9/src

  make

  makeinstall

3.配置

  将这4个文件redis-server、redis-benchmark、redis-cli、redis.conf复制到一个目录下,方便管理:

  mkdir /usr/local/redis/sbin

  cd /usr/local/redis/redis-4.0.9

  cp redis-server /usr/local/redis/sbin/

  cp redis-sentinel /usr/local/redis/sbin/

  cp redis-cli /usr/local/redis/sbin/

  cp /usr/local/redis/redis4.0.9/conf/redis.conf /usr/local/redis/sbin/

4.修改redis.conf配置:

  vi redis.conf

  修改一下配置:

  a.注释bind 127.0.0.1

    # bind 127.0.0.1

  b.设置密码

    #requirepass foobared

    requirepass yourpassword

  c.设置后台启动

    daemonize yes

5.指定配置文件启动

  /usr/local/redis/sbin/redis-server /usr/local/redis/sbin/redis.conf

6.正常停止

  /usr/local/redis/sbin/redis-cli shutdown

7.强制停止

  ps -aef|grep redis

  kill -9 pid

8.多实例配置

  复制一份redis.conf文件即可