Failing Over Databases Across Multiple Accounts¶
This topic describes the steps necessary to fail over your replicated databases across multiple accounts in different regions for disaster recovery.
Note
Only account administrators (users with the ACCOUNTADMIN role) can enable and manage failover for a database.
In this Topic:
Web Interface for Database Replication and Failover/Failback¶
Account administrators (users with the ACCOUNTADMIN role) can use the Replication area of the Databases tab in the Snowflake web interface to perform most actions related to configuring and managing database replication, including the following actions:
Promote a local database to serve as a primary database.
Enable failover for a primary database (Business Critical Edition accounts (or higher).
Refresh a secondary database, either once (manually) or repeatedly (on a schedule, using a task).
Promote a secondary database to serve as a primary database (Business Critical Edition accounts (or higher)).
Disable replication and/or failover for a primary database.
Prerequisite Requirements¶
Enable replication for a primary database in a set of accounts.
Create at least one secondary database (i.e. replica) of the primary database in one or more of the accounts specified in Step 1, and regularly refresh (i.e. synchronize) the replica with the latest updates to the primary database.
For instructions, see Replicating Databases Across Multiple Accounts.
Step 1: Viewing All Accounts in Your Organization¶
Retrieve the list of accounts in your organization to determine which accounts have been linked for database replication and failover.
To view the list of accounts in your organization, query SHOW REPLICATION ACCOUNTS.
SHOW REPLICATION ACCOUNTS;
+------------------+---------------------------------+---------------+------------+
| snowflake_region | created_on | name | comment |
|------------------+---------------------------------+---------------+------------|
| AWS_US_WEST_2 | 2018-11-19 16:11:12.720 -0700 | MYACCOUNT1 | |
| AWS_US_EAST_1 | 2019-06-02 14:12:23.192 -0700 | MYACCOUNT2 | |
+------------------+---------------------------------+---------------+------------+
See the complete list of Snowflake Region IDs.
Step 2: Enabling Failover for a Primary Database¶
Note
Skip this step if you enabled failover for this primary database in Replicating Databases Across Multiple Accounts.
Enable failover for a primary database to one or more accounts in your organization using an ALTER DATABASE … ENABLE FAILOVER TO ACCOUNTS statement. The replica of this primary database in any one of these accounts (i.e. a secondary database) can be promoted to serve as the primary database.
Note that enabling failover for a primary database can be done either before or after a replica of the primary database has been created in a specified account.
Example¶
Enable failover for primary database mydb1
(in region aws_us_west_2
) to accounts myaccount2
and myaccount3
(in regions aws_us_east_1
(AWS) and azure_westeurope
(Azure), respectively). In this example, suppose the primary database is stored in the myaccount1
account. The ALTER DATABASE command must be executed in that account:
ALTER DATABASE mydb1 ENABLE FAILOVER TO ACCOUNTS aws_us_east_1.myaccount2, azure_westeurope.myaccount3;
Step 3: Promoting a Replica Database to Serve as the Primary Database¶
Any replica of a primary database can be promoted to serve as the primary database by executing an ALTER DATABASE … PRIMARY statement. When promoted, the database becomes writeable. At the same time, the previous primary database becomes a read-only replica database.
Execute the ALTER DATABASE
statement in the account containing the secondary database that you are promoting.
Note
To promote a secondary database, the role used to perform the operation must have the OWNERSHIP privilege on the database.
Example¶
-- Promote a secondary database to serve as the primary database.
ALTER DATABASE mydb1 PRIMARY;
-- Verify that the former secondary database was promoted successfully.
SHOW REPLICATION DATABASES;
Snowflake Region IDs¶
The following table displays the complete list of Snowflake Region IDs:
Region |
Region ID |
Snowflake Region ID |
Notes |
---|---|---|---|
Amazon Web Services (AWS) |
|||
US West (Oregon)
|
|
|
|
US East (Ohio)
|
|
|
|
US East (N. Virginia)
|
|
|
|
US East (Commercial Gov - N. Virginia)
|
|
|
Available only for accounts on Business Critical (or higher); not located in AWS GovCloud (US), which is a separate, dedicated cloud not yet supported by Snowflake. |
Canada (Central)
|
|
|
|
EU (Ireland)
|
|
|
|
Europe (London)
|
|
|
|
EU (Frankfurt)
|
|
|
|
Asia Pacific (Tokyo)
|
|
|
|
Asia Pacific (Mumbai)
|
|
|
|
Asia Pacific (Singapore)
|
|
|
|
Asia Pacific (Sydney)
|
|
|
|
Google Cloud Platform (GCP) |
|||
US Central1 (Iowa)
|
|
|
|
Europe West2 (London)
|
|
|
|
Europe West4 (Netherlands)
|
|
|
|
Microsoft Azure |
|||
West US 2 (Washington)
|
|
|
|
East US 2 (Virginia)
|
|
|
|
US Gov Virginia
|
|
|
Available only for accounts on Business Critical (or higher). |
Canada Central (Toronto)
|
|
|
|
West Europe (Netherlands)
|
|
|
|
Southeast Asia (Singapore)
|
|
|
|
Switzerland North (Zurich)
|
|
|
|
Australia East (New South Wales)
|
|
|