---
title: Rebuild the TSI index
description: Flush and rebuild the TSI index to purge corrupt index files or remove indexed data that is out of date.
url: https://docs.influxdata.com/influxdb/v2/admin/internals/tsi/rebuild-index/
estimated_tokens: 1410
product: InfluxDB OSS v2
version: v2
---

# Rebuild the TSI index

This page documents an earlier version of InfluxDB OSS. [InfluxDB 3 Core](/influxdb3/core/) is the latest stable version.

#### API token hashing is enabled by default in InfluxDB OSS 2.9.0

Stronger token security: tokens are stored as hashes on disk, so a copy of the database file doesn’t expose usable tokens. Existing tokens are hashed on first startup and the original strings can’t be recovered afterward — **capture any plaintext tokens you still need before you upgrade**.

For more information, see [Token hashing](/influxdb/v2/admin/tokens/#token-hashing).

In some cases, it may be necessary to flush and rebuild the TSI index. For example, purging corrupt index files or removing outdated indexed data.

To rebuild your InfluxDB TSI index:

1. **Stop the InfluxDB (`influxd`) process**.
    
    Rebuilding the TSI index while the `influxd` is running could prevent some data from being queryable.
    
2. Navigate to the `data` directory in your [InfluxDB engine path](/influxdb/v2/reference/internals/file-system-layout/). *The engine path depends on your operating system or [custom engine path setting](/influxdb/v2/reference/config-options/#engine-path).*
    
    <!-- Tabbed content: Select one of the following options -->
    
    
    **macOS & Linux:**
    
    ```sh
    cd ~/.influxdbv2/engine/data/
    ```
    
    
    
    **Windows (PowerShell):**
    
    ```powershell
    cd -Path 'C:\%USERPROFILE%\.influxdbv2\engine\data\'
    ```
    
    
    
    <!-- End tabbed content -->
    
3. **Delete all `_series` directories in your InfluxDB `data` directory.** By default, `_series` directories are are stored at `/data/<bucket-id>/_series`, but check for and remove `_series` directories throughout the `data` directory.
    
    <!-- Tabbed content: Select one of the following options -->
    
    
    **macOS & Linux:**
    
    ```sh
    find . -type d -name _series -exec -delete
    ```
    
    
    
    **Windows (PowerShell):**
    
    ```powershell
    get-childitem -Include _series -Recurse -force | Remove-Item -Force -Recurse
    ```
    
    
    
    <!-- End tabbed content -->
    
4. **Delete all `index` directories.** By default, `index` directories are stored at `/data/<bucket-id>/autogen/<shard-id>/index`, but check for and remove `index` directories throughout the `data` directory.
    
    <!-- Tabbed content: Select one of the following options -->
    
    
    **macOS & Linux:**
    
    ```sh
    find . -type d -name index -exec -delete
    ```
    
    
    
    **Windows (PowerShell):**
    
    ```powershell
    get-childitem -Include index -Recurse -force | Remove-Item -Force -Recurse
    ```
    
    
    
    <!-- End tabbed content -->
    
5. Use the [`influxd inspect build-tsi` command](/influxdb/v2/reference/cli/influxd/inspect/build-tsi/) to rebuild the TSI index.
    
    ```sh
    influxd inspect build-tsi
    ```
    

#### Related

-   [InfluxDB storage engine](/influxdb/v2/reference/internals/storage-engine/)
-   [InfluxDB file system layout](/influxdb/v2/reference/internals/file-system-layout/)
-   [influxd inspect build-tsi](/influxdb/v2/reference/cli/influxd/inspect/build-tsi/)

[storage](/influxdb/v2/tags/storage/) [internals](/influxdb/v2/tags/internals/)
