刷新数据库数据

要在不删除数据库的情况下删除数据库中的数据,您可以使用 Redis CLI 将其从数据库中刷新。您还可以使用 Redis CLI、管理控制台和 Redis 软件 REST API 从主动-主动数据库刷新数据。

Redis 企业软件

要删除数据库中的数据而不删除数据库配置, 您可以从数据库中刷新数据。

您可以使用集群管理器 UI 从主动-主动数据库中刷新数据。

警告:
flush 命令将删除数据库中的所有内存和持久性数据。 我们建议您在刷新数据之前备份数据库

从数据库刷新数据

在命令行中,您可以使用 redis-cli 命令或您最喜欢的 Redis 客户端刷新数据库。

要使用 redis-cli 从数据库刷新数据,请运行:

redis-cli -h <hostname> -p <portnumber> -a <password> flushall

Example:

redis-cli -h redis-12345.cluster.local -p 9443 -a xyz flushall
Note:
Port 9443 is the default port configuration.

Flush data from an Active-Active database

When you flush an Active-Active database (formerly known as CRDB), all of the replicas flush their data at the same time.

To flush data from an Active-Active database:

  • Cluster Manager UI

    1. If you are using the new Cluster Manager UI, switch to the legacy admin console.

      Select switch to legacy admin console from the dropdown.
    2. Go to database and select the Active-Active database that you want to flush.

    3. Go to configuration and click Flush at the bottom of the page.

    4. Enter the name of the Active-Active database to confirm that you want to flush the data.

  • Command line

    1. To find the ID of the Active-Active database, run:

      crdb-cli crdb list
      

      For example:

      $ crdb-cli crdb list
      CRDB-GUID                                NAME                 REPL-ID CLUSTER-FQDN
      a16fe643-4a7b-4380-a5b2-96109d2e8bca     crdb1                1       cluster1.local
      a16fe643-4a7b-4380-a5b2-96109d2e8bca     crdb1                2       cluster2.local
      a16fe643-4a7b-4380-a5b2-96109d2e8bca     crdb1                3       cluster3.local
      
    2. To flush the Active-Active database, run:

      crdb-cli crdb flush --crdb-guid <CRDB-GUID>
      

      The command output contains the task ID of the flush task, for example:

      $ crdb-cli crdb flush --crdb-guid a16fe643-4a7b-4380-a5b2-96109d2e8bca
      Task 63239280-d060-4639-9bba-fc6a242c19fc created
      ---> Status changed: queued -> started
      
    3. To check the status of the flush task, run:

      crdb-cli task status --task-id <Task-ID>
      

      For example:

      $ crdb-cli task status --task-id 63239280-d060-4639-9bba-fc6a242c19fc
      Task-ID: 63239280-d060-4639-9bba-fc6a242c19fc
      CRDB-GUID: -
      Status: finished
      
  • REST API

    1. To find the ID of the Active-Active database, use GET /v1/crdbs:

      GET https://[host][:port]/v1/crdbs
      
    2. To flush the Active-Active database, use PUT /v1/crdbs/{guid}/flush:

      PUT https://[host][:port]/v1/crdbs/<guid>/flush
      

      The command output contains the task ID of the flush task.

    3. To check the status of the flush task, use GET /v1/crdb_tasks:

      GET https://[host][:port]/v1/crdb_tasks/<task-id>
      
RATE THIS PAGE
Back to top ↑