diff --git a/.ci/docker-compose-file/docker-compose-emqx-cluster-mnesia.override.yaml b/.ci/docker-compose-file/docker-compose-emqx-cluster-mnesia.override.yaml index 1a255b2e1..17b008661 100644 --- a/.ci/docker-compose-file/docker-compose-emqx-cluster-mnesia.override.yaml +++ b/.ci/docker-compose-file/docker-compose-emqx-cluster-mnesia.override.yaml @@ -14,8 +14,8 @@ services: restart: on-failure environment: - "EMQX_HOST=node1.emqx.io" - - "EMQX_DB__BACKEND=mnesia" - - "EMQX_DB__ROLE=core" + - "EMQX_NODE__DB_BACKEND=mnesia" + - "EMQX_NODE__DB_ROLE=core" emqx2: <<: *default-emqx @@ -25,5 +25,5 @@ services: restart: on-failure environment: - "EMQX_HOST=node2.emqx.io" - - "EMQX_DB__BACKEND=mnesia" - - "EMQX_DB__ROLE=core" + - "EMQX_NODE__DB_BACKEND=mnesia" + - "EMQX_NODE__DB_ROLE=core" diff --git a/.ci/docker-compose-file/docker-compose-emqx-cluster-rlog.override.yaml b/.ci/docker-compose-file/docker-compose-emqx-cluster-rlog.override.yaml index 4c53ec3ae..7dc87a5d2 100644 --- a/.ci/docker-compose-file/docker-compose-emqx-cluster-rlog.override.yaml +++ b/.ci/docker-compose-file/docker-compose-emqx-cluster-rlog.override.yaml @@ -14,8 +14,8 @@ services: restart: on-failure environment: - "EMQX_HOST=node1.emqx.io" - - "EMQX_DB__BACKEND=rlog" - - "EMQX_DB__ROLE=core" + - "EMQX_NODE__DB_BACKEND=rlog" + - "EMQX_NODE__DB_ROLE=core" - "EMQX_CLUSTER__STATIC__SEEDS=[emqx@node1.emqx.io]" - "EMQX_LISTENERS__TCP__DEFAULT__PROXY_PROTOCOL=false" - "EMQX_LISTENERS__WS__DEFAULT__PROXY_PROTOCOL=false" @@ -28,9 +28,9 @@ services: restart: on-failure environment: - "EMQX_HOST=node2.emqx.io" - - "EMQX_DB__BACKEND=rlog" - - "EMQX_DB__ROLE=replicant" - - "EMQX_DB__CORE_NODES=emqx@node1.emqx.io" + - "EMQX_NODE__DB_BACKEND=rlog" + - "EMQX_NODE__DB_ROLE=replicant" + - "EMQX_CLUSTER__CORE_NODES=emqx@node1.emqx.io" - "EMQX_CLUSTER__STATIC__SEEDS=[emqx@node1.emqx.io]" - "EMQX_LISTENERS__TCP__DEFAULT__PROXY_PROTOCOL=false" - "EMQX_LISTENERS__WS__DEFAULT__PROXY_PROTOCOL=false" diff --git a/apps/emqx_conf/etc/emqx_conf.conf b/apps/emqx_conf/etc/emqx_conf.conf index 4fd1fb7cc..5e5883dd4 100644 --- a/apps/emqx_conf/etc/emqx_conf.conf +++ b/apps/emqx_conf/etc/emqx_conf.conf @@ -100,6 +100,20 @@ node { max_history = 100 cleanup_interval = 5m } + + ## Database backend + ## + ## @doc node.db_backend + ## ValueType: mnesia | rlog + ## Default: rlog + db_backend = rlog + + ## RLOG role + ## + ## @doc node.db_role + ## ValueType: core | replicant + ## Default: core + db_role = core } ##================================================================== @@ -142,6 +156,13 @@ cluster { ## Default: manual discovery_strategy = manual + ## Replicant core nodes + ## + ## @doc cluster.core_nodes + ## ValueType: comma-separated node list + ## Default: "" + core_nodes = "" + ##---------------------------------------------------------------- ## Cluster using static node list ##---------------------------------------------------------------- @@ -311,32 +332,6 @@ cluster { } } -##================================================================== -## Internal database -##================================================================== -db { - ## Database backend - ## - ## @doc db.backend - ## ValueType: mnesia | rlog - ## Default: rlog - backend = rlog - - ## RLOG role - ## - ## @doc db.role - ## ValueType: core | replicant - ## Default: core - role = core - - ## Replicant core nodes - ## - ## @doc db.core_nodes - ## ValueType: comma-separated node list - ## Default: "" - core_nodes = "" -} - ##================================================================== ## Log ##================================================================== diff --git a/apps/emqx_conf/src/emqx_conf_schema.erl b/apps/emqx_conf/src/emqx_conf_schema.erl index 46e036d66..5b3f8f1f7 100644 --- a/apps/emqx_conf/src/emqx_conf_schema.erl +++ b/apps/emqx_conf/src/emqx_conf_schema.erl @@ -93,11 +93,6 @@ roots() -> sc( ref("rpc"), #{translate_to => ["gen_rpc"]} - )}, - {"db", - sc( - ref("db"), - #{} )} ] ++ emqx_schema:roots(medium) ++ @@ -129,6 +124,16 @@ fields("cluster") -> 'readOnly' => true } )}, + {"core_nodes", + sc( + emqx_schema:comma_separated_atoms(), + #{ + mapping => "mria.core_nodes", + default => [], + 'readOnly' => true, + desc => ?DESC(db_core_nodes) + } + )}, {"autoclean", sc( emqx_schema:duration(), @@ -509,11 +514,8 @@ fields("node") -> sc( ref("cluster_call"), #{'readOnly' => true} - )} - ]; -fields("db") -> - [ - {"backend", + )}, + {"db_backend", sc( hoconsc:enum([mnesia, rlog]), #{ @@ -523,7 +525,7 @@ fields("db") -> desc => ?DESC(db_backend) } )}, - {"role", + {"db_role", sc( hoconsc:enum([core, replicant]), #{ @@ -533,16 +535,6 @@ fields("db") -> desc => ?DESC(db_role) } )}, - {"core_nodes", - sc( - emqx_schema:comma_separated_atoms(), - #{ - mapping => "mria.core_nodes", - default => [], - 'readOnly' => true, - desc => ?DESC(db_core_nodes) - } - )}, {"rpc_module", sc( hoconsc:enum([gen_rpc, rpc]), @@ -933,8 +925,6 @@ desc(cluster_k8s) -> ?DESC("desc_cluster_k8s"); desc("node") -> ?DESC("desc_node"); -desc("db") -> - ?DESC("desc_db"); desc("cluster_call") -> ?DESC("desc_cluster_call"); desc("rpc") -> diff --git a/bin/emqx b/bin/emqx index 8aaec26bd..af6751fa8 100755 --- a/bin/emqx +++ b/bin/emqx @@ -406,7 +406,7 @@ call_hocon() { ## Resolve boot configs in a batch ## This is because starting the Erlang beam with all modules loaded ## and parsing HOCON config + environment variables is a non-trivial task -CONF_KEYS=( 'node.data_dir' 'node.name' 'node.cookie' 'db.backend' ) +CONF_KEYS=( 'node.data_dir' 'node.name' 'node.cookie' 'node.db_backend' ) if [ "$IS_ENTERPRISE" = 'yes' ]; then CONF_KEYS+=( 'license.file' 'license.key' ) fi @@ -718,11 +718,11 @@ fi ## check if OTP version has mnesia_hook feature; if not, fallback to ## using Mnesia DB backend. -if [[ "$IS_BOOT_COMMAND" == 'yes' && "$(get_boot_config 'db.backend')" == "rlog" ]]; then +if [[ "$IS_BOOT_COMMAND" == 'yes' && "$(get_boot_config 'node.db_backend')" == "rlog" ]]; then if ! (echo -e "$COMPATIBILITY_INFO" | grep -q 'MNESIA_OK'); then echoerr "DB Backend is RLOG, but an incompatible OTP version has been detected. Falling back to using Mnesia DB backend." - export EMQX_DB__BACKEND=mnesia - export EMQX_DB__ROLE=core + export EMQX_NODE__DB_BACKEND=mnesia + export EMQX_NODE__DB_ROLE=core fi fi diff --git a/bin/emqx.cmd b/bin/emqx.cmd index ce5842c31..0c4741b95 100644 --- a/bin/emqx.cmd +++ b/bin/emqx.cmd @@ -64,8 +64,8 @@ @set node_type=-name @set schema_mod=emqx_conf_schema :: no advanced DB backend for Windows -@set EMQX_DB__BACKEND=mnesia -@set EMQX_DB__ROLE=core +@set EMQX_NODE__DB_BACKEND=mnesia +@set EMQX_NODE__DB_ROLE=core @set conf_path="%etc_dir%\emqx.conf"