Oracle sharding : Installation & Configuration
-
Upload
suresh-gandhi -
Category
Data & Analytics
-
view
259 -
download
8
Transcript of Oracle sharding : Installation & Configuration
Oracle 12c ShardingPart 2 – Installation & Configuration
Shared catalog
db1
db2
SDB
Connection Pool Search
Distributed MetadataThe requested data is distributed to shard1 – db1
Select custid,customernumner,product,qty from customer_orders where cust_id=11030;
Takes the hash key of this customer id
Global Service
Shard Director
Customer_orders Partition1
Customer_orders Partition2
Oracle Sharding Architecture (12c R2)
1521
shard2
1521
shard1
1521
Primary
Primary
db1
db2
Customer_orders Partition1
Customer_orders Partition2
shard2
shard1
Standby
Standby
High Availability
Dataguard Broder
Dataguard Broder
Configuring Oracle Sharding – Environment Planning
Node Type IP Address Home Ports DB Name Scheduler Agent
Shard Catalog Node
192.168.56.150Host: shardcat
Oracle Home: /u01/app/oracle/12.2.0.1/db_1GSM home: /u01/app/oracle/12.2.0.1/GSM
GSM Listener 1539DB Listener 1521
SCAT
Shard1 192.168.56.151Host: shard1
Oracle Home: /u01/app/oracle/12.2.0.1/db_1 DB Listener 1521 sh1 Scheduler Agent -
Shard2 192.168.56.152Host: shard2
Oracle Home: /u01/app/oracle/12.2.0.1/db_1 DB Listener 1521 sh2 Scheduler Agent -
Steps to Configure Oracle ShardingStep Nodes/Hosts Step Details
1 shardcat/Shard1/Shard2 Install Oracle Software Only 12cR2 – Preferably Same Location
2 shardcat Create Database SCAT using DBCA (NON CDB)
3 shardcat Install GSM Software as Separate Home
4 shardcat Create Environment Setup
5 Shardcat Prepare SCAT database for Sharding - Prerequisities
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
8 shardcat Create Shard Group/Director/Add Shards
9 shardcat Deploy Shards using GSDCTL – This will eventually create databases in shard1/shard2
10 shardcat Verify Shard Configuration
11 shardcat Create Global Service using GSDCTL
12 shardcat Create sample schema and Tablespace set and see that propagate to shard1/shard2
13 shardcat Connect to sample schema and create shard table
14 Shardcat/shard1/shard2 Verify the sample table is created across shards
Step 1 : Install Oracle 12c R2 Software• Install Oracle 12cR2 Software on all three nodes shardcat/shard1/shard2
• Complete Pre-requisities• Install with Software only option
• Sample options to change in <softwarelocation>/response/db_install.rsporacle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=Geek DBA11g UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u02/app/oraInventory ORACLE_HOME=/u01/app/oracle/product/12.1.0/db_1 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=oper oracle.install.db.BACKUPDBA_GROUP=dba oracle.install.db.DGDBA_GROUP=asmadmin oracle.install.db.KMDBA_GROUP=dba SECURITY_UPDATES_VIA_MYORACLESUPPORT=false DECLINE_SECURITY_UPDATES=true
• Create Oracle Home Directories mkdir -p /u01/app/oracle/product/12.1.0/db_1mkdir -p /u02/app/oraInventory chown -R oracle:oinstall /u02/app/oraInventory
• Sample Run Installer Command./runInstaller -silent -ignoresysprereqs -responsefile /home/oracle/database/response/db_install.rsp
Step 2: Create ShardCatalog DatabaseOn shardcat Node:-
• Create Directoriesmkdir –p /u01/app/oracle/flash_recover_area/SCATmkdir –p /u01/app/oracle/fast_recovery_area/SCATmkdir –p /u01/oradata/SCATmkdir –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 \ -characterSet AL32UTF8 \ -nationalCharacterSet AL16UTF16 \ -databaseType MULTIPURPOSE \ -memoryPercentage 40 \
-memoryType AUTO
Step 3: Install GSM Software in ShardcatOn Shardcat Node:-• Download from Oracle Downloads page or Edelivery.oracle.com• Unzip the GSM Software• Install as separate Home
Step 4: Create Environment Setup in Shardcat
Step 5 : Prepare SCAT database for Sharding - Prerequisities On Shardcat : SCAT Database
alter system set db_create_file_dest='/u01/ora12c/app/oracle/oradata' scope=both; alter system set open_links=16 scope=spfile; alter system set open_links_per_instance=16 scope=spfile; startup force
alter user gsmcatuser account unlock; alter user gsmcatuser identified by oracle; CREATE USER mygdsadmin IDENTIFIED BY oracle; GRANT connect, create session, gsmadmin_role to mygdsadmin; grant inherit privileges on user SYS to GSMADMIN_INTERNAL;
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 On 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>start gsm -gsm sharddirector1
GDSCTL>add credential -credential oracle_cred -osaccount oracle -ospassword ****
GDSCTL> exit
Step 7: Start the Scheduler Agent on Shard NodesOn 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 –resiterdatabase shardcat 8080 provide name of host not database
Step 8 : Create Shard Group/Director/Add Shards
GDSCTL>set gsm -gsm sharddirector1 GDSCTL>connect mygdsadmin/oracleCatalog connection is establishedGDSCTL>-- add shard groupGDSCTL>add shardgroup -shardgroup primary_shardgroup -deploy_as primary -region region1The operation completed successfullyGDSCTL>-- add shard1GDSCTL>add invitednode shard1GDSCTL>create shard -shardgroup primary_shardgroup -destination shard1 -credential oracle_credDB Unique Name: sh1GDSCTL> --add shard2GDSCTL>add invitednode shard2GDSCTL>create shard -shardgroup primary_shardgroup -destination shard2 -credential oracle_credDB Unique Name: sh2
Step 8 : Deploy Shards• In shardcat node, using
gsdctl, run
gsdctl> deploy
Note: This will create the databases in shard1 and shard2 using dbca and create listeners automatically
Step 10: Verify Shard Status
Step 11 : Create Global Service using GSDCTL
Using GDSCTL on shardcatgdsctl> add service –service test_srv –role primargdsctl> config servicegdsctl> start servicegdsctl> status service
Step 12: Create sample schema and Tablespace set and see that propagate to shard1/shard2
#[oracle12c@sdb1 ~]$ db_envSqlplus / as sysdbaalter session enable shard ddl;create user app_schema identified by oracle;grant all privileges to app_schema;grant gsmadmin_role to app_schema;grant select_catalog_role to app_schema;grant connect, resource to app_schema;grant dba to app_schema;grant execute on dbms_crypto to app_schema;
#Create Sharded Tablespace & Test outconn app_schema/oraclealter session enable shard ddl;CREATE TABLESPACE SET TSP_SET_1 using template (datafile size 100m extent management local segment space management auto );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• On Shard Catalog SDB Database
Step 14: Verify Distribution of Tables to Shards
On Shard1, SH1 database the customer table is partitioned and some of the partitions created here
On Shard2, SH2 database the customer table is partitioned and some of the partitions created here
Thanks• In Next Post/Presentation we will be seeing
• Managing Shards• Adding / Deleting Shards• Verify Data Distribution• Shard Restrictions