Redis 中文文档 Redis 中文文档
指南
redis.io (opens new window)
指南
redis.io (opens new window)
  • 关于
    • Redis 开源治理
    • Redis 发布周期
    • Redis 赞助商
  • 入门
  • 数据类型
  • Redis Stack
  • 命令
  • 手册

Redis Commander


Redis web management tool written in node.js

GUI image

Install and Run


  1. ``` shell
  2. $ npm install -g redis-commander
  3. $ redis-commander
  4. ```

Installation via yarn is currently not supported. Please use npm as package manager.

Or run Redis Commander as Docker image ghcr.io/joeferner/redis-commander rediscommander/redis-commander(instructions see below).

Multi-Arch images built are available at ghcr.io/joeferner/redis-commander:latest. (https://github.com/joeferner/redis-commander/pkgs/container/redis-commander )

Remark: new version are not published to Dockerhub right now.

Features


Web-UI to display and edit data within multiple different Redis servers.

It has support for the following data types to view, add, update and delete data:

Strings
Lists
Sets
Sorted Set
Streams (Basic support based on HFXBus project from https://github.com/exocet-engineering/hfx-bus, only view/add/delete data)
ReJSON documents (Basic support, only for viewing values of ReJSON type keys)

Usage


  1. ``` sh
  2. $ redis-commander --help
  3. Options:
  4.   --redis-port                         The port to find redis on.                  [string]
  5.   --redis-host                         The host to find redis on.                  [string]
  6.   --redis-socket                       The unix-socket to find redis on.           [string]
  7.   --redis-username                     The redis username.                         [string]
  8.   --redis-password                     The redis password.                         [string]
  9.   --redis-db                           The redis database.                         [string]
  10.   --redis-label                        The label to display for the connection.    [string]
  11.   --redis-tls                          Use TLS for connection to redis server or sentinel. [boolean] [default: false]
  12.   --redis-optional                     Set to true if no permanent auto-reconnect shall be done if server is down [boolean] [default: false]
  13.   --sentinel-port                      The port to find redis sentinel on.         [string]
  14.   --sentinel-host                      The host to find redis sentinel on.         [string]
  15.   --sentinels                          Comma separated list of sentinels with host:port. [string]
  16.   --sentinel-name                      The redis sentinel group name to use.       [string]  [default: mymaster]
  17.   --sentinel-username                  The username for sentinel instance.         [string]
  18.   --sentinel-password                  The password for sentinel instance.         [string]
  19.   --http-auth-username, --http-u       The http authorisation username.            [string]
  20.   --http-auth-password, --http-p       The http authorisation password.            [string]
  21.   --http-auth-password-hash, --http-h  The http authorisation password hash.       [string]
  22.   --address, -a                        The address to run the server on.           [string]  [default: 0.0.0.0]
  23.   --port, -p                           The port to run the server on.              [string]  [default: 8081]
  24.   --url-prefix, -u                     The url prefix to respond on.               [string]  [default: ""]
  25.   --root-pattern, --rp                 The root pattern of the redis keys.         [string]  [default: "*"]
  26.   --read-only                          Start app in read-only mode.                [boolean] [default: false]
  27.   --trust-proxy                        App is run behind proxy (enable Express "trust proxy") [boolean|string] [default: false]
  28.   --nosave, --ns                       Do not save new connections to config file. [boolean] [default: true]
  29.   --noload, --nl                       Do not load connections from config.        [boolean] [default: false]
  30.   --use-scan, --sc                     Use scan instead of keys.                   [boolean] [default: false]
  31.   --clear-config, --cc                 Clear configuration file.
  32.   --migrate-config                     Migrate old configuration file in $HOME to new style.
  33.   --scan-count, --sc                   The size of each separate scan.             [integer] [default: 100]
  34.   --no-log-data                        Do not log data values from redis store.    [boolean] [default: false]
  35.   --open                               Open web-browser with Redis-Commander.      [boolean] [default: false]
  36.   --folding-char, --fc                 Character to fold keys at in tree view.     [character] [default: ":"]
  37.   --test, -t                           Test final configuration (file, env-vars, command line)

  38. ```

The connection can be established either via direct connection to redis server or indirect via a sentinel instance. Most of this command line parameters map onto configuration params read from the config file - see docs/configuration.md and docs/connections.md.

Configuration


Redis Commander can be configured by configuration files, environment variables or using command line parameters. The different types of config values overwrite each other, only the last (most important) value is used.

For configuration files the node-config module (https://github.com/lorenwest/node-config ) is used, with default to json syntax.

The order of precedence for all configuration values (from least to most important) is:

Configuration files

default.json - this file contains all default values and SHOULD NOT be changed

local.json - optional file, all local overwrites for values inside default.json should be placed here as well as a list of redis connections to use at startup

local-<NODE_ENV>.json - Do not add anything else than connections to this file! Redis Commander will overwrite this whenever a connection is added or removed via user interface. Inside docker container this file is used to store all connections parsed from REDIS_HOSTS env var. This file overwrites all connections defined inside local.json

There are some more possible files available to use - please check the node-config Wiki for a complete list of all possible file names (https://github.com/lorenwest/node-config/wiki/Configuration-Files )

Environment variables - the full list of env vars possible (except the docker specific ones) can be got from the file config/custom-environment-variables.json together with their mapping to the respective configuration key.

Command line parameters - Overwrites everything

To check the final configuration created from files, env-vars set and command line param overwrites start redis commander with additional param "--test". All invalid configuration keys will be listed in the output. The config test does not check if hostnames or ip addresses can be resolved.

More information can be found in the documentation at docs/configuration.md and docs/connections.md.

Environment Variables


These environment variables can be used starting Redis Commander as normal application or inside docker container (defined inside file config/custom-environment-variables.json ) and at docs/configuration.md :

  1. ``` sh
  2. HTTP_USER
  3. HTTP_PASSWORD
  4. HTTP_PASSWORD_HASH
  5. ADDRESS
  6. PORT
  7. READ_ONLY
  8. URL_PREFIX
  9. SIGNIN_PATH
  10. ROOT_PATTERN
  11. NOSAVE
  12. NO_LOG_DATA
  13. FOLDING_CHAR
  14. VIEW_JSON_DEFAULT
  15. USE_SCAN
  16. SCAN_COUNT
  17. FLUSH_ON_IMPORT
  18. REDIS_CONNECTION_NAME
  19. REDIS_LABEL
  20. CLIENT_MAX_BODY_SIZE
  21. BINARY_AS_HEX

  22. ```

Docker


All environment variables listed at "Environment Variables" can be used running image with Docker. The following additional environment variables are available too (defined inside docker startup script):

  1. ``` sh
  2. HTTP_PASSWORD_FILE
  3. HTTP_PASSWORD_HASH_FILE
  4. REDIS_PORT
  5. REDIS_HOST
  6. REDIS_SOCKET
  7. REDIS_TLS
  8. REDIS_USERNAME
  9. REDIS_PASSWORD
  10. REDIS_PASSWORD_FILE
  11. REDIS_DB
  12. REDIS_HOSTS
  13. REDIS_OPTIONAL
  14. SENTINEL_PORT
  15. SENTINEL_HOST
  16. SENTINEL_NAME
  17. SENTINEL_USERNAME
  18. SENTINEL_PASSWORD
  19. SENTINEL_PASSWORD_FILE
  20. SENTINELS
  21. K8S_SIGTERM

  22. ```

A (partial) description for the mapping onto the cli params and into the config files can be found at the docs/connections.md file.

The K8S_SIGTERM variable (default "0") can be set to "1" to work around kubernetes specifics to allow pod replacement with zero downtime. More information on how kubernetes handles termination of old pods and the setup of new ones can be found within the thread [kubernetes-retired/contrib#1140 (comment) ]

Hosts can be optionally specified with a comma separated string by setting the REDIS_HOSTS environment variable.

After running the container, redis-commander will be available at localhost:8081.

Valid host strings


the REDIS_HOSTS environment variable is a comma separated list of host definitions, where each host should follow one of these templates:

hostname

label:hostname

label:hostname:port

label:hostname:port:dbIndex

label:hostname:port:dbIndex:password

Connection strings defined with REDIS_HOSTS variable do not support TLS connections. If remote redis server needs TLS write all connections into a config file instead of using REDIS_HOSTS (see docs/connections.md at the end within the more complex examples).

This environment variable REDIS_HOSTS does not support IPv6 addresses. It supports IPv4 or hostnames only due to ':' used as separator within IPv6 addresses and this fields here.

With docker-compose


  1. ``` yaml
  2. version: '3'
  3. services:
  4.   redis:
  5.     container_name: redis
  6.     hostname: redis
  7.     image: redis

  8.   redis-commander:
  9.     container_name: redis-commander
  10.     hostname: redis-commander
  11.     image: ghcr.io/joeferner/redis-commander:latest
  12.     restart: always
  13.     environment:
  14.     - REDIS_HOSTS=local:redis:6379
  15.     ports:
  16.     - "8081:8081"
  17. ```

Without docker-compose


Simplest


If you're running redis on localhost:6379, this is all you need to get started.

  1. ``` shell
  2. docker run --rm --name redis-commander -d -p 8081:8081 \
  3.   ghcr.io/joeferner/redis-commander:latest
  4. ```

Specify single host


  1. ``` shell
  2. docker run --rm --name redis-commander -d -p 8081:8081 \
  3.   --env REDIS_HOSTS=10.10.20.30 \
  4.   ghcr.io/joeferner/redis-commander:latest
  5. ```

Specify multiple hosts with labels


  1. ``` shell
  2. docker run --rm --name redis-commander -d -p 8081:8081 \
  3.   --env REDIS_HOSTS=local:localhost:6379,myredis:10.10.20.30 \
  4.   ghcr.io/joeferner/redis-commander:latest
  5. ```

Kubernetes


An example deployment can be found at k8s/redis-commander/deployment.yaml.

If you already have a cluster running with redis in the default namespace, deploy redis-commander with kubectl apply -f k8s/redis-commander. If you don't have redis running yet, you can deploy a simple pod with kubectl apply -f k8s/redis.

Alternatively, you can add a container to a deployment's spec like this:

  1. ``` sh
  2. containers:
  3. - name: redis-commander
  4.   image: ghcr.io/joeferner/redis-commander
  5.   env:
  6.   - name: REDIS_HOSTS
  7.     value: instance1:redis:6379
  8.   ports:
  9.   - name: redis-commander
  10.     containerPort: 8081

  11. ```

known issues with Kubernetes:

using REDIS_HOSTS works only with a password-less redis db. You must specify REDIS_HOST on a password protected redis db
using REDIS_HOSTS does not work with IPv6 addresses. For connections to IPv6 addresses either use REDIS_HOST and REDIS_PORT env var or a custom config/local.json configuration file mounted into the redis container.

Helm chart


You can install the application on any Kubernetes cluster using Helm. There is no helm repo available currently, therefore local checkout of helm sources inside this repo is needed:

  1. ``` shell
  2. helm -n myspace install redis-web-ui ./k8s/helm-chart/redis-commander
  3. ```

More Documentation about this Helm chart and its values.

OpenShift V3


To use the stock Node.js image builder do the following.

Open Catalog and select the Node.js template
Specify the name of the application and the URL to the redis-command github repository
Click the advanced options link
(optional) specify the hostname for the route - if one is not specified it will be generated
In the Deployment Configuration section
Add REDIS_HOST environment variable whose value is the name of the redis service - e.g., redis
Add REDIS_PORT environment variable whose value is the port exposed of the redis service - e.g., 6379
Add value from secret generated by the redis template :
name: REDIS_PASSWORD
resource: redis
key: database-password

(optional) specify a label such as appl=redis-commander-dev1
this label will be applied on all objects created allowing for easy deletion later via:

  1. ``` shell
  2. oc delete all --selector appl=redis-commander-dev1
  3. ```

Helper Scripts


Generate BCrypted password hash


Redis commander allows setting either a plain text password for http authentication or an already bcrypted password hash. To generate a hashed password the script bin/bcrypt-password.js can be used. The parameter "-p" to set password should be given.

Usage example:

  1. ``` shell
  2. $ git clone https://github.com/joeferner/redis-commander.git
  3. $ cd redis-commander/bin
  4. $ node bcrypt-password.js -p myplainpass
  5. $2b$10BQPbC8dlxeEqB/nXOkyjr.tlafGZ28J3ug8sWIMRoeq5LSVOXpl3W
  6. ```

This generated hash can be set inside the config file as "server.httpAuth.passwordHash", as env var "HTTP_PASSWORD_HASH" or on the command line as --http-auth-password-hash. Running inside docker image a file containing this password hash can be set via env var HTTP_PASSWORD_HASH_FILE

Build images based on this one


To use this images as a base image for other images you need to call "apk update" inside your Dockerfile before adding other apk packages with "apk add foo". Afterwards, to reduce your image size, you may remove all temporary apk configs too again as this Dockerfile does.
Last Updated: 2023-09-03 19:17:54