Beruflich Dokumente
Kultur Dokumente
Suresh Gandhi
• 18 Years of Experience in IT
• Graduate in Commerce
• Started with Career in Foxpro/Sybase/Oracle 7
• Oracle Certified in year 2000
• ITIL & AWS Certified
• Blogging – http://db.geeksinsight.com
• AWS – Aut
• Oracle Cloud - Evaluation
• Knows about NOSQL, Bigdata, Middleware, EBS etc.
• Likes Automation but not over kill
• Companies – Oracle, IBM, HSBC, Open Universities Australia, Qualcomm
• Believes - Happy to Learn – Keen to Share |
WHAT IS SHARDING?
• NoSQL Databases
• Cassandra
• MongoDB
• CouchDB
• Etc….
http://www.oracle.com/technetwork/database/availability/oraclesharding-whitepaper-3675509.pdf
RAC VS SHARDING
• ACID properties and read consistency (very rich feature when compare to other databases)
• Multi-core scalability
• Advanced security
• ULA – If organisations has Unlimited License Agreement with EE, RAC, Goldengate / Dataguard,
then Sharding is at no cost.
• Shards - independent physical Oracle databases that host a subset of the sharded databas SDB (schema)
• Global service (GDS) - database services that provide access to data in an SDB , implementation of general service to a distributed service.
• Shard catalog – an Oracle Database that supports automated shard deployment, centralized management of a sharded database, and multi-shard queries, as like leader node, config instance in mongodb.
• Shard directors – network listeners that enable high performance connection routing based on a sharding key, its like mongos instance for instance and holds the key information which stored in shard catalog.
• Connection pools - at runtime, act as shard directors by routing database requests across pooled connections
• Management interfaces - GDSCTL (command-line utility) and Oracle Enterprise Manager (GUI) to manage shards
Oracle Sharding Architecture (12c R2)
shard1 shard1
db1 db1
Customer_orders Partition1 Customer_orders Partition1
Dataguard
Broder
SDB 1521
Global Shard Director
Primary Standby
Service
1521
Shared catalog
Select Connection
custid,customernumner,product,qty Pool Search shard2 shard2
Distributed
from customer_orders where
Metadata
db2 db2
cust_id=11030;
The requested Customer_orders Partition2 Customer_orders Partition2
Takes the hash key of this data is
customer id distributed to Dataguard
Broder
shard1 – db1
1521
Primary Standby
High
Availability
HOW IS THE DATA DISTRIBUTED?
• Duplicated Tables
In addition to sharded tables, an SDB can contain tables that are duplicated on all shards.
• Tablespaces
• Each partition of a sharded table is stored in a separate tablespace, making the tablespace the unit of data
distribution in an SDB.
• Tablespace Sets
• Tablespace Set is created to group the tablespaces between different shards
• Chunks
• Each chunk contains corresponding partitions from the tables or table family
SHARDING - METHODS
SUBPARTITION TEMPLATE ( SUBPARTITION per1 VALUES LESS THAN (TO_DATE('01/01/2000','DD/MM/YYYY')), SUBPARTITION per2
VALUES LESS THAN (TO_DATE('01/01/2010','DD/MM/YYYY')), SUBPARTITION per3 VALUES LESS THAN
(TO_DATE('01/01/2020','DD/MM/YYYY')),
SUBPARTITION future VALUES LESS THAN (MAXVALUE)) )
PARTITIONS AUTO ;
CHANGES TO SYNTAX – CREATE TABLESPACE/TABLES
• Oracle Sharding introduces changes to the SQL DDL statements. DDL statements
with this syntax can only be executed against a sharded database.
• truncate table
• truncate partition
• drop partition/subpartition
6 shardcat Configure Shard Catalog using GSDCTL – Create Shard Catalog in SCAT
7 shard1/shard2 Start the SCH Agent & Register Shard nodes to SCAT database
9 shardcat Deploy Shards using GSDCTL – This will eventually create databases in shard1/shard2
12 shardcat Create sample schema and Tablespace set and see that propagate to shard1/shard2
On shardcat Node:-
• Create Directories
mkdir –p /u01/app/oracle/flash_recover_area/SCAT
mkdir –p /u01/app/oracle/fast_recovery_area/SCAT
mkdir –p /u01/oradata/SCAT
mkdir –p /u01/app/oracle/admin/SCAT/adump
• Run DBCA
./dbca -silent \
-createDatabase \
-templateName General_Purpose.dbc \
-gdbName SCAT \
-sid SCAT \
-SysPassword ****\
-createAsContainerDatabase false\
-SystemPassword ***\
-emConfiguration NONE\
-redoLogFileSize 100 \
-recoveryAreaDestination /u01/app/oracle/SCAT \
-DatafileDestination /u01/app/oracle/SCAT
-storageType FS \
-listeners LISTENER12 \
-registerWithDirService false \
STEP 3: INSTALL GSM SOFTWARE IN SHARDCAT
In Shardcat Node:-
• Download from Oracle Downloads page or Edelivery.oracle.com
• Unzip the GSM Software
• Install as separate Home
STEP 5 : PREPARE SCAT DATABASE FOR SHARDING -
PREREQUISITES
In Shardcat : SCAT Database
startup force
execute dbms_xdb.sethttpport(8080);
commit;
@?/rdbms/admin/prvtrsch.plb
exec DBMS_SCHEDULER.SET_AGENT_REGISTRATION_PASS('oracleagent');
STEP 6:– CREATE SHARD CATALOG IN SCAT
In Shardcat node, in SCAT Database & Set environment to GSM Home
# gdsctl
GDSCTL> create shardcatalog -database shardcat:1521:SCAT -chunks 12 -user mygdsadmin/oracle -sdb SCAT -region region1
GDSCTL>add gsm -gsm sharddirector1 -listener 1571 -pwd oracle -catalog shardcat:1521:SCAT -region region1
GDSCTL> exit
STEP 7: START THE SCHEDULER AGENT ON SHARD NODES
In Shard1 & 2 :
Scheduler Agent is already installed if you install oracle database software just start it
#Set Oracle Home
#schagent start
#schagent status
# echo oracleagent | schagent –registerdatabase shardcat 8080 provide name of host not database
STEP 8 : CREATE SHARD GROUP/DIRECTOR/ADD SHARDS
gsdctl> deploy
Sqlplus / as sysdba
conn app_schema/oracle
SQL> CREATE TABLESPACE SET TSP_SET_1 using template (datafile size 100m extent management local segment space management auto );
SQL> CREATE TABLESPACE products_tsp datafile size 100m extent management local uniform size 1m;
Note: For any command that need to be shard, you must enable shard ddl at session level before running the sql command
STEP 13: CREATE SHARD TABLES
STEP 14: VERIFY DISTRIBUTION OF TABLES TO SHARDS
• Recovering Shard
• Deleting Shard
• Resharding
• Validating Shard
CONNECTING TO SHARD: USING SHARDING_KEY
GDSCTL>add service -service msrv
The operation completed successfully GDSCTL>
GDSCTL>config service
GDSCTL>
$sqlplus user/root@sh:1521/GDS\$CATALOG.localdomain
MULTISHARD QUERIES – KEY NOTES
References
https://docs.oracle.com/database/122/ADMIN/sharding-overview.htm#ADMIN-GUID-0F39B1FB-DCF9-4C8A-A2EA-88705B90C5BF
THANK YOU ALL FOR JOINING
SEE YOU AGAIN !!!
I am reachable via
Facebook : https://www.facebook.com/suresh.gandhi.739
Linkedin : https://www.linkedin.com/in/suresh-gandhip/
Blog : https://db.geeksinsight.com