Tendis Documentation

repository·unstable·Indexed 25 days ago

https://github.com/tencent/tendis

Tendis is a high-performance distributed storage system fully compatible with the Redis protocol, utilizing RocksDB as its storage engine for persistent, disk-based storage. The documentation covers building from source using cmake, managing the service via start.sh and stop.sh, and using CLI tools like redis-cli and memtier_benchmark. It includes detailed references for CLUSTER management commands, authentication via AUTH, database selection via SELECT, and guidelines for implementing custom commands by extending the Command class.

Tokens
13.7K
Snippets
14
Records
124
Agent score
85%

What's inside Tendis

  1. Available CLI tools in the bin directory

    unstable

    The bin directory contains several utility tools for Tendis, including synchronization tools, instance comparison tools, and various benchmarking/client utilities derived from Redis and other projects.

    Available tools:

    • checkdts: Data verification tool.
    • redis-sync: Synchronization utility.
    • compare_instances: Tool to compare Tendis instances (source: src/tendisplus/misc/compare_instances.go).
    • predixy: Proxy tool (customized for testing).
    • redis-benchmark: Benchmarking tool (customized for testing).
    • redis-cli: Command line interface (based on Redis 7.2.3).
    • redis-server: The Tendis server implementation.
    • memtier_benchmark: High-performance benchmarking tool (customized for testing).
  2. Build Tendis from source

    unstable

    To build Tendis, ensure you have the required dependencies installed, clone the repository recursively to include submodules, and use cmake to generate the build files.

    Requirements

    • g++ (version >= 5.5, required for C++17 support)
    • cmake (version >= 3.13.0)

    Build Steps

    1. Clone the repository with submodules:
      git clone https://github.com/Tencent/tendis.git --recursive
      git submodule update --init --recursive
    2. Create a build directory and compile:
      mkdir build
      cd build && cmake ..
      make -j12
    git clone https://github.com/Tencent/tendis.git --recursive
    git submodule update --init --recursive
    mkdir build
    cd build && cmake ..
    make -j12
  3. Use create-cluster to set up a Tendisplus cluster for testing

    unstable

    The create-cluster script is a utility used to quickly start multiple Tendisplus instances configured in cluster mode. It is primarily intended for manual testing and experimentation with large numbers of instances to replicate specific bugs or system behaviors.

    Setup and Execution Workflow

    1. Configure Ports: Edit the create-cluster script to adjust the start and end port ranges based on the number of instances you wish to create.
    2. Start Instances: Run the script with the start command to launch the Tendisplus instances.
    3. Initialize Cluster: Run the script with the create command. This executes redis-cli to perform the actual cluster creation logic.
      • Note: If accessing the setup via a local container, you must update the CLUSTER_HOST value in the script to your local IP address.
    4. Verify Files: Data files and logs for each instance are generated in the current working directory.

    Managing the Cluster

    • Stop Instances: Use ./create-cluster stop to shut down all running instances. You can later use ./create-cluster start to restart them.
    • Clean Environment: Use ./create-cluster clean to delete all AOF (Append Only File) and log files, allowing for a fresh start.
    • Help: Run ./create-cluster help to view the full list of available commands and features.
  4. Start the Tendis service using start.sh

    unstable

    The start.sh script is an entrypoint script used to initialize the environment and start the tendisplus service. It performs the following actions:

    1. Updates LD_LIBRARY_PATH to include the ../bin/deps directory.
    2. Creates necessary directories for data persistence and logging under the home directory:
      • ${dir}/db for database files.
      • ${dir}/dump for dump files.
      • ${dir}/log for log files.
    3. Executes the tendisplus binary using the configuration specified in tendisplus.conf.

    Ensure that the tendisplus.conf file is present in the same directory as the script or accessible via the relative path used by the binary.

  5. Manage Tendis Cluster via CLUSTER commands

    unstable

    The CLUSTER command is used for cluster management, including node discovery, slot manipulation, replication, and migration/importing tasks.

    Note: Many cluster operations require binlog to be enabled. Some operations like importing or restart cannot be performed on slave or arbiter nodes.

  6. Compile Lua source files with luac

    unstable

    Use the luac compiler to translate Lua source code into binary bytecode files. Pre-compiling provides faster loading, protects source code from accidental changes, and allows for offline syntax checking.

    By default, luac produces a single output file named luac.out containing the bytecodes for all provided source files. Note that binary files are only portable among architectures with the same word size and byte order.