Skip to content

配置 GreptimeDB

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

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

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

指定配置文件

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

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

常见配置

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

toml
[http_options]
addr = "127.0.0.1:4000"
timeout = "30s"

[grpc_options]
addr = "127.0.0.1:4001"
runtime_size = 8

[mysql_options]
addr = "127.0.0.1:4002"
runtime_size = 2

[mysql_options.tls]
mode = "disable"
cert_path = ""
key_path = ""

[postgres_options]
addr = "127.0.0.1:4003"
runtime_size = 2

[postgres_options.tls]
mode = "disable"
cert_path = ""
key_path = ""

[opentsdb_options]
addr = "127.0.0.1:4242"
runtime_size = 2

[influxdb_options]
enable = true

[prometheus_options]
enable = true
[http_options]
addr = "127.0.0.1:4000"
timeout = "30s"

[grpc_options]
addr = "127.0.0.1:4001"
runtime_size = 8

[mysql_options]
addr = "127.0.0.1:4002"
runtime_size = 2

[mysql_options.tls]
mode = "disable"
cert_path = ""
key_path = ""

[postgres_options]
addr = "127.0.0.1:4003"
runtime_size = 2

[postgres_options.tls]
mode = "disable"
cert_path = ""
key_path = ""

[opentsdb_options]
addr = "127.0.0.1:4242"
runtime_size = 2

[influxdb_options]
enable = true

[prometheus_options]
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
[storage]
type = "File"
data_dir = "/tmp/greptimedb/data/"
[storage]
type = "File"
data_dir = "/tmp/greptimedb/data/"

s3 配置范例:

toml
[storage]
type = "S3"
bucket = "test_greptimedb"
root = "/greptimedb"
access_key_id = "<access key id>"
secret_access_key = "<secret access key>"
[storage]
type = "S3"
bucket = "test_greptimedb"
root = "/greptimedb"
access_key_id = "<access key id>"
secret_access_key = "<secret access key>"

Compaction

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

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

Manifest

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

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

单机模式

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

toml
mode = "standalone"

[http_options]
addr = "127.0.0.1:4000"
timeout = "30s"

[wal]
dir = "/tmp/greptimedb/wal"
file_size = "1GB"
purge_interval = "10m"
purge_threshold = "50GB"
read_batch_size = 128
sync_write = false

[storage]
type = "File"
data_dir = "/tmp/greptimedb/data/"

[grpc_options]
addr = "127.0.0.1:4001"
runtime_size = 8

[mysql_options]
addr = "127.0.0.1:4002"
runtime_size = 2

[influxdb_options]
enable = true

[opentsdb_options]
addr = "127.0.0.1:4242"
enable = true
runtime_size = 2

[prometheus_options]
enable = true

[postgres_options]
addr = "127.0.0.1:4003"
runtime_size = 2
mode = "standalone"

[http_options]
addr = "127.0.0.1:4000"
timeout = "30s"

[wal]
dir = "/tmp/greptimedb/wal"
file_size = "1GB"
purge_interval = "10m"
purge_threshold = "50GB"
read_batch_size = 128
sync_write = false

[storage]
type = "File"
data_dir = "/tmp/greptimedb/data/"

[grpc_options]
addr = "127.0.0.1:4001"
runtime_size = 8

[mysql_options]
addr = "127.0.0.1:4002"
runtime_size = 2

[influxdb_options]
enable = true

[opentsdb_options]
addr = "127.0.0.1:4242"
enable = true
runtime_size = 2

[prometheus_options]
enable = true

[postgres_options]
addr = "127.0.0.1:4003"
runtime_size = 2

分布式模式下的 Frontend

在分布式模式下配置 Frontend

toml
mode = "distributed"

[http_options]
addr = "127.0.0.1:4000"
timeout = "30s"

[meta_client_options]
metasrv_addrs = ["127.0.0.1:3002"]
timeout_millis = 3000
connect_timeout_millis = 5000
tcp_nodelay = false
mode = "distributed"

[http_options]
addr = "127.0.0.1:4000"
timeout = "30s"

[meta_client_options]
metasrv_addrs = ["127.0.0.1:3002"]
timeout_millis = 3000
connect_timeout_millis = 5000
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
node_id = 42
mode = "distributed"
rpc_addr = "127.0.0.1:3001"
rpc_runtime_size = 8
mysql_addr = "127.0.0.1:4406"
mysql_runtime_size = 4

[wal]
dir = "/tmp/greptimedb/wal"
file_size = "1GB"
purge_interval = "10m"
purge_threshold = "50GB"
read_batch_size = 128
sync_write = false

[storage]
type = "File"
data_dir = "/tmp/greptimedb/data/"

[meta_client_options]
metasrv_addrs = ["127.0.0.1:3002"]
timeout_millis = 3000
connect_timeout_millis = 5000
tcp_nodelay = false
node_id = 42
mode = "distributed"
rpc_addr = "127.0.0.1:3001"
rpc_runtime_size = 8
mysql_addr = "127.0.0.1:4406"
mysql_runtime_size = 4

[wal]
dir = "/tmp/greptimedb/wal"
file_size = "1GB"
purge_interval = "10m"
purge_threshold = "50GB"
read_batch_size = 128
sync_write = false

[storage]
type = "File"
data_dir = "/tmp/greptimedb/data/"

[meta_client_options]
metasrv_addrs = ["127.0.0.1:3002"]
timeout_millis = 3000
connect_timeout_millis = 5000
tcp_nodelay = false

分布式模式下的 datanode 应该在不同的节点上设置不同的 node_id

Metasrv 配置

一个配置范例:

toml
bind_addr = "127.0.0.1:3002"
server_addr = "127.0.0.1:3002"
store_addr = "127.0.0.1:2379"
datanode_lease_secs = 30
bind_addr = "127.0.0.1:3002"
server_addr = "127.0.0.1:3002"
store_addr = "127.0.0.1:2379"
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.