配置 GreptimeDB

本文介绍了配置 GreptimeDB server 的方法,用户可以在 TOML 文件中进行设置。

在配置文件中,对于缺失的参数,系统会赋予其一个默认值。

所有样本配置文件都放在项目的 config 文件夹中。

指定配置文件

用户可以通过使用命令行参数 -c [file_path] 指定配置文件,比如:

sh

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

常见配置

frontendstandalone 子命令中常见的协议配置有:

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

所有选项都是可选的,上面列出了其默认值。如果想禁用某些选项,比如 OpenTSDB 协议,可以删除 prometheus_options 或将其中 enable 的值设为 false

协议选项

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

节点选项

一些共同的节点选项:

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

存储选项

存储选项在 datanode 和单机模式下有效,它指定了数据库数据目录和其他存储相关的选项。

OptionKeyTypeDescription
storageStorage options
typeStringStorage type, Only supports “File” or “S3” right now
FileFile storage options, valid when type=”file”
data_dirStringData directory, “/tmp/greptimedb/data” by default
S3S3 storage options, valid when type=”S3”
bucketStringThe s3 bucket name
rootStringThe root path in s3 bucket
access_key_idStringThe s3 access key id
secret_access_keyStringThe s3 secret access key

文件存储配置范例:

toml

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

s3 配置范例:

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>"

Compaction

[storage.compaction] 中配置存储引擎的 compaction 选项:

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

[storage.manifest] 中配置存储引擎的 region manifest 选项:

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

单机模式

当用户在单机模式下使用 GreptimeDB 时,可以像下面这样进行配置:

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_dir = "/tmp/greptimedb/data/"
  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

在分布式模式下配置 Frontend

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

通过 meta_client_options 配置 metasrv 客户端,包括:

  • metasrv_addrs, metasrv 地址列表
  • timeout_millis, 操作超时时长,单位为毫秒,默认为 3000。
  • connect_timeout_millis,连接服务器超时时长,单位为毫秒,默认为 5000。
  • tcp_nodelay,接受连接时的 TCP_NODELAY 选项,默认为 true。

分布式模式下的 Datanode

在分布式模式下配置 datanode

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_dir = "/tmp/greptimedb/data/"
  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 应该在不同的节点上设置不同的 node_id

Metasrv 配置

一个配置范例:

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.