Skip to main content
Version: latest

Configuration

This section describes how to configure the CnosDB configuration.

The configuration adopts TOML syntax.

TOML Syntax Reference: https://toml.io

Use the cnosdb config command to create default configuration files, For example:

cnosdb run config > ./config.toml

Use the cnosdb check server-config <path> command to check if the configuration file is legal, for example:

cnosdb check server-config ./config.toml

Use the cnosdb command to specify the configuration file to start:

If not specified by the user, the program looks for the configuration first in /etc/cnosdb/cnosdb.conf, $HOME/cnosdb/cnosdb.conf, and if it does not find it, the default configuration is used.

cnosdb --config ./cnosdb.conf

Configuration in CnosDB is prioritized as follows: specified parameters > environment variables > specified configuration files > /etc/cnosdb/cnosdb.conf > $HOME/cnosdb/cnosdb.conf > default configuration

Environment Variables

All settings in the configuration file can be set or overridden using environment variables.If both exist in the file and environment variables, the environment variable will take precedence, and the value in the configuration file will be ignored.

To make these configuration settings available for CnosDB to use via environment variables, they must be in the following format:

CNOSDB_REPORTING_DISABLED=false

Description

This section introduces the configuration method and usage of each configuration.

Global

ParametersDefaultEnvironment VariablesDescription
node_id1001CNOSDB_NODE_IDNode ID
hostlocalhostCNOSDB_HOSTUsed to communicate with other nodes.
cluster_namecluster_xxxCNOSDB_CLUSTER_NAMECluster Name
store_metricstrueCNOSDB_STORE_METRICSWhether to track the usage of this node and store it in the usage_schema database.
pre_create_bucketfalseCNOSDB_PRE_CREATE_BUCKETPre-create bucket

[deployment]

ParametersDefaultEnvironment VariablesDescription
modequery_tskvCNOSDB_DEPLOYMENT_MODEDeployment mode, Optional: tskv, query, query_tskv, singleton. tskv: Deploying only tskv engine requires specifying a meta address. query: Only deploy the query engine, a meta address needs to be specified. query_tskv: query and tskv engines are both deployed, a meta address needs to be specified. singleton: Deploying a standalone version without specifying a meta address.
cpuEquivalent Node Core CountCNOSDB_DEPLOYMENT_CPUNumber of CPU cores used by the node to run
memoryEquivalent nodes CPUCNOSDB_DEPLOYMENT_MEMORYMaximum memory used by the node during operation, unit: (G)

[meta]

ParametersDefaultEnvironment VariablesDescription
service_addr["127.0.0.1:8901"]CNOSDB_META_SERVICE_ADDRRemote meta Service port
report_time_interval30sCNOSDB_META_REPORT_TIME_INTERVALTime interval between reporting heart, disk balance and other information on this node to meta service in: seconds.

[query]

ParametersDefaultEnvironment VariablesDescription
max_server_connections10240CNOSDB_QUERY_MAX_SERVER_CONNECTIONSMaximum number of concurrent connection requests.
query_sql_limit16777216CNOSDB_QUERY_QUERY_SQL_LIMITMaximum number of bytes per SQL query request, unit: Bytes
write_sql_limit167772160CNOSDB_QUERY_WRITE_SQL_LIMITMaximum number of bytes per Line Protocol to write to the request, unit: Bytes
auth_enabledfalseCNOSDB_QUERY_AUTH_ENABLEDWhether to start checking user permissions.
read_timeout3000msCNOSDB_QUERY_READ_TIMEOUTquery visits the timeout of tskv in units: ms
write_timeout3000msCNOSDB_QUERY_WRITE_TIMEOUTTimeout for writing to tskv in unit: ms
stream_trigger_cpu1CNOSDB_QUERY_STREAM_TRIGGER_CPUNumber of CPUs to prepare stream calculation tasks
stream_executor_cpu2CNOSDB_QUERY_STREAM_EXECUTOR_CPUNumber of CPUs to execute stream calculation tasks
sql_record_timeout10sCNOSDB_QUERY_SQL_RECORD_TIMEOUTThe lowest execution time of the sql is recorded in the cluster_schema.sql_history table

[storage]

ParametersDefaultEnvironment VariablesDescription
path/etc/cnosdb/cnosdb.confCNOSDB_STORAGE_PATHData storage directory.
max_summary_size128MCNOSDB_STORAGE_MAX_SUMMARY_SIZEMaximum size of a single Summary log.
base_file_size16MCNOSDB_STORAGE_BASE_FILE_SIZESingle file data size.
flush_req_channel_cap16CNOSDB_STORAGE_FLUSH_REQ_CHANNEL_CAPCumulative flush task ceiling.
max_cache_readers32CNOSDB_STORAGE_MAX_CACHE_READERSThe maximum count of file handles (for querying) opened in each vnode.
max_level4CNOSDB_STORAGE_MAX_LEVELThe maximum number of layers of the LSM, in the range 0-4.
compact_trigger_file_num4CNOSDB_STORAGE_COMPACT_TRIGGER_FILE_NUMNumber of files to trigger compaction.
compact_trigger_cold_duration1hCNOSDB_STORAGE_COMPACT_TRIGGER_COLD_DURATIONCompaction is triggered when no action is taken during the time period.
max_compact_size2GCNOSDB_STORAGE_MAX_COMPACT_SIZEMaximum selected file size for compaction.
max_concurrent_compaction4CNOSDB_STORAGE_MAX_CONCURRENT_COMPACTIONMaximum number of compaction tasks to be performed simultaneously.
strict_writefalseCNOSDB_STORAGE_STRICT_WRITEWhether to enable strict writing.
reserve_space0CNOSDB_STORAGE_RESERVE_SPACEThe size of the retained space of the system.
copyinto_trigger_flush_size128MCNOSDB_STORAGE_COPYINTO_TRIGGER_FLUSH_SIZECOPY INTO Export triggers the memory size of the disk.Supported version: >2.3.4.3
max_datablock_size100KBCNOSDB_STORAGE_MAX_DATABLOCK_SIZEMaximum size of data block at the time it is computed.
index_cache_capacity100000CNOSDB_STORAGE_INDEX_CACHE_CAPACITYIndex cache capacity

[wal]

ParametersDefaultEnvironment VariablesDescription
enabledtrueCNOSDB_WAL_ENABLEDWhether to enable WAL.
path/var/lib/cnosdb/walCNOSDB_WAL_PATHWAL storage directory.
wal_req_channel_cap64CNOSDB_WAL_WAL_REQ_CHANNEL_CAPCumulative write WAL task ceiling.
max_file_size1GCNOSDB_WAL_MAX_FILE_SIZEMaximum size of a single WAL.
flush_trigger_total_file_size2GCNOSDB_WAL_FLUSH_TRIGGER_TOTAL_FILE_SIZEFlash when all WAL sizes reach this value.
syncfalseCNOSDB_WAL_SYNCWhether to sync for each writing.
sync_interval0CNOSDB_WAL_SYNC_INTERVALThe time interval for synchronizing WAL, default: 0, i.e. not actively synchronizing, Unit: hmsmsusns

[cache]

ParametersDefaultEnvironment VariablesDescription
max_buffer_size128MCNOSDB_CACHE_MAX_BUFFER_SIZEMaximum active cache size.
partitionEquivalent nodes CPUCNOSDB_CACHE_PARTITIONNumber of partitions to memcache cache, default value equals CPU quantity

[log]

ParametersDefaultEnvironment VariablesDescription
levelinfoCNOSDB_LOG_LEVELLog Level (debug, info, error, warn).
path/var/log/cnosdbCNOSDB_LOG_PATHLog storage directory.
max_file_countUnlimitedCNOSDB_LOG_MAX_FILE_COUNTMaximum number of log files to keep.
file_rotationdailyCNOSDB_LOG_FILE_ROTATIONLog files are split between time intervals (daily, hourly, minutely, never).

[security.tls_config]

ParametersDefaultEnvironment VariablesDescription
certificateNoneCNOSDB_SECURITY_TLS_CONFIG_CERTIFICATETLS service certificate
private_keyNoneCNOSDB_SECURITY_TLS_CONFIG_PRIVATE_KEYTLS service private key

[service]

ParametersDefaultEnvironment VariablesDescription
http_listen_port8902CNOSDB_SERVICE_HTTP_LISTEN_PORTHTTP service listening port.
grpc_listen_port8903CNOSDB_SERVICE_GRPC_LISTEN_PORTGRPC service listening port.
grpc_enable_gzipfalseCNOSDB_SERVICE_GRPC_ENABLE_GZIPWhether to enable compression for data transmission of the meta service interface
flight_rpc_listen_port8904CNOSDB_SERVICE_FLIGHT_RPC_LISTEN_PORTFlight RPC service listening port.
tcp_listen_port8905CNOSDB_SERVICE_TCP_LISTEN_PORTTCP service listening port.
vector_listen_port8906CNOSDB_SERVICE_VECTOR_LISTEN_PORTUse to listen for Vector written data
enable_reporttrueCNOSDB_SERVICE_ENABLE_REPORTWhether to turn off the automatic reporting of telemetry data by CnosDB, mainly to track the usage rates of different versions of CnosDB, which is beneficial for the continuous development of CnosDB.Data is reported every 24 hours, each record includes: instance running time, operating system type, database version, geographical location of the instance (up to provincial or continental level).

[cluster]

ParametersDefaultEnvironment VariablesDescription
raft_logs_to_keep5000CNOSDB_CLUSTER_RAFT_LOGS_TO_KEEPRaft log retention count, and take a snapshot every these times written.
snapshot_holding_time3600sCNOSDB_CLUSTER_SNAPSHOT_HOLDING_TIMERaft snapshot retention time.
trigger_snapshot_interval600sCNOSDB_CLUSTER_TRIGGER_SNAPSHOT_INTERVALRaft trigger snapshot interval.
lmdb_max_map_size1024000000BCNOSDB_CLUSTER_LMDB_MAX_MAP_SIZEUsed to configure store Raft status data size.
heartbeat_interval3000msCNOSDB_CLUSTER_HEARTBEAT_INTERVALRaft Replica algorithm heartbeat intervals.
send_append_entries_timeout5000msCNOSDB_CLUSTER_SEND_APPEND_ENTRIES_TIMEOUTSend log timeout between Raft nodes.
install_snapshot_timeout3600000msCNOSDB_CLUSTER_INSTALL_SNAPSHOT_TIMEOUTTime to replica snapshot between Raft nodes.

[trace]

ParametersDefaultEnvironment VariablesDescription
auto_generate_spanfalseCNOSDB_TRACE_AUTO_GENERATE_SPANWhether to automatically generate a root span. This parameter is valid when the client does not carry a span context.
max_spans_per_traceNoneCNOSDB_TRACE_MAX_SPANS_PER_TRACESoft limits on the total number of spans and events in trace.
batch_report_interval500msCNOSDB_TRACE_BATCH_REPORT_INTERVALTime interval between two batch reports.
batch_report_max_spansNoneCNOSDB_TRACE_BATCH_REPORT_MAX_SPANSThe maximum number of soft limits for span in batch report.
otlp_endpointNoneCNOSDB_TRACE_OTLP_ENDPOINTGRPC address of OTLP collector.e.g. http://localhost:4317.

meta file description

Global

ParametersDefaultEnvironment VariablesDescription
id1CNOSDB_META_IDmeta node's ID, unique group
host127.0.0.1CNOSDB_META_HOSTHost to communicate with other nodes
port8901CNOSDB_META_PORTport for communicating with other nodes
data_path/var/lib/cnosdb/metaCNOSDB_META_DATA_PATHPath to the meta data store
cluster_namecluster_xxxCNOSDB_META_META_INIT_CLUSTER_NAMECluster Name
grpc_enable_gzipfalseCNOSDB_META_GRPC_ENABLE_GZIPWhether to enable compression for data transmission of the meta service interface
lmdb_max_map_sizefalseCNOSDB_META_LMDB_MAX_MAP_SIZEThe lmdb storage engine uses the maximum space value, store meta data and draft-related status
heartbeat_interval3000msCNOSDB_META_HEARTBEAT_INTERVALRaft Replica algorithm heartbeat intervals.
raft_logs_to_keep10000CNOSDB_META_RAFT_LOGS_TO_KEEPNumber of logs to trigger snapshot in Raft.
install_snapshot_timeout3600000msCNOSDB_META_INSTALL_SNAPSHOT_TIMEOUTTime to replica snapshot between Raft nodes.
send_append_entries_timeout5000msCNOSDB_META_SEND_APPEND_ENTRIES_TIMEOUTSend log timeout between Raft nodes.
usage_schema_cache_size2097152CNOSDB_META_USAGE_SCHEMA_CACHE_SIZEMaximum memory cache for usage_schema.
cluster_schema_cache_size2097152CNOSDB_META_CLUSTER_SCHAME_CACHE_SIZEMaximum memory cache for cluster_schema.
system_database_replica1CNOSDB_META_SYSTEM_DATABASE_REPLICAReplica of the system database.

[log]

ParametersDefaultEnvironment VariablesDescription
levelinfoCNOSDB_META_LOG_LEVELLog Level (debug, info, error, warn).
path/var/log/cnosdbCNOSDB_META_LOG_PATHLog storage directory.

[heartbeat]

ParametersDefaultDescription
heartbeat_recheck_interval300CNOSDB_META_HEARTBEAT_HEARTBEAT_RECHECK_INTERVALHow often to check the status of CnosDB nodes, in seconds.
heartbeat_expired_interval300CNOSDB_META_HEARTBEAT_HEARTBEAT_EXPIRED_INTERVALHow long has the CnosDB node not reported an abnormal heartbeat determination, measured in seconds.