8 Sharded Database Deployment
Sharded database deployment includes the prerequisites and instructions for installing the required software components, creating the catalog, roles, and the sharded database, configuring replication for high availability, and creating the schema for the sharded database.
The following topics contain the concepts and tasks you need to deploy a sharded database:
- Introduction to Sharded Database Deployment
Oracle Sharding provides the capability to automatically deploy the sharded database, which includes both the shards and the replicas. - Oracle Sharding Prerequisites
Before you install any software, review these hardware, network, and operating system requirements for Oracle Sharding. - Installing Oracle Database Software
Install Oracle Database on each system that will host the shard catalog or database shards. - Installing the Shard Director Software
Install the global service manager software on each system that you want to host a shard director. - Creating the Shard Catalog Database
Create an Oracle Database using DBCA to host the shard catalog. - Setting Up the Oracle Sharding Management and Routing Tier
The shard catalog, shard directors and shards must be configured to communicate with each other. - Creating and Deploying a System-Managed Sharded Database
- Creating and Deploying a User-Defined SDB
- Creating and Deploying a Composite SDB
To deploy a composite SDB you must install the required Oracle Sharding software components, configure the objects for a composite SDB, and create the schema. - Using Transparent Data Encryption with Oracle Sharding
Oracle Sharding supports Transparent Data Encryption (TDE), but in order to successfully move chunks in a sharded database with TDE enabled, all of the shards must share and use the same encryption key for the encrypted tablespaces.
8.1 Introduction to Sharded Database Deployment
Oracle Sharding provides the capability to automatically deploy the sharded database, which includes both the shards and the replicas.
The sharded database administrator defines the topology (regions, shard hosts, replication technology) and invokes the DEPLOY command with a declarative specification using the GDSCTL command-line interface.
At a high level, the deployment steps are:
-
Set up the components.
-
Create a database that hosts the shard catalog.
-
Install Oracle Database software on the shard nodes.
-
Install shard director (GSM) software on the shard director nodes.
Note:
For production deployments, it is highly recommended that you configure Data Guard for the shard catalog database. -
-
Specify the topology layout using the following commands.
-
CREATE SHARDCATALOG
-
ADD GSM
-
START GSM
-
ADD CREDENTIAL
(if usingCREATE SHARD
) -
ADD SHARDGROUP
-
ADD INVITEDNODE
-
CREATE SHARD
(orADD SHARD
) for each shard
-
-
Run
DEPLOY
and add the global service to access any shard in the sharded database.-
DEPLOY
-
ADD SERVICE
-
- Choosing a Deployment Method
You can deploy a sharded database, by creating the shards at the same time for a new database, or by adding the shards from a preexisting database. - Using Oracle Multitenant with Oracle Sharding
You can use a multitenant container database (CDB) containing pluggable databases (PDBs) as shards and shard catalogs in your Oracle Sharding configuration.
Parent topic: Sharded Database Deployment
8.1.1 Choosing a Deployment Method
You can deploy a sharded database, by creating the shards at the same time for a new database, or by adding the shards from a preexisting database.
Oracle Sharding supports two deployment methods. The first method is with the CREATE SHARD
command, where the creation of shards and the replication configuration are automatically done by the Oracle Sharding management tier. This method cannot be used in a multitenant architecture where PDBs are used as shards.
The second deployment method is with the ADD SHARD
command. If your database creation standards require that you deploy the SDB using your own pre-created databases, the ADD SHARD
deployment method supports this requirement by simply adding your prebuilt database shards.
Deployment Method: CREATE SHARD
The DEPLOY
command creates the shards. This is done using the DBMS_SCHEDULER
package (executed on the shard catalog), which communicates with the Scheduler agents on the remote shard hosts.
Agents then invoke DBCA and NETCA, and if Oracle GoldenGate replication is specified, GoldenGate Creation Assistance (GGCA) , to create the shards and the local listeners. After the primary shards are created the corresponding standby shards are built using the RMAN DUPLICATE
command.
When Data Guard is used as the high availability solution, once the primary and standby shards are built, the DEPLOY
command configures Data Guard Broker with Fast-Start Failover (FSFO) enabled. The FSFO observers are automatically started on the regional shard director.
Note:
The CREATE SHARD method is not supported for PDBs used as shards. Only the ADD SHARD methods can be used in a multitenant architecture.
Archivelog and flashback are enabled for all of the shards. This is required for the FSFO observer to perform standby auto-reinstantiation upon failover.
Deployment Method: ADD SHARD
Use the ADD SHARD
command to add shards to a sharded database configuration if you have your own database creation standards and prefer to deploy the sharded database using your own pre-created databases. This method is recommended for shards that are Oracle RAC-enabled, Oracle Restart-enabled, or PDB shards. This method is recommended when ASM is being used. The ADD SHARD
deployment method supports this requirement by adding shards, which already have database installations deployed on them, rather than creating new instances.
When the ADD SHARD
command is used for deployment, and Data Guard is used for high availability, the DEPLOY
command handles the configuration of Oracle GoldenGate, or Data Guard, Broker and Fast-start Failover. It also handles the scenario where you have pre-configured Data Guard for the shard that is being added.
Unlike sharding with Data Guard or Active Data Guard, you cannot deploy Oracle GoldenGate manually, it must be done using the DEPLOY
command.
Parent topic: Introduction to Sharded Database Deployment
8.1.2 Using Oracle Multitenant with Oracle Sharding
You can use a multitenant container database (CDB) containing pluggable databases (PDBs) as shards and shard catalogs in your Oracle Sharding configuration.
To support consolidation of databases on under-utilized hardware, for ease of management, or geographical business requirements, you can use PDBs in CDBs as database shards. For example, for database consolidation, you can add other, non-shard or shard PDBs to the CDB containing a shard PDB. A CDB can contain shard PDBs from different sharded databases, each with their own separate catalog databases. CDBs can support multiple PDB shards from different sharded databases; however, this support is limited to only one PDB shard from a given sharded database for each CDB.
To add a shard PDB to the sharded database configuration, you should first add the CDB in which that shard PDB is contained to the shard catalog. The GDSCTL command ADD CDB
is used to add a pre-created CDB to the shard catalog. Then, use the GDSCTL ADD SHARD
command with the -cdb
option to add shards which are a PDB contained within a CDB to the sharded database during deployment.
The following example adds a CDB with unique name db11 to the shard catalog and then adds it to shardgroup shgrp1 in a sharded database configuration.
GDSCTL> add cdb -connect CDB$ROOT_connect_string -pwd GSMROOTUSER_password
GDSCTL> add shard -cdb db11 -connect PDB_connect_string –shardgroup shgrp1
-deploy_as active_standby -pwd GSMUSER_password
Use CONFIG CDB
to display information about the CDB in the shard catalog.
GDSCTL> config cdb
Name: tstsdbyb
Connection string: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=cdb1host)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=cdb1.example.com)))
SCAN address:
ONS remote port: 0
Disk Threshold, ms: 20
CPU Threshold, %: 75
Version: 18.0.0.0
Rack:
Note:
Oracle GoldenGate replication does not support PDBs as shards.
Moving PDB Shards
You can manually unplug a shard PDB from a CDB, and plug it in to a different CDB. This can be done outside of the sharding interfaces, and then you can update the shard catalog metadata to indicate that the PDB shard has moved to another CDB. The GDSCTL command ADD SHARD
with the –REPLACE
option is used to update the location of the shard PDB in the shard catalog.
Certain PDB operations, such as unplugging and plugging an existing PDB back into the same CDB, using the SQL commands ALTER PLUGGABLE DATABASE UNPLUG
and ALTER PLUGGABLE DATABASE OPEN
, do not cause a registration update event. This can mean that the shard PDB will not show as registered in the GDSCTL config shard
output after it is plugged back in. If this occurs, a registration event can be forced by connecting to the PDB in SQL*Plus, and running a full shutdown and startup cycle for the PDB using the SHUTDOWN
and STARTUP
SQL commands.
PDB Shard High Availability
Oracle Data Guard supports replication only at the CDB level. The existing sharding architecture allows replicated copies of the sharded data for high availability, and it can optionally configure and use Data Guard to create and maintain these copies. Data Guard does not currently support replication at the PDB level; it can only replicate an entire container.
If you choose to add PDB shards from different sharded databases into the same CDB, then the replication topology in all of the resident sharded databases in the CDB must match. It is possible to create an invalid configuration where the sharded databases are configured with a different number of standby PDBs in each Data Guard configuration, so it is your responsibility to ensure that this mismatch does not happen by validating the numbers and locations of the PDBs and CDBs in each sharded database.
Making Changes to CDB in Sharding Configuration
Use MODIFY CDB
to change the metadata of the CDB in the shard catalog. Some parameters cannot be used after the CDB contains shards, or contains shards that have been deployed.
GDSCTL> modify cdb -shard cdb1 -pwd new_GSMROOTUSER_password
Use REMOVE CDB
to remove a CDB from the shard catalog. Removing a CDB does not destroy it.
GDSCTL> remove cdb -cdb cdb1
Upgrading from a Non-PDB Shard to a PDB Shard
When upgrading from a non-PDB sharded environment to one which makes use of PDBs, you must back up each existing non-PDB shard and then create a new CDB, and a PDB inside it. The shard is then restored to the PDB inside the CDB, as the CDB migration guide recommends. At this point, the shard has become a PDB inside a CDB, and you use the GDSCTL ADD CDB
command to add the new CDB, and then run ADD SHARD -REPLACE
, specifying the connect string of the PDB, to tell the sharding infrastructure to replace the old location of the shard with new PDB location.
Database Compatibility and Migration
When upgrading from an Oracle Database 18c installation which contains a single PDB shard for a given CDB, you must update the shard catalog metadata for any PDB. Specifically, in 18c, the name of a PDB shard is the db_unique_name of its CDB; however, in Oracle Database 19c, the shard names are db_unique_name_of_CDB_pdb_name.
To update the catalog metadata to reflect this new naming methodology, and to also support the new GSMROOTUSER
account as described in About the GSMROOTUSER Account, perform the following steps during the upgrade process as described in Upgrading Sharded Database Components.
- After upgrading any CDB that contains a PDB shard, ensure that the GSMROOTUSER account exists, is unlocked, has been assigned a password, and has been granted SYSDG, SYSBACKUP, and gsmrootuser_role privileges. The following SQL statements in SQL*Plus will successfully set up GSMROOTUSER while connected to the root container (CDB$ROOT) of the CDB.
SQL> alter session set "_oracle_script"=true; Session altered. SQL> create user gsmrootuser; User created. SQL> alter user gsmrootuser identified by new_GSMROOTUSER_password account unlock; User altered. SQL> grant sysdg, sysbackup, gsmrootuser_role to gsmrootuser container=current; Grant succeeded. SQL> alter session set "_oracle_script"=false; Session altered.
-
After upgrading the catalog database to the desired Oracle Database version, run the following PL/SQL procedure to update the catalog metadata to reflect the new name for the PDB shards present in the configuration. This procedure must be executed for each Oracle Database 18c PDB shard.
The first parameter to
pdb_fixup
is the value ofdb_unique_name
in the CDB that contains the PDB shard. In Oracle Database 18c, this is the same as the shard name as shown bygdsctl config shard
.The second parameter is the PDB name of the shard PDB as shown by
show con_name
in SQL*Plus when connected to the shard PDB.The
pdb_fixup
procedure will update the catalog metadata to make it compatible with the new naming method for PDB shards.SQL> connect sys/password as sysdba Connected. SQL> set serveroutput on SQL> execute gsmadmin_internal.dbms_gsm_pooladmin.pdb_fixup('cdb1', 'pdb1');
- After upgrading all shard directors to the desired version, run the following GDSCTL command once for each CDB in the configuration to inform the shard directors of the password for the
GSMROOTUSER
in each CDB.GDSCTL> modify cdb -cdb CDB_name -pwd new_GSMROOTUSER_password
See Also:
Oracle Database Global Data Services Concepts and Administration Guide for information about the GDSCTL commands used with PDB shards
Oracle Multitenant Administrator's Guide for information about Oracle Multitenant
Parent topic: Introduction to Sharded Database Deployment
8.2 Oracle Sharding Prerequisites
Before you install any software, review these hardware, network, and operating system requirements for Oracle Sharding.
-
Hardware and operating system requirements for the shards are the same as those on which Oracle Database is supported. See your Oracle Database installation documentation for these requirements.
-
Hardware, software, and operating system requirements for the shard catalog and shard directors are the same as those on which the Global Data Services catalog and global service manager are supported. See Oracle Database Global Data Services Concepts and Administration Guide for these requirements.
-
Network requirements are Low Latency GigE
-
Port communication requirements are listed below. All of the following are required for using CREATE SHARD. When using ADD SHARD, items 4 and 5 are not relevant.
-
Each and every shard must be able to reach each and every shard director's listener and ONS ports. The default listener port of the shard director is 1522, and the default ONS ports on most platforms are 6123 for the local ONS and 6234 for remote ONS. These shard director listener ports and the ONS ports must also be opened to the application/client tier, all of the shards, the shard catalog, and all other shard directors.
-
Each and every shard must be able to reach the TNS Listener port of the shard catalog (both primary and standby).
-
The TNS Listener port (default 1521) of each shard must be opened to shard directors and the shard catalog.
-
On the primary and standby shard catalog database, the port used for
-agent_port
(default 8080) in theCREATE SHARDCATALOG
command must be visible to all of the shards. -
The scheduler agent port on all of the shards must be visible to shard catalog node. Execute
schagent -status
on each shard to identify the port.
-
Parent topic: Sharded Database Deployment
8.3 Installing Oracle Database Software
Install Oracle Database on each system that will host the shard catalog or database shards.
Before installing Oracle Database, create an operating system user on all of the systems where you will be hosting the sharded database, shard catalog, and shard directors, and assign them to the DBA group. Allow the user to run su
, and make note of the credentials so that you can use them in later procedures.
See Oracle Database Installation Guide for Linux, or your platform’s installation guide, for information about configuring operating system users.
- Download the Oracle Database installer on all of the systems that will host the shard catalog or the database shards.
- Install Oracle Database on all of the systems where you intend to host the shard catalog and sharded database.
See Also:
Oracle Database Installation Guide for Linux for more information about using the response file for silent installation of Oracle Database
Parent topic: Sharded Database Deployment
8.4 Installing the Shard Director Software
Install the global service manager software on each system that you want to host a shard director.
Parent topic: Sharded Database Deployment
8.5 Creating the Shard Catalog Database
Create an Oracle Database using DBCA to host the shard catalog.
Parent topic: Sharded Database Deployment
8.6 Setting Up the Oracle Sharding Management and Routing Tier
The shard catalog, shard directors and shards must be configured to communicate with each other.
Before you begin, carefully read through the port requirements prerequisites listed in Oracle Sharding Prerequisites, and make any changes necessary before proceeding with the tasks in this section.
See Also:
Oracle Database Global Data Services Concepts and Administration Guide for information about usage and options for the GDSCTL commands.
Parent topic: Sharded Database Deployment
8.7 Creating and Deploying a System-Managed Sharded Database
The following topics describe the tasks for creating and deploying a system-managed sharded database.
- Deploying a System-Managed Sharded Database
To deploy a system-managed sharded database you create shardgroups and shards, create and configure the databases to be used as shards, execute theDEPLOY
command, and create role-based global services. - Creating a Schema for a System-Managed Sharded Database
Create the schema user, tablespace set, sharded tables, and duplicated tables for the sharded database. Verify that the DDLs are propagated to all of the shards, and, while connected to the shards, verify the automatic Data Guard Broker configuration with Fast-Start Failover. - System-Managed SDB Demo Application
The system-managed sharded database (SDB) demo application simulates the workload of an online retail store. Use it to validate the setup of any system-managed (automatic sharding) SDB configuration. The demo application also provides a practical example of sharding concepts for administrators and developers new to database sharding.
Parent topic: Sharded Database Deployment
8.7.1 Deploying a System-Managed Sharded Database
To deploy a system-managed sharded database you create shardgroups and shards, create and configure the databases to be used as shards, execute the DEPLOY
command, and create role-based global services.
System-managed sharding does not require the user to map data to shards. Data is automatically distributed across shards using partitioning by consistent hash. The partitioning algorithm evenly and randomly distributes data across shards. For more conceptual information about the system-managed sharded Database, see System-Managed Sharding.
See Also:
Creating a Schema for a System-Managed Sharded Database
Oracle Database Global Data Services Concepts and Administration Guide for more information about GDSCTL command usage
Parent topic: Creating and Deploying a System-Managed Sharded Database
8.7.2 Creating a Schema for a System-Managed Sharded Database
Create the schema user, tablespace set, sharded tables, and duplicated tables for the sharded database. Verify that the DDLs are propagated to all of the shards, and, while connected to the shards, verify the automatic Data Guard Broker configuration with Fast-Start Failover.
See Also:
Oracle Database Global Data Services Concepts and Administration Guide for information about GDSCTL command usage
Parent topic: Creating and Deploying a System-Managed Sharded Database
8.7.3 System-Managed SDB Demo Application
The system-managed sharded database (SDB) demo application simulates the workload of an online retail store. Use it to validate the setup of any system-managed (automatic sharding) SDB configuration. The demo application also provides a practical example of sharding concepts for administrators and developers new to database sharding.
The demo application assumes that a system-managed SDB environment was already created along with the CUSTOMER table-family. The environment may have any number of chunks and shards (database nodes). When run, the application will first populate the Products table and then start a one-hour workload that can be paused at any time by the administrator. The workload includes four types of transactions: create a customer order, lookup the list of orders, create a new product, and multi-shard query with report generation. All aspects of a sharded database configuration are exercised.
You can download the demo application, along with a README file that describes how to run and monitor it, from My Oracle Support Document 2184500.1.
Parent topic: Creating and Deploying a System-Managed Sharded Database
8.8 Creating and Deploying a User-Defined SDB
The following topics describe the tasks for creating and deploying a user-defined SDB.
- Deploying a User-Defined SDB
The following procedure describes how to deploy a user-defined sharded database using the ADD SHARD command and an Oracle Active Data Guard high availability solution. - Creating a Schema for a User-Defined SDB
Create the schema user, tablespace set, sharded tables, and duplicated tables for the SDB. Verify that the DDLs are propagated to all of the shards, and, while connected to the shards, verify the automatic Data Guard Broker configuration with Fast-Start Failover.
Parent topic: Sharded Database Deployment
8.8.1 Deploying a User-Defined SDB
The following procedure describes how to deploy a user-defined sharded database using the ADD SHARD command and an Oracle Active Data Guard high availability solution.
User-defined sharding allows the user to map data to shards. For more conceptual information about the user-defined sharding method, see User-Defined Sharding.
See Also:
Oracle Database Global Data Services Concepts and Administration Guide for more information about GDSCTL command usage
Parent topic: Creating and Deploying a User-Defined SDB
8.8.2 Creating a Schema for a User-Defined SDB
Create the schema user, tablespace set, sharded tables, and duplicated tables for the SDB. Verify that the DDLs are propagated to all of the shards, and, while connected to the shards, verify the automatic Data Guard Broker configuration with Fast-Start Failover.
See Also:
Oracle Database Global Data Services Concepts and Administration Guide for information about GDSCTL command usage
Parent topic: Creating and Deploying a User-Defined SDB
8.9 Creating and Deploying a Composite SDB
To deploy a composite SDB you must install the required Oracle Sharding software components, configure the objects for a composite SDB, and create the schema.
The composite sharding method allows you to create multiple shardspaces for different subsets of data in a table partitioned by consistent hash. A shardspace is set of shards that store data that corresponds to a range or list of key values.
The following topics describe the tasks for deploying a composite SDB.
- Deploying a Composite SDB
To deploy a composite SDB you create shardgroups and shards, execute theDEPLOY
command, and create role-based global services. - Creating a Schema for a Composite SDB
Create the schema user, tablespace set, sharded tables, and duplicated tables for the SDB. Verify that the DDLs are propagated to all of the shards, and, while connected to the shards, verify the automatic Data Guard Broker configuration with Fast-Start Failover.
Parent topic: Sharded Database Deployment
8.9.1 Deploying a Composite SDB
To deploy a composite SDB you create shardgroups and shards, execute the DEPLOY
command, and create role-based global services.
8.9.2 Creating a Schema for a Composite SDB
Create the schema user, tablespace set, sharded tables, and duplicated tables for the SDB. Verify that the DDLs are propagated to all of the shards, and, while connected to the shards, verify the automatic Data Guard Broker configuration with Fast-Start Failover.
Parent topic: Creating and Deploying a Composite SDB
8.10 Using Transparent Data Encryption with Oracle Sharding
Oracle Sharding supports Transparent Data Encryption (TDE), but in order to successfully move chunks in a sharded database with TDE enabled, all of the shards must share and use the same encryption key for the encrypted tablespaces.
A sharded database consists of multiple independent databases and a catalog database. For TDE to work properly, especially when data is moved between shards, certain restrictions apply. In order for chunk movement between shards to work when data is encrypted, you must ensure that all of the shards use the same encryption key.
There are two ways to accomplish this:
-
Create and export an encryption key from the shard catalog, and then import and activate the key on all of the shards individually.
-
Store the wallet in a shared location and have the shard catalog and all of the shards use the same wallet.
The following TDE statements are automatically propagated to shards when executed on the shard catalog with shard DDL enabled:
-
alter system set encryption wallet open/close identified by password
-
alter system set encryption key
-
administer key management set keystore [open|close] identified by password
-
administer key management set key identified by password
-
administer key management use key identified by password
-
administer key management create key store identified by password
Limitations
The following limitations apply to using TDE with Oracle Sharding.
-
For
MOVE CHUNK
to work, all shard database hosts must be on the same platform. -
MOVE CHUNK
cannot use compression during data transfer, which may impact performance. -
Only encryption on the tablespace level is supported. Encryption on specific columns is not supported.
- Creating a Single Encryption Key on All Shards
To propagate a single encryption key to all of the databases in the sharded database configuration, you must create a master encryption key on the shard catalog, then use wallet export, followed by wallet import onto the shards, and activate the keys.
See Also:
Oracle Database Advanced Security Guide for more information about TDE
Parent topic: Sharded Database Deployment
8.10.1 Creating a Single Encryption Key on All Shards
To propagate a single encryption key to all of the databases in the sharded database configuration, you must create a master encryption key on the shard catalog, then use wallet export, followed by wallet import onto the shards, and activate the keys.
Note:
This procedure assumes that the keystore password and wallet directory path are the same for the shard catalog and all of the shards. If you require different passwords and directory paths, all of the commands should be issued individually on each shard and the shard catalog with shard DDL disabled using the shard’s own password and path.
These steps should be done before any data encryption is performed.
All of the shards and the shard catalog database now have the same encryption key activated and ready to use for data encryption. On the shard catalog, you can issue TDE DDLs (with shard DDL enabled) such as:
-
Create encrypted tablespaces and tablespace sets.
-
Create sharded tables using encrypted tablespaces.
-
Create sharded tables containing encrypted columns (with limitations).
Validate that the key IDs on all of the shards match the ID on the shard catalog.
SELECT KEY_ID FROM V$ENCRYPTION_KEYS
WHERE ACTIVATION_TIME =
(SELECT MAX(ACTIVATION_TIME) FROM V$ENCRYPTION_KEYS
WHERE ACTIVATING_DBID = (SELECT DBID FROM V$DATABASE));
Parent topic: Using Transparent Data Encryption with Oracle Sharding