|
| 1 | +# Setup Global Active Tables |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +This lab picks up where Lab 4 left off. You are going to setup a GAT configuration, |
| 6 | +and deploy your application in multiple regions. Oracle NoSQL Global Active Tables |
| 7 | +provide multi-active replication of table data between geographically separated regions. |
| 8 | + |
| 9 | +_Estimated Time:_ 20 minutes |
| 10 | + |
| 11 | +### Objectives |
| 12 | + |
| 13 | +* GAT Offers low-latency local access to data irrespective of where the data originated. |
| 14 | + |
| 15 | +### Prerequisites |
| 16 | + |
| 17 | +* An Oracle Free Tier, Paid Account or Green Button |
| 18 | +* Connection to the Oracle NoSQL Database Cloud Service |
| 19 | +* Working knowledge of bash shell |
| 20 | + |
| 21 | + |
| 22 | +## Task 1: Create a GAT |
| 23 | + |
| 24 | +Before deploying the application in multiple regions, we will create replicas for `movie` table. |
| 25 | + |
| 26 | +1. From the hamburger menu, click **Databases**. Under Oracle NoSQL Databases, click **Tables**. |
| 27 | +Click the **Movie** table. Under **Resources**, click **Replicas**. |
| 28 | +The list of replicas already created in the table is listed. In our case, the list start empty |
| 29 | + |
| 30 | + |
| 31 | +2. Click on `Add replica` button. |
| 32 | + |
| 33 | +3. Choose a Replication region from the list. It does not matter which one is selected. Other information does not need to be changed for this LiveLab. Click **Add Replica**. |
| 34 | + |
| 35 | +  |
| 36 | + |
| 37 | +4. Wait few second until the deployment is created - Status will change from Updating to Active. Any data that was in the originating table (the table created in Lab 2) will be immediately pushed to the newly created replica. |
| 38 | + |
| 39 | +  |
| 40 | + |
| 41 | + Click on the link for the `replica` added. It will open a new Tab with the information for the region selected. |
| 42 | + |
| 43 | +5. You can query the table created as we learned in lab 3. You will have exactly the same data in both regions. |
| 44 | + |
| 45 | +  |
| 46 | + |
| 47 | +6. Modify a row in a region and query in the other region to verify that the changes got pushed to the other region. |
| 48 | + |
| 49 | + |
| 50 | +## Task 2: Set up the Movie Stream Catalog Microservice in the New Region |
| 51 | + |
| 52 | +We are going to set up the Movie Stream Microservice in the new region and follow similar steps to what we used in **Lab 3 - Run the Movie Stream Catalog Microservice.** |
| 53 | + |
| 54 | +1. Let's get back into the Cloud Shell. We will execute in the tab on the remote region. |
| 55 | + |
| 56 | +  |
| 57 | + |
| 58 | +2. Execute the following environment setup shell script in the Cloud Shell to |
| 59 | +set up your environment. If you close/open the Cloud Shell Console, please re-execute it. |
| 60 | + |
| 61 | + ```shell |
| 62 | + <copy> |
| 63 | + export OCI_obo_token=$(cat $OCI_obo_token_path) |
| 64 | + source ~/global-microservices-springdata-nosql/env.sh |
| 65 | + </copy> |
| 66 | + ``` |
| 67 | +  |
| 68 | + |
| 69 | +3. List the installed JDKs using the `csruntimectl java list` command. Select GraalVM for JDK 17 as the current JDK. |
| 70 | + |
| 71 | + ```shell |
| 72 | + <copy> |
| 73 | + csruntimectl java list |
| 74 | + </copy> |
| 75 | + ``` |
| 76 | + |
| 77 | + ```shell |
| 78 | + <copy> |
| 79 | + csruntimectl java set graalvmjdk-17 |
| 80 | + </copy> |
| 81 | + ``` |
| 82 | + |
| 83 | +## Task 3: Start the Movie Stream Catalog Microservice and look at data |
| 84 | + |
| 85 | +1. Use the following maven wrapper command to start the Spring application. Execute in the Cloud Shell. |
| 86 | + |
| 87 | + ```shell |
| 88 | + <copy> |
| 89 | + cd ~/global-microservices-springdata-nosql/code-nosql-spring-sdk/ |
| 90 | + nohup ./mvnw spring-boot:run & |
| 91 | + </copy> |
| 92 | + ``` |
| 93 | + **Note:** This will start the "movie" application in the background. |
| 94 | + |
| 95 | +2. After you complete step 1, you can use the command tail to see the startup for the application |
| 96 | + |
| 97 | +  |
| 98 | + |
| 99 | + ```shell |
| 100 | + <copy> |
| 101 | + tail nohup.out |
| 102 | + </copy> |
| 103 | + ``` |
| 104 | + The `mvnw` command will compile and start the application, please wait for the message *Started DemoApplication in xx seconds* |
| 105 | + |
| 106 | +3. Lets review the data created in the prior Labs. Execute in the Cloud Shell. |
| 107 | + |
| 108 | + ```shell |
| 109 | + <copy> |
| 110 | + curl http://localhost:8080/api/movie | jq |
| 111 | + </copy> |
| 112 | + ``` |
| 113 | + |
| 114 | +4. Stop the application and delete temporary files |
| 115 | + |
| 116 | + execute the linux command `fg` followed by CTRL-C and enter to stop the application. |
| 117 | + ```shell |
| 118 | + <copy> |
| 119 | + fg |
| 120 | + </copy> |
| 121 | + ``` |
| 122 | + NB: you can rexecute the command `fg` to validate that there are not jobs running in background. |
| 123 | + |
| 124 | + Delete the temporary files created. |
| 125 | + ```shell |
| 126 | + <copy> |
| 127 | + rm nohup.out result-test.txt |
| 128 | + </copy> |
| 129 | + ``` |
| 130 | + |
| 131 | +5. Close the tab for the remote region. |
| 132 | + |
| 133 | + |
| 134 | +Adding a new region and standing up the application in that region is a straight forward process. You could use the same process to extend to even more regions. You can also use the application to insert new data into your replicated region and look to see that it got properly transmitted to the other region. |
| 135 | + |
| 136 | +## Task 4: Delete a remote region |
| 137 | + |
| 138 | + |
| 139 | +This task deletes the resources that got created. |
| 140 | + |
| 141 | +1. From the hamburger menu, click Databases. Under Oracle NoSQL Databases, click Tables. Click the Movie table. Under Resources, click Replicas. |
| 142 | +The list of replicas already created in the table is listed. Click on delete |
| 143 | + |
| 144 | +  |
| 145 | + |
| 146 | + Deleting tables is an async operation, the status will get changed to deleting. Wait for the end of this operation. |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | +You may now **proceed to the next lab.** |
| 151 | + |
| 152 | +## Learn More |
| 153 | + |
| 154 | + |
| 155 | +* [Oracle NoSQL Database Cloud Service page](https://www.oracle.com/database/nosql-cloud.html) |
| 156 | +* [Global Active Tables in NDCS](https://docs.oracle.com/en/cloud/paas/nosql-cloud/gasnd/) |
| 157 | + |
| 158 | + |
| 159 | +## Acknowledgements |
| 160 | +* **Author** - Dario Vega, Product Manager, NoSQL Product Management, Michael Brey, Director, NoSQL Product Development |
0 commit comments