Setting up replicasets | Tarantool

Setting up replicasets

The cartridge replicasets command is used to configure replica sets on local start.

cartridge replicasets [subcommand] [flags] [args]

The following flags work with any replicasets subcommand:

--name Application name.
--run-dir The directory where PID and socket files are stored. Defaults to ./tmp/run or the run-dir value in .cartridge.yml.
--cfg Instances’ configuration file. Defaults to ./instances.yml or the cfg value in .cartridge.yml.

Replicasets are configured using the Cartridge Lua API. All instances in the topology are described in a single file, instances.yml (see the --cfg flag). The instances receive their configuration through instance console sockets that can be found in the run directory.

First, all the running instances mentioned in instances.yml are organized into a membership network. In this way, Cartridge checks if there are any instances that have already joined the cluster. One of these instances is then used to perform cluster operations.

cartridge replicasets setup [flags]

Setup replica sets using a file.


--file File with replica set configuration. Defaults to replicasets.yml.
--bootstrap-vshard Bootstrap vshard upon setup.

Example configuration:

  - router
  - vshard-router
  - app.roles.custom
  - s1-master
  - s1-replica
  - vshard-storage
  weight: 11
  all_rw: false
  vshard_group: default

All the instances should be described in instances.yml (or another file passed via --cfg).

cartridge replicasets save [flags]

Saves the current replica set configuration to a file.


--file The file to save the configuration to. Defaults to replicasets.yml.

cartridge replicasets list [flags]

Lists the current cluster topology.

cartridge replicasets join [INSTANCE_NAME...] [flags]

Joins an instance to a cluster.


--replicaset Name of the replica set

If a replica set with the specified alias isn’t found in cluster, it is created. Otherwise, instances are joined to an existing replica set.

To join an instance to a replica set, Cartridge requires the instance to have its advertise_uri specified in instances.yml.

cartridge replicasets list-roles [flags]

List the available roles.

cartridge replicasets list-vshard-groups [flags]

List the available vshard groups.

cartridge replicasets add-roles [ROLE_NAME...] [flags]

Add roles to the replica set.


--replicaset Name of the replica set
--vshard-group Vshard group for vshard-storage replica sets

cartridge replicasets remove-roles [ROLE_NAME...] [flags]

Remove roles from the replica set.


--replicaset Name of the replica set

cartridge replicasets set-weight WEIGHT [flags]

Specify replica set weight.


--replicaset Name of the replica set

cartridge replicasets set-failover-priority INSTANCE_NAME... [flags]

Configure replica set failover priority.


--replicaset Name of the replica set

cartridge replicasets bootstrap-vshard [flags]

Bootstrap vshard.

cartridge replicasets expel [INSTANCE_NAME...] [flags]

Expel one or more instances from the cluster.

We’ll use an application created with cartridge create. Here is its instances.yml file:

advertise_uri: localhost:3301
http_port: 8081

advertise_uri: localhost:3302
http_port: 8082

advertise_uri: localhost:3303
http_port: 8083

# other instances are hidden in this example

cartridge replicasets join --replicaset s-1 s1-master s1-replica

     Join instance(s) s1-master, s1-replica to replica set s-1
     Instance(s) s1-master, s1-replica have been successfully joined to replica set s-1

cartridge replicasets join --replicaset router router

     Join instance(s) router to replica set router
     Instance(s) router have been successfully joined to replica set router

cartridge replicasets list-roles

       Available roles:

cartridge replicasets add-roles --replicaset s-1 vshard-storage

     Add role(s) vshard-storage to replica set s-1
     Replica set s-1 now has these roles enabled:
       vshard-storage (default)

cartridge replicasets add-roles \
  --replicaset router \
  vshard-router app.roles.custom failover-coordinator metrics

     Add role(s) vshard-router, app.roles.custom, failover-coordinator, metrics to replica set router
     Replica set router now has these roles enabled:

cartridge replicasets bootstrap-vshard

     Bootstrap vshard task completed successfully, check the cluster status

cartridge replicasets list

     Current replica sets:
• router
Role: failover-coordinator | vshard-router | metrics | app.roles.custom
     router localhost:3301
• s-1                    default | 1
Role: vshard-storage
     s1-master localhost:3302
     s1-replica localhost:3303

cartridge replicasets expel s1-replica

     Instance(s) s1-replica have been successfully expelled
Found what you were looking for?