docs/en/08-operation/18-ha/01-replica3.md
TDengine TSDB in three-replica configuration uses the Raft algorithm to ensure consistency for both metadata and time-series data. Each vgroup is a Raft group, and the vnodes within the group are the members of that Raft group, also referred to as replicas.
For details on how multi-replica mechanisms work, see Data Writing and Replication Process.
The three-replica architecture requires at least three server nodes. The basic deployment and configuration steps are as follows:
Create two additional dnodes in your cluster for a total of three dnodes:
CREATE dnode <dnode_ep> port <dnode_port>;
CREATE dnode <dnode_ep> port <dnode_port>;
Create mnodes on the two dnodes for a total of three mnodes:
CREATE mnode on dnode <dnode_id>;
CREATE mnode on dnode <dnode_id>;
Create a three-replica database:
create database <dbname> replica 3 vgroups xx buffer xx ...
If you have already created a database with fewer than three replicas, you can change it into a three-replica database:
alter database <dbname> replica 3|1
DB error: Out of dnodesDB error: Vnodes exhausted