下载

安装

  • Install Redis from Source | Redis

  • 生成如果用redis6,版本要>=6.0.8

    1
    2
    3
    4
    5
    wget https://download.redis.io/releases/redis-6.2.7.tar.gz
    tar -xzvf redis-6.2.7.tar.gz
    cd redis-6.2.7
    # yum -y install gcc automake autoconf libtool make gcc-c++
    make
  • If the compile succeeds, you’ll find several Redis binaries in the src directory, including:

    • redis-server: the Redis Server itself
    • redis-cli is the command line interface utility to talk with Redis.
  • To install these binaries in /usr/local/bin, run:

    1
    make install
  • Starting and stopping Redis in the foreground

    • Once installed, you can start Redis by running

      1
      redis-server
    • If successful, you’ll see the startup logs for Redis, and Redis will be running in the foreground.

    • To stop Redis, enter Ctrl-C.

  • 客户端访问

    1
    2
    3
    [root@node1 redis-6.2.7]# src/redis-cli
    127.0.0.1:6379> ping
    PONG

官网命令大全

查看Redis版本

  • redis-server -v 命令

    1
    2
    3
    [root@node1 redis-6.2.7]# redis-server -v
    Redis server v=6.2.7 sha=00000000:0 malloc=libc bits=64 build=66f054e0ef6e61fa

  • redis-cli进去后info

    1
    2
    3
    4
    5
    [root@node1 redis-6.2.7]# src/redis-cli
    127.0.0.1:6379> info
    # Server
    redis_version:6.2.7
    redis_git_sha1:00000000

卸载

  • 查看reids 是否在运行,如果在运行的话,先关闭

    1
    2
    3
    4
    5
    6
    7
    8
    # redis-server目前正在6379端口运行,需要将该进程关闭。
    [root@node1 redis-6.2.7]# ps -ef | grep redis
    root 70896 59211 0 22:45 pts/1 00:00:00 redis-server *:6379

    # kill -9 PID 将进程关闭
    [root@node1 redis-6.2.7]# kill -9 7089

    # 正常停止redis-cli shutdown
  • 删除/usr/local/lib目录下与redis相关的文件:

    1
    2
    3
    4
    # /usr/local/lib目录下与redis相关的文件:
    rm -rf /usr/local/bin/redis-*
    # 删除掉解压后的文件目录和所有文件
    rm -rf redis-3.2.1
  • 卸载完成