Configuration

GreptimeDB supports layered configuration and uses the following precedence order(each item takes precedence over the item below it):

  • Command-line flags
  • Configuration file
  • Environment variables
  • Default values

This page describes methods for configuring GreptimeDB server settings. Configuration can be set in TOML file.

The system assigns a default value for missing parameters in the configuration file.

All sample configuration files are in the project’s config folder.

Command-line flags

Global flags

  • -h/--help: Print help information;
  • -V/--version: Print version information;
  • --log-dir <LOG_DIR>: The logging directory;
  • --log-level <LOG_LEVEL>: The logging level;

Datanode subcommand flags

You can list all the flags from the following command:

  1. greptime datanode start --help
  • -c/--config-file: The configuration file for datanode;
  • --env-prefix <ENV_PREFIX>: The prefix of environment variables, default is GREPTIMEDB_DATANODE;
  • --data-home: Database storage root directory;
  • --http-addr <HTTP_ADDR>: HTTP server address;
  • --http-timeout <HTTP_TIMEOUT>: HTTP request timeout;
  • --metasrv-addr <METASRV_ADDR>: Metasrv address list;
  • --node-id <NODE_ID>: The datanode ID;
  • --rpc-addr <RPC_ADDR>: The datanode RPC addr;
  • --rpc-hostname <RPC_HOSTNAME>: The datanode hostname;
  • --wal-dir <WAL_DIR>: The wal directory of WAL;

Metasrv subcommand flags

You can list all the flags from the following command:

  1. greptime metasrv start --help
  • -c/--config-file: The configuration file for metasrv;
  • --env-prefix <ENV_PREFIX>: The prefix of environment variables, default is GREPTIMEDB_METASRV;
  • --bind-addr <BIND_ADDR>: The bind address of metasrv;
  • --http-addr <HTTP_ADDR>: HTTP server address;
  • --http-timeout <HTTP_TIMEOUT>: HTTP request timeout;
  • --selector <SELECTOR>: You can refer selector-type;
  • --server-addr <SERVER_ADDR>: The communication server address for frontend and datanode to connect to metasrv;
  • --store-addr <STORE_ADDR>: Etcd server address;
  • --use-memory-store: Use memory store instead of etcd;

Frontend subcommand flags

You can list all the flags from the following command:

  1. greptime frontend start --help
  • -c/--config-file: The configuration file for frontend;
  • --env-prefix <ENV_PREFIX>: The prefix of environment variables, default is GREPTIMEDB_FRONTEND;
  • --disable-dashboard: Disable dashboard http service;
  • --http-addr <HTTP_ADDR>: HTTP server address;
  • --http-timeout <HTTP_TIMEOUT>: HTTP request timeout;
  • --influxdb-enable: Whether to enable InfluxDB protocol in HTTP API;
  • --grpc-addr <GPRC_ADDR>: GRPC server address;
  • --metasrv-addr <METASRV_ADDR>: Metasrv address list;
  • --mysql-addr <MYSQL_ADDR>: MySQL server address;
  • --opentsdb-addr <OPENTSDB_ADDR>: OpenTSDB server address;
  • --postgres-addr <POSTGRES_ADDR>: Postgres server address;
  • --prom-addr <PROM_ADDR>: Prometheus server address;
  • --tls-cert-path <TLS_CERT_PATH>: The TLS public key file path;
  • --tls-key-path <TLS_KEY_PATH>: The TLS private key file path;
  • --tls-mode <TLS_MODE>: TLS Mode;
  • --user-provider <USER_PROVIDER>: You can refer authentication;

Configuration File

Specify configuration file

You can specify the configuration file by using the command line arg -c [file_path], for example:

sh

  1. greptime [standalone | frontend | datanode | metasrv] start -c config/standalone.example.toml

Common configurations

Common protocol configurations in frontend and standalone sub command:

toml

  1. [http_options]
  2. addr = "127.0.0.1:4000"
  3. timeout = "30s"
  4. [grpc_options]
  5. addr = "127.0.0.1:4001"
  6. runtime_size = 8
  7. [mysql_options]
  8. addr = "127.0.0.1:4002"
  9. runtime_size = 2
  10. [mysql_options.tls]
  11. mode = "disable"
  12. cert_path = ""
  13. key_path = ""
  14. [postgres_options]
  15. addr = "127.0.0.1:4003"
  16. runtime_size = 2
  17. [postgres_options.tls]
  18. mode = "disable"
  19. cert_path = ""
  20. key_path = ""
  21. [opentsdb_options]
  22. addr = "127.0.0.1:4242"
  23. runtime_size = 2
  24. [influxdb_options]
  25. enable = true
  26. [prometheus_options]
  27. enable = true

All of these options are optional, the default values are listed above. If you want to disable some options, such as OpenTSDB protocol support, you can remove the prometheus_options or set its enable value to be false.

Protocol options

OptionKeyTypeDescription
http_optionsHTTP server options
addrStringServer address, “127.0.0.1:4000” by default
timeoutStringHTTP request timeout, 30s by default
grpc_optionsgRPC server options
addrStringServer address, “127.0.0.1:4001” by default
runtime_sizeIntegerThe number of server worker threads, 8 by default
mysql_optionsMySQL server options
addStringServer address, “127.0.0.1:4002” by default
runtime_sizeIntegerThe number of server worker threads, 2 by default
influxdb_optionsInfluxDB Protocol options
enableBooleanWhether to enable InfluxDB protocol in HTTP API, true by default
opentsdb_optionsOpenTSDB Protocol options
addrStringOpenTSDB telnet API server address, “127.0.0.1:4242” by default
runtime_sizeIntegerThe number of server worker threads, 2 by default
prometheus_optionsPrometheus protocol options
enableBooleanWhether to enable Prometheus remote write and read in HTTP API, true by default
postgres_optionsPostgresSQL server options
addrStringServer address, “127.0.0.1:4003” by default
runtime_sizeIntegerThe number of server worker threads, 2 by default

Node options

There are also some node options in common:

OptionKeyTypeDescription
modeStringNode running mode, includes “standalone” and “distributed”
enable_memory_catalogBooleanUse in-memory catalog, false by default

Storage options

The storage options are valid in datanode and standalone mode, which specify the database data directory and other storage-related options.

GreptimeDB supports storing data in local file system, AWS S3 and compatible services (including minio, digitalocean space, Tencent Cloud Object Storage(COS), Baidu Object Storage(BOS) and so on), Azure Blob Storage and Aliyun OSS.

OptionKeyTypeDescription
storageStorage options
typeStringStorage type, Only supports “File”, “S3” and “Oss” etc.
FileLocal file storage options, valid when type=”file”
data_homeStringDatabase storage root directory, “/tmp/greptimedb” by default
S3AWS S3 storage options, valid when type=”S3”
bucketStringThe S3 bucket name
rootStringThe root path in S3 bucket
endpointStringThe API endpoint of S3
regionStringThe S3 region
access_key_idStringThe S3 access key id
secret_access_keyStringThe S3 secret access key
OssAliyun OSS storage options, valid when type=”Oss”
bucketStringThe OSS bucket name
rootStringThe root path in OSS bucket
endpointStringThe API endpoint of OSS
access_key_idStringThe OSS access key id
secret_access_keyStringThe OSS secret access key
AzblobAzure Blob Storage options, valid when type=”Azblob”
containerStringThe container name
rootStringThe root path in container
endpointStringThe API endpoint of Azure Blob Storage
account_nameStringThe account name of Azure Blob Storage
account_keyStringThe access key
sas_tokenStringThe shared access signature

A file storage sample configuration:

toml

  1. [storage]
  2. type = "File"
  3. data_home = "/tmp/greptimedb/"

A S3 storage sample configuration:

toml

  1. [storage]
  2. type = "S3"
  3. bucket = "test_greptimedb"
  4. root = "/greptimedb"
  5. access_key_id = "<access key id>"
  6. secret_access_key = "<secret access key>"

Object storage cache

When using S3, OSS or Azure Blob Storage, it’s better to enable object storage caching for speedup data querying:

toml

  1. [storage]
  2. type = "S3"
  3. bucket = "test_greptimedb"
  4. root = "/greptimedb"
  5. access_key_id = "<access key id>"
  6. secret_access_key = "<secret access key>"
  7. ## Enable object storage caching
  8. cache_path = "/var/data/s3_local_cache"
  9. cache_capacity = 1024

The cache_path is the local file directory that keeps cache files, and the cache_capacity is the maximum file number in the cache directory.

WAL options

The [wal] section in datanode or standalone config file configures the options of Write-Ahead-Log:

toml

  1. [wal]
  2. # WAL data directory
  3. # dir = "/tmp/greptimedb/wal"
  4. file_size = "1GB"
  5. purge_threshold = "50GB"
  6. purge_interval = "10m"
  7. read_batch_size = 128
  8. sync_write = false
  • dir: is the directory where to write logs. When using File storage, it’s {data_home}/wal by default. It must be configured explicitly when using other storage types such as S3 etc.
  • file_size: the maximum size of the WAL log file, default is 1GB.
  • purge_threshold and purge_interval: control the purging of wal files.
  • sync_write: whether to call fsync when writing every log.

Compaction

The [storage.compaction] section configures the compaction options of storage engine:

toml

  1. [storage.compaction]
  2. # Max task number that can concurrently run.
  3. max_inflight_tasks = 4
  4. # Max files in level 0 to trigger compaction.
  5. max_files_in_level0 = 8
  6. # Max task number for SST purge task after compaction.
  7. max_purge_tasks = 32

Manifest

The [storage.manifest] section configures the region manifest options of storage engine:

toml

  1. [storage.manifest]
  2. # Region checkpoint actions margin.
  3. # Create a checkpoint every <checkpoint_margin> actions.
  4. checkpoint_margin = 10
  5. # Region manifest logs and checkpoints gc execution duration
  6. gc_duration = '30s'
  7. # Whether to try creating a manifest checkpoint on region opening
  8. checkpoint_on_startup = false

Standalone

When you use GreptimeDB in the standalone mode, you can configure it as below:

toml

  1. mode = "standalone"
  2. [http_options]
  3. addr = "127.0.0.1:4000"
  4. timeout = "30s"
  5. [wal]
  6. #dir = "/tmp/greptimedb/wal"
  7. file_size = "1GB"
  8. purge_interval = "10m"
  9. purge_threshold = "50GB"
  10. read_batch_size = 128
  11. sync_write = false
  12. [storage]
  13. type = "File"
  14. data_home = "/tmp/greptimedb/"
  15. [grpc_options]
  16. addr = "127.0.0.1:4001"
  17. runtime_size = 8
  18. [mysql_options]
  19. addr = "127.0.0.1:4002"
  20. runtime_size = 2
  21. [influxdb_options]
  22. enable = true
  23. [opentsdb_options]
  24. addr = "127.0.0.1:4242"
  25. enable = true
  26. runtime_size = 2
  27. [prometheus_options]
  28. enable = true
  29. [postgres_options]
  30. addr = "127.0.0.1:4003"
  31. runtime_size = 2

Frontend in distributed mode

Configure frontend in distributed mode:

toml

  1. mode = "distributed"
  2. [http_options]
  3. addr = "127.0.0.1:4000"
  4. timeout = "30s"
  5. [meta_client_options]
  6. metasrv_addrs = ["127.0.0.1:3002"]
  7. timeout_millis = 3000
  8. connect_timeout_millis = 5000
  9. tcp_nodelay = false

The meta_client_options configure the metasrv client, including:

  • metasrv_addrs, metasrv address list
  • timeout_millis, operation timeout in milliseconds, 3000 by default.
  • connect_timeout_millis, connect server timeout in milliseconds,5000 by default.
  • tcp_nodelay, TCP_NODELAY option for accepted connections, true by default.

Datanode in distributed mode

Configure datanode in distributed mode:

toml

  1. node_id = 42
  2. mode = "distributed"
  3. rpc_addr = "127.0.0.1:3001"
  4. rpc_runtime_size = 8
  5. mysql_addr = "127.0.0.1:4406"
  6. mysql_runtime_size = 4
  7. [wal]
  8. #dir = "/tmp/greptimedb/wal"
  9. file_size = "1GB"
  10. purge_interval = "10m"
  11. purge_threshold = "50GB"
  12. read_batch_size = 128
  13. sync_write = false
  14. [storage]
  15. type = "File"
  16. data_home = "/tmp/greptimedb/"
  17. [meta_client_options]
  18. metasrv_addrs = ["127.0.0.1:3002"]
  19. timeout_millis = 3000
  20. connect_timeout_millis = 5000
  21. tcp_nodelay = false

Datanode in distributed mode should set different node_id in different nodes.

Metasrv configuration

A sample configurations:

toml

  1. bind_addr = "127.0.0.1:3002"
  2. server_addr = "127.0.0.1:3002"
  3. store_addr = "127.0.0.1:2379"
  4. datanode_lease_secs = 30
KeyTypeDescription
bind_addrStringThe bind address of metasrv, “127.0.0.1:3002” by default.
server_addrStringThe communication server address for frontend and datanode to connect to metasrv, “127.0.0.1:3002” by default for localhost
store_addrStringEtcd server address, “127.0.0.1:2379” by default
datanode_lease_secsIntegerDatanode lease in seconds, 15 seconds by default.

Environment variable

Every item in the configuration file can be mapped into environment variables. For example, if we want to set the configuration item max_inflight_tasks of datanode by environment variable:

toml

  1. # ...
  2. [storage.compaction]
  3. # Max task number that can concurrently run.
  4. max_inflight_tasks = 4
  5. # ...

You can use the following shell command to setup the environment variable as the following format:

  1. export GREPTIMEDB_DATANODE__STORAGE__COMPACTION__MAX_INFLIGHT_TASKS=4

Environment Variable Rules

  • Every environment variable should have the component prefix, for example:

    • GREPTIMEDB_FRONTEND
    • GREPTIMEDB_METASRV
    • GREPTIMEDB_DATANODE
    • GREPTIMEDB_STANDALONE
  • We use double underscore __ as a separator. For example, the above data structure storage.compaction.max_inflight_tasks will be transformed to STORAGE__COMPACTION__MAX_INFLIGHT_TASKS.

The environment variable also accepts list that are separated by a comma ,, for example:

  1. GREPTIMEDB_METASRV__META_CLIENT_OPTIONS__METASRV_ADDRS=127.0.0.1:3001,127.0.0.1:3002,127.0.0.1:3003