Project: YugabyteDB (App Definition and Development / Database)
File: synchronous-replication-ycql.md

title: Synchronous replication (3+ regions) in YCQL headerTitle: Synchronous replication (3+ regions) linkTitle: Synchronous (3+ regions) description: Global data distributed using synchronous replication across regions in YCQL. headcontent: Distribute data across regions menu: v2.16: identifier: explore-multi-region-deployments-sync-replication-2-ycql parent: explore-multi-region-deployments weight: 710 type: docs <ul class="nav nav-tabs-alt nav-tabs-yb"> <li > <a href="../synchronous-replication-ysql/" class="nav-link"> <i class="icon-postgres" aria-hidden="true"></i> YSQL </a> </li> <li > <a href="../synchronous-replication-ycql/" class="nav-link active"> <i class="icon-cassandra" aria-hidden="true"></i> YCQL </a> </li> </ul> YugabyteDB can be deployed in a globally distributed manner to serve application queries from the region closest to the end users with low latencies as well as to survive any outages to ensure high availability. This page simulates AWS regions on a local machine. First, you deploy YugabyteDB in the `us-west-2` region across multiple availability zones (`a`, `b`, `c`) and start a key-value workload against this cluster. Next, you change this setup to run across multiple geographic regions in US East (`us-east-1`) and Tokyo (`ap-northeast-1`), with the workload running uninterrupted during the entire transition. This page uses the local cluster management utility. If you have a previously running local cluster, destroy it using the following command: ```sh ./bin/yb-ctl destroy ``` Start a new local cluster with a replication factor (RF) of `3`, and each replica placed in different zones (`us-west-2a`, `us-west-2b`, `us-west-2c`) in the `us-west-2` (Oregon) region of AWS. This can be done by running the following command: ```sh ./bin/yb-ctl --rf 3 create --placement_info "aws.us-west-2.us-west-2a,aws.us-west-2.us-west-2b,aws.us-west-2.us-west-2c" ``` In this deployment, the YB-Masters are each placed in a separate zone to allow them to survive the loss of a zone. You can view the masters on the , as per the following illustration: You can view the tablet servers on the , as per the following illustration: Download the JAR file (`yb-sample-apps.jar`) by running the following command: ```sh wget https://github.com/yugabyte/yb-sample-apps/releases/download/1.3.9/yb-sample-apps.jar?raw=true -O

``` Run a `SqlInserts` workload in a separate shell: ```sh java -jar ./yb-sample-apps.jar --workload CassandraKeyValue \ --nodes 127.0.0.1:9042 \ --numthreadswrite 1 \ --numthreadsread 4 ``` You should now see some read and write load on the , as per the following illustration: Add a node in the zone `us-east-1a` of region `us-east-1`, as follows: ```sh ./bin/yb-ctl addnode --placementinfo "aws.us-east-1.us-east-1a" ``` Add another node in the zone `ap-northeast-1a` of region `ap-northeast-1`, as follows: ```sh ./bin/yb-ctl addnode --placementinfo "aws.ap-northeast-1.ap-northeast-1a" ``` At this point, these two new nodes are added into the cluster but are not taking any read or write IO. This is because YB Master's initial placement policy of storing data across the zones in `us-west-2` region still applies, as per the following illustration: Update the placement policy, instructing the YB-Master to place data in the new regions, as follows: ```sh ./bin/yb-admin --master_addresses 127.0.0.1:7100,127.0.0.2:7100,127.0.0.3:7100 \ modifyplacementinfo aws.us-west-2.us-west-2a,aws.us-east-1.us-east-1a,aws.ap-northeast-1.ap-northeast-1a 3 ``` You should see that the data as well as the IO gradually moves from the nodes in `us-west-2b` and `us-west-2c` to the newly added nodes. The should look similar to the following illustration: You need to move the YB-Master from the old nodes to the new nodes. In order to do so, first start a new masters on the new nodes, as follows: ```sh ./bin/yb-ctl addnode --master --placementinfo "aws.us-east-1.us-east-1a" ``` ```sh ./bin/yb-ctl addnode --master --placementinfo "aws.ap-northeast-1.ap-northeast-1a" ``` Remove the old masters from the masters Raft group. Assuming nodes with IPs `127.0.0.2` and `127.0.0.3` were the two old nodes, run the following commands: ```sh ./bin/yb-admin --masteraddresses 127.0.0.1:7100,127.0.0.2:7100,127.0.0.3:7100,127.0.0.4:7100,127.0.0.5:7100 changemasterconfig REMOVESERVER 127.0.0.2 7100 ``` ```sh ./bin/yb-admin --masteraddresses 127.0.0.1:7100,127.0.0.3:7100,127.0.0.4:7100,127.0.0.5:7100 changemasterconfig REMOVESERVER 127.0.0.3 7100 ``` Remove the old nodes, as follows: ```sh ./bin/yb-ctl remove_node 2 ``` ```sh ./bin/yb-ctl remove_node 3 ``` Optionally, you can shutdown the local cluster created in Step 1, as follows: ```sh ./bin/yb-ctl destroy ```