真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Oracle12CSharding部署和測(cè)試

Oracle 12C Sharding 部署和測(cè)試  

成都創(chuàng)新互聯(lián)長(zhǎng)期為數(shù)千家客戶(hù)提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為梅河口企業(yè)提供專(zhuān)業(yè)的成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站,梅河口網(wǎng)站改版等技術(shù)服務(wù)。擁有十余年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。

日期: 2019-02-26  

作者:陳舉超

目錄

一:環(huán)境說(shuō)明 ... 4

二:安裝GSM/Shard catalog/ORACLE 12.2  RDBMS . 5

2.1 Gsm 安裝 ... 5

2.2 ORACLE 12.2 RDBMS 安裝 ... 8

2.3 創(chuàng)建并啟動(dòng)監(jiān)聽(tīng) ... 8

2.4 創(chuàng)建Shard Catalog database . 8

三:配置GSM/Shard director . 8

3.1  解鎖用戶(hù) ... 8

3.2 創(chuàng)建管理用戶(hù)mygds . 8

3.3  啟動(dòng)listener . 8

3.4 創(chuàng)建shard catalog 配置remote  scheduler agent . 8

3.5  創(chuàng)建和啟動(dòng)shard  director. 9

3.6  添加操作系統(tǒng)認(rèn)證. 9

3.7 在所有的shard 節(jié)點(diǎn)分別執(zhí)行Agent . 10

3.8 創(chuàng)建shard 數(shù)據(jù)庫(kù)的數(shù)據(jù)文件存儲(chǔ)路徑 ... 11

四:創(chuàng)建System-Managed SDB . 11

4.1 連接gsm .. 11

4.2 添加shardgroup . 11

4. 3 創(chuàng)建shard . 11

4.4  檢查配置 ... 12

4.5  部署/deploy . 13

4.6  檢查配置信息 ... 14

4.7  創(chuàng)建service . 16

五:創(chuàng)建用戶(hù)和對(duì)象 ... 16

5.1  在catalog 數(shù)據(jù)庫(kù)中創(chuàng)建業(yè)務(wù)用戶(hù) ... 16

5.2  創(chuàng)建表空間集合 ... 16

5.3 為duplicated tables 創(chuàng)建表空間 ... 17

5.4 創(chuàng)建 root 表 Customers . 17

5.5 創(chuàng)建其他 sharded table Orders. 18

5.6 為 OrderId 列創(chuàng)建序列 ... 18

5.7 創(chuàng)建 SHARDED TABLE LineItems . 18

5.8 創(chuàng)建 duplicated tables. 18

5.9 檢查是否有錯(cuò)誤 ... 19

六:驗(yàn)證環(huán)境- 表空間/chunks . 20

6.1   在db01 檢查chunks 信息 ... 20

6.2  在 sd1,sd2 節(jié)點(diǎn)檢查表空間和 chunks 信息 ... 20

6.3 在catalog 數(shù)據(jù)庫(kù)檢查chunks 信息 ... 23

6.4   驗(yàn)證環(huán)境 ... 23

七:訪問(wèn)Shard . 24

7.1 訪問(wèn)單獨(dú)一個(gè)shard . 24

7.2 訪問(wèn)多個(gè)shard . 26

八:shard 數(shù)據(jù)庫(kù)啟動(dòng)和停止 ... 27

8.1 關(guān)閉 ... 27

8.2 啟動(dòng)

九:常見(jiàn)問(wèn)題 ... 29

9.1  create shard –shardgroup 錯(cuò)誤 ... 29

9.2  catalog 創(chuàng)建用戶(hù)和表,不能同步到 shard db 庫(kù) ... 29

9.3 GSM 啟動(dòng)失敗,顯示異常

十:參考文獻(xiàn)

一:環(huán)境說(shuō)明

Oracle 12C Sharding部署和測(cè)試

OS :CentOS Linux release 7.5

DB :Oracle 12.2.0.1.0

GSMOCI :2.2.1

本次使用三臺(tái)虛擬機(jī)進(jìn)行安裝:

其中:

(1) db01 主機(jī)上安裝Shard Director 和Shard catalog ,也就是分別安裝GSM 、ORACLE 12.2 RDBMS 、non-cdb Database(GSM 和ORACLE 12.2 環(huán)境變量需要手動(dòng)切換) ;

(2)db02 主機(jī)上安裝Shard1 ,也就是ORACLE 12.2 RDBMS ,不需要?jiǎng)?chuàng)建數(shù)據(jù)庫(kù);

(3) db03 主機(jī)上安裝Shard2 ,也就是ORACLE 12.2 RDBMS ,不需要?jiǎng)?chuàng)建數(shù)據(jù)庫(kù);

主機(jī)

組件

SID

Oracle_Home

db01

Shard Director


/u01/app/oracle/product/12.2.0/gsm_1

db01

Shard catalog

db01

/u01/app/oracle/product/12.2.0/db_1

db02

Shard1

sh2

/u01/app/oracle/product/12.2.0/db_1

db03

Shard2

sh3

/u01/app/oracle/product/12.2.0/db_1

安裝文件下載鏈接如下:

https://www.oracle.com/technetwork/cn/database/options/partitioning/downloads/index.html

Oracle 軟件下載

Oracle 12C Sharding部署和測(cè)試

GSM 下載

Oracle 12C Sharding部署和測(cè)試

二:安裝GSM/Shard catalog/ORACLE 12.2 RDBMS

2.1 Gsm 安裝

Oracle 12C Sharding部署和測(cè)試

Oracle 12C Sharding部署和測(cè)試

Oracle 12C Sharding部署和測(cè)試

Oracle 12C Sharding部署和測(cè)試

Oracle 12C Sharding部署和測(cè)試

2.2 ORACLE 12.2 RDBMS 安裝

2.3 創(chuàng)建并啟動(dòng)監(jiān)聽(tīng)

Netca

2.4 創(chuàng)建Shard Catalog database

在Shard catalog   服務(wù)器gsm1   創(chuàng)建 non-cdb 數(shù)據(jù)庫(kù)。創(chuàng)建過(guò)程與普通數(shù)據(jù)庫(kù)相同。

三:配置GSM/Shard director

https://blogs.oracle.com/database4cn/12c-oracle-sharding

3.1  解鎖用戶(hù)

在db01 服務(wù)器(catalog 數(shù)據(jù)庫(kù)/shard director) ,連接到Sharding catalog 數(shù)據(jù)庫(kù), 解鎖 GSMCATUSER 用戶(hù),shard director 通過(guò)GSMCATUSER 用戶(hù)連接到shard catalog database

SQL> alter user gsmcatuser identified by oracle account unlock;

3.2 創(chuàng)建管理用戶(hù)mygds

在 catalog 數(shù)據(jù)庫(kù),創(chuàng)建管理用戶(hù)mygds ,用戶(hù)mygds 用于存儲(chǔ)Sharding 管理信息,GDSCTL 接口通過(guò)用戶(hù)mygds 連接到catalog 數(shù)據(jù)庫(kù)。

SQL> create user mygds identified by oracle;

SQL> grant connect, create session, gsmadmin_role to mygds;

SQL> grant inherit privileges on user SYS to GSMADMIN_INTERNAL;

3.3  啟動(dòng)listener

在db01 服務(wù)器(catalog 數(shù)據(jù)庫(kù)/shard director) ,啟動(dòng)listener

3.4 創(chuàng)建shard catalog 配置remote scheduler agent

在db01 服務(wù)器(catalog 數(shù)據(jù)庫(kù)/shard director) ,創(chuàng)建shard catalog ,在shard catalog 中配置remote scheduler agent.

參數(shù)含義:

-user : 指定管理用戶(hù),在前面步驟中創(chuàng)建的catalog database 管理用戶(hù)mygds

-database : 指定catalog database 信息,catalog 數(shù)據(jù)庫(kù)的主機(jī)名: 監(jiān)聽(tīng)器port: catalog 數(shù)據(jù)庫(kù)db_name

-sdb : 指定sharded database name

-agent_port: 設(shè)置端口,用于shard 節(jié)點(diǎn)agent 連接到GSM

-agent_password: 設(shè)置密碼,用于shard 節(jié)點(diǎn)agent 連接到GSM

如果沒(méi)有指定- sharding 參數(shù),默認(rèn)是創(chuàng)建system-managed (default) 類(lèi)型

[oracle@db01 ~]$ export ORACLE_BASE=/u01/app/oracle

[oracle@db01 ~]$ export ORACLE_HOME=/u01/app/oracle/products/12.2.0/gsm_1

[oracle@db01 ~]$

export PATH=/u01/app/oracle/products/12.2.0/gsmh_11/bin:$PATH:$HOME/bin

[oracle@db01 ~]$ gdsctl

GDSCTL: Version 12.2.0.1.0 - Production on Mon Feb 25 10:38:54 CST 2019

Copyright (c) 2011, 2016, Oracle.  All rights reserved.

Welcome to GDSCTL, type "help" for information.

Warning: current GSM name is not set automatically because gsm.ora contains zero or several GSM entries. Use "set  gsm" command to set GSM for the session.

Current GSM is set to GSMORA

GDSCTL> create shardcatalog -database db01:1521:db01 -chunks 12 -user mygds/oracle -sdb shdb -region region1, region2 -agent_port 8080 -agent_password oracle

Catalog is created

3.5  創(chuàng)建和啟動(dòng)shard director

參數(shù)含義:

-gsm: 指定shard director 名稱(chēng)

-listener: 指定shard director 的監(jiān)聽(tīng)端口,注意不能與數(shù)據(jù)庫(kù)的listener 端口沖突

-catalog: 指定catalog database 信息,catalog 數(shù)據(jù)庫(kù)的主機(jī)名: 監(jiān)聽(tīng)器port: catalog 數(shù)據(jù)庫(kù)db_name

GDSCTL> add gsm -gsm sharddirector1 -listener 1522 -pwd oracle -catalog db01:1521:db01 -region region1

GSM successfully added

GDSCTL> start gsm -gsm sharddirector1

GSM 已成功啟動(dòng)

3.6  添加操作系統(tǒng)認(rèn)證

GDSCTL> add credential -credential cre_reg1 -osaccount oracle -ospassword oracle

操作已成功完成

3.7 在所有的shard 節(jié)點(diǎn)分別執(zhí)行Agent

--- 在db02 節(jié)點(diǎn)執(zhí)行

[oracle@db02 ~]$ schagent -start

Scheduler agent started using port 24409

[oracle@db02 ~]$ schagent -status

Agent running with PID 8537

Agent_version:12.2.0.1.2

Running_time:00:00:11

Total_jobs_run:0

Running_jobs:0

Platform:Linux

ORACLE_HOME:/u01/app/oracle/product/12.2.0/db_1

ORACLE_BASE:/u01/app/oracle

Port:24409

Host:db02

--- 在db03 節(jié)點(diǎn)執(zhí)行

[oracle@db03 ~]$ schagent -start

Scheduler agent started using port 19249

[oracle@db03 ~]$ schagent -status

Agent running with PID 8344

Agent_version:12.2.0.1.2

Running_time:00:00:05

Total_jobs_run:0

Running_jobs:0

Platform:Linux

ORACLE_HOME:/u01/app/oracle/product/12.2.0/db_1

ORACLE_BASE:/u01/app/oracle

Port:19249

Host:db03

----- 密碼oracle 和端口8080

[oracle@db02 ~]$ echo oracle | schagent -registerdatabase 192.168.2.226 8080

Agent Registration Password ? 

Oracle Scheduler Agent Registration for 12.2.0.1.2 Agent

Agent Registration Successful!

[oracle@db03 ~]$ echo oracle | schagent -registerdatabase 192.168.2.226 8080

Agent Registration Password ? 

Oracle Scheduler Agent Registration for 12.2.0.1.2 Agent

Agent Registration Successful!

3.8 創(chuàng)建shard 數(shù)據(jù)庫(kù)的數(shù)據(jù)文件存儲(chǔ)路徑

[oracle@db02 ~]$ mkdir /u01/app/oracle/oradata

[oracle@db02 ~]$ mkdir /u01/app/oracle/fast_recovery_area

[oracle@db03 ~]$ mkdir /u01/app/oracle/oradata

[oracle@db03 ~]$ mkdir /u01/app/oracle/fast_recovery_area

四:創(chuàng)建System-Managed SDB

4.1 連接gsm

在Shard 服務(wù)器 sd1 連接到shard director/GSM 服務(wù)器(db01)

[oracle@db02 ~]$ ssh oracle@db01

……

oracle@db01's password:

Last login: Mon Feb 25 10:45:20 2019 from 192.168.70.249

[oracle@db01 ~]$ source .bash_profile

[oracle@db01 ~]$ gdsctl

GDSCTL: 版本 12.2.0.1.0 - Production, 時(shí)間: Mon Feb 25 11:16:04 CST 2019

版權(quán)所有 (c) 2011, 2016, Oracle 。保留所有權(quán)利。

歡迎使用GDSCTL, 請(qǐng)鍵入 "help" 以獲得信息。

當(dāng)前 GSM 設(shè)置為 SHARDDIRECTOR1

GDSCTL> set gsm -gsm sharddirector1

GDSCTL>connect mygds/oracle

已建立目錄連接

4.2 添加shardgroup

shardgroup 是一組shard 的集合,shardgroup 名稱(chēng)為primary_shardgroup ,-deploy_as primary 表示這個(gè)group 中的shard 都是主庫(kù)。

GDSCTL> add shardgroup -shardgroup primary_shardgroup -deploy_as primary -region region1

操作已成功完成

4. 3 創(chuàng)建shard

將每個(gè)shard 地址添加到catalog 的valid node checking for registration (VNCR) 列表,并且創(chuàng)建shard

GDSCTL> add invitednode db02 

GDSCTL> create shard -shardgroup primary_shardgroup -destination db02 -credential cre_reg1 -sys_password oracle

操作已成功完成

數(shù)據(jù)庫(kù)的唯一名稱(chēng): sh2

GDSCTL> add invitednode db03

GDSCTL> create shard -shardgroup primary_shardgroup -destination db03 -credential cre_reg1 -sys_password oracle

操作已成功完成

數(shù)據(jù)庫(kù)的唯一名稱(chēng): sh3

4.4  檢查配置

GDSCTL>config

區(qū)域

------------------------

region1                      

region2                      

GSM

------------------------

sharddirector1               

sharddirector3               

分片數(shù)據(jù)庫(kù)

------------------------

shdb                         

數(shù)據(jù)庫(kù)

------------------------

sh2                          

sh3                          

分片組

------------------------

primary_shardgroup           

分片空間

------------------------

shardspaceora                

服務(wù)

------------------------

GDSCTL 暫掛請(qǐng)求

------------------------

命令                            對(duì)象                            狀態(tài)                           

--                            --                            --                           

全局屬性

------------------------

名稱(chēng): oradbcloud

主 GSM: sharddirector1

DDL 序列號(hào): 0

GDSCTL> config shardspace

分片空間                          塊                            

----                          -                            

shardspaceora                 12  

GDSCTL> config shardgroup

分片組                 塊      區(qū)域                  分片空間               

---                 -      --                  ----                

primary_shardgroup  12     region1             shardspaceora 

GDSCTL> config vncr

名稱(chēng)                            組 ID                         

--                            ----                         

192.168.2.226                                               

db02                                                       

db03                              

GDSCTL> config shard

名稱(chēng)                   分片組                  狀態(tài)         狀態(tài)           區(qū)域         可用性       

--                  ---                 --        --          --        ---      

sh2                 primary_shardgroup  U         無(wú)            region1   -        

sh3                 primary_shardgroup  U         無(wú)            region1   -        

4.5  部署/deploy

執(zhí)行deploy 后,自動(dòng)在db02 和db03 服務(wù)器上采用靜默安裝方式部署shard 數(shù)據(jù)庫(kù),速度較慢;

GDSCTL> deploy

deploy: examining configuration...

deploy: deploying primary shard 'sh2' ...

deploy: network listener configuration successful at destination 'db02'

deploy: starting DBCA at destination 'db02' to create primary shard 'sh2' ...

deploy: deploying primary shard 'sh3' ...

deploy: network listener configuration successful at destination 'db03'

deploy: starting DBCA at destination 'db03' to create primary shard 'sh3' ...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: waiting for 2 DBCA primary creation job(s) to complete...

deploy: DBCA primary creation job succeeded at destination 'db02' for shard 'sh2'

deploy: waiting for 1 DBCA primary creation job(s) to complete...

deploy: waiting for 1 DBCA primary creation job(s) to complete...

deploy: DBCA primary creation job succeeded at destination 'db03' for shard 'sh3'

deploy: requesting Data Guard configuration on shards via GSM

deploy: shards configured successfully

操作已成功完成

4.6  檢查配置信息

GDSCTL> config shard

名稱(chēng)                   分片組                  狀態(tài)         狀態(tài)           區(qū)域         可用性       

--                  ---                 --        --          --        ---      

sh2                 primary_shardgroup  確定         已部署          region1   ONLINE   

sh3                 primary_shardgroup  確定         已部署          region1   ONLINE   

GDSCTL> databases

數(shù)據(jù)庫(kù): "sh2" 注冊(cè)時(shí)間: Y 狀態(tài): 確定 ONS: N 。角色: PRIMARY 實(shí)例: 1 區(qū)域: region1

   已注冊(cè)的實(shí)例:

     shdb%1

數(shù)據(jù)庫(kù): "sh3" 注冊(cè)時(shí)間: Y 狀態(tài): 確定 ONS: N 。角色: PRIMARY 實(shí)例: 1 區(qū)域: region1

   已注冊(cè)的實(shí)例:

     shdb%11

GDSCTL> config shard -shard sh2

名稱(chēng): sh2

分片組: primary_shardgroup

狀態(tài): 確定

狀態(tài): 已部署

區(qū)域: region1

連接字符串: db02:1521/sh2:dedicated

SCAN 地址:

ONS 遠(yuǎn)程端口: 0

磁盤(pán)閾值, 毫秒: 20

CPU 閾值, %: 75

版本: 12.2.0.0

上次失敗的 DDL:

DDL 錯(cuò)誤: ---

失敗的 DDL ID:

可用性: ONLINE

Rack:

支持的服務(wù)

------------------------

名稱(chēng)                                                              首選        狀態(tài)       

--                                                              --        --       

GDSCTL> config shard -shard sh3  

名稱(chēng): sh3

分片組: primary_shardgroup

狀態(tài): 確定

狀態(tài): 已部署

區(qū)域: region1

連接字符串: db03:1521/sh3:dedicated

SCAN 地址:

ONS 遠(yuǎn)程端口: 0

磁盤(pán)閾值, 毫秒: 20

CPU 閾值, %: 75

版本: 12.2.0.0

上次失敗的 DDL:

DDL 錯(cuò)誤: ---

失敗的 DDL ID:

可用性: ONLINE

Rack:

支持的服務(wù)

------------------------

名稱(chēng)                                                              首選        狀態(tài)       

--                                                              --        --    

4.7  創(chuàng)建service

GDSCTL> add service -service oltp_rw_srvc -role primary

操作已成功完成

GDSCTL> start service -service oltp_rw_srvc

操作已成功完成

GDSCTL> status service

服務(wù) "oltp_rw_srvc.shdb.oradbcloud" 具有 2 個(gè)實(shí)例。關(guān)系: ANYWHERE

   實(shí)例 "shdb%1", 名稱(chēng): "sh2", 數(shù)據(jù)庫(kù): "sh2", 區(qū)域: "region1", 狀態(tài): ready 。

   實(shí)例 "shdb%11", 名稱(chēng): "sh3", 數(shù)據(jù)庫(kù): "sh3", 區(qū)域: "region1", 狀態(tài): ready 。

五:創(chuàng)建用戶(hù)和對(duì)象

5.1  在catalog 數(shù)據(jù)庫(kù)中創(chuàng)建業(yè)務(wù)用戶(hù)

---db01

SQL> alter session enable shard ddl;

SQL> create user app_schema identified by oracle;

SQL> grant all privileges to app_schema;

SQL> grant gsmadmin_role to app_schema;

SQL> grant select_catalog_role to app_schema;

SQL> grant connect, resource to app_schema;

SQL> grant dba to app_schema;

SQL> grant execute on dbms_crypto to app_schema;

5.2  創(chuàng)建表空間集合

---db01

SQL> conn app_schema

Enter password:

Connected.

SQL> alter session enable shard ddl;

Session altered.

SQL> create tablespace set tsp_set_1 using template (datafile size 100m autoextend on next 10m maxsize unlimited extent management local segment space management auto);

Tablespace created.

GDSCTL> set gsm -gsm sharddirector1

GDSCTL> config shard

已建立目錄連接

名稱(chēng)                   分片組                  狀態(tài)         狀態(tài)           區(qū)域         可用性       

--                  ---                 --        --          --        ---      

sh2                 primary_shardgroup  確定         DDL 錯(cuò)誤       region1   ONLINE   

sh3                 primary_shardgroup  確定         DDL 錯(cuò)誤       region1   ONLINE   

5.3 為duplicated tables 創(chuàng)建表空間

--- 這個(gè)測(cè)試中duplicated table 是Products table.

SQL> CREATE TABLESPACE products_tsp datafile '/u01/app/oracle/oradata/db01/products_tsp01.dbf' size 100m autoextend on next 10M maxsize unlimited extent management local uniform size 1m;

Tablespace created.

5.4 創(chuàng)建 root 表 Customers

SQL > CONNECT app_schema / oracle

SQL > ALTER SESSION ENABLE SHARD DDL ;

SQL > CREATE SHARDED TABLE Customers

  (

    CustId      VARCHAR2 ( 60 ) NOT NULL ,

    FirstName   VARCHAR2 ( 60 ),

    LastName    VARCHAR2 ( 60 ),

    Class        VARCHAR2 ( 10 ),

    Geo         VARCHAR2 ( 8 ),

    CustProfile VARCHAR2 ( 4000 ),

    Passwd      RAW ( 60 ),

    CONSTRAINT pk_customers PRIMARY KEY ( CustId ),

    CONSTRAINT json_customers CHECK ( CustProfile IS JSON )

  ) TABLESPACE SET TSP_SET_1

PARTITION BY CONSISTENT HASH ( CustId ) PARTITIONS AUTO ;

5 .5 創(chuàng)建其他 sharded table Orders.

SQL > CREATE SHARDED TABLE Orders

  (

    OrderId     INTEGER NOT NULL ,

    CustId      VARCHAR2 ( 60 ) NOT NULL ,

    OrderDate   TIMESTAMP NOT NULL ,

    SumTotal    NUMBER ( 19 , 4 ),

    Status      CHAR ( 4 ),

    CONSTRAINT   pk_orders PRIMARY KEY ( CustId , OrderId ),

    CONSTRAINT   fk_orders_parent FOREIGN KEY ( CustId )

    REFERENCES Customers ON DELETE CASCADE

  ) PARTITION BY REFERENCE ( fk_orders_parent );  

5.6 為 OrderId 列創(chuàng)建序列

SQL > CREATE SEQUENCE Orders_Seq ;  

Sequence created.

5.7 創(chuàng)建 SHARDED TABLE LineItems

SQL > CREATE SHARDED TABLE LineItems

  (

    OrderId     INTEGER NOT NULL ,

    CustId      VARCHAR2 ( 60 ) NOT NULL ,

    ProductId   INTEGER NOT NULL ,

    Price       NUMBER ( 19 , 4 ),

    Qty         NUMBER ,

    CONSTRAINT   pk_items PRIMARY KEY ( CustId , OrderId , ProductId ),

    CONSTRAINT   fk_items_parent FOREIGN KEY ( CustId , OrderId )

    REFERENCES Orders ON DELETE CASCADE

  ) PARTITION BY REFERENCE ( fk_items_parent );

5.8 創(chuàng)建 duplicated tables.

---In this example , the Products table is a duplicated object.

SQL > CREATE DUPLICATED TABLE Products

  (

    ProductId  INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ,

    Name        VARCHAR2 ( 128 ),

    DescrUri   VARCHAR2 ( 128 ),

    LastPrice  NUMBER ( 19 , 4 )

  ) TABLESPACE products_tsp ;  

5.9 檢查是否有錯(cuò)誤

GDSCTL> set gsm -gsm sharddirector1

GDSCTL> show ddl

ID      DDL 文本                                   失敗的分片    

--      ------                                   -----    

108     grant dba to app_schema                           

109     grant execute on dbms_crypto to app_s...          

110     CREATE TABLESPACE SET TSP_SET_1 using...          

111      CREATE TABLESPACE products_tsp dataf...          

112      CREATE SHARDED TABLE Customers   (  ...          

113     CREATE SHARDED TABLE Orders   (     O...          

114     CREATE SHARDED TABLE LineItems   (   ...          

115     CREATE MATERIALIZED VIEW "APP_SCHEMA"...          

116     CREATE OR REPLACE FUNCTION PasswCreat...          

117     CREATE OR REPLACE FUNCTION PasswCheck...         

GDSCTL> config shard -shard sh2

名稱(chēng): sh2

分片組: primary_shardgroup

狀態(tài): 確定

狀態(tài): 已部署

區(qū)域: region1

連接字符串: db02:1521/sh2:dedicated

SCAN 地址:

ONS 遠(yuǎn)程端口: 0

磁盤(pán)閾值, 毫秒: 20

CPU 閾值, %: 75

版本: 12.2.0.0

上次失敗的 DDL: CREATE MATERIALIZED VIEW "APP_...

DDL 錯(cuò)誤: ORA-00942: table or view does not exist

ORA-06512: at "SYS.EXECASUSER", line 44

ORA-06512: at "SYS.DBMS_SYS_SQL", line 1529

ORA-06512: at "SYS.EXECASUSER", line 31

ORA-06512: at "GSMADMIN_INTERNAL.EXECUTEDDL", line 70

ORA-06512: at line 1 \(ngsmoci_execute\)

失敗的 DDL ID: 57

可用性: ONLINE

Rack:

支持的服務(wù)

------------------------

名稱(chēng)                                                              首選        狀態(tài)       

--                                                              --        --       

oltp_rw_srvc                                                    是         啟用       

六:驗(yàn)證環(huán)境-表空間/chunks

6.1   在db01 檢查chunks 信息

前面創(chuàng)建shardcatalog時(shí)指定chunks為12,因此后續(xù)創(chuàng)建shard table分配12個(gè)chunks

GDSCTL>config chunks

------------------------

數(shù)據(jù)庫(kù)                           自         至        

---                           -         -        

sh2                           1         6        

sh3                           7         12   

6.2  在 sd1,sd2 節(jié)點(diǎn)檢查表空間和 chunks 信息

---db02

--表空間

SQL> select TABLESPACE_NAME, BYTES/1024/1024 MB from sys.dba_data_files order by tablespace_name;

TABLESPACE_NAME               MB

------------------------------ ----------

C001TSP_SET_1                100

C002TSP_SET_1                100

C003TSP_SET_1                100

C004TSP_SET_1                100

C005TSP_SET_1                100

C006TSP_SET_1                100

PRODUCTS_TSP                 100

SYSAUX                       480

SYSTEM                       810

TSP_SET_1                100

UNDOTBS1                  70

TABLESPACE_NAME               MB

------------------------------ ----------

USERS                       5

12 rows selected.

創(chuàng)建了6個(gè)表空間,分別是C001TSP_SET_1 ~ 表空間C006TSP_SET_1,因?yàn)樵O(shè)置chunks=12,每個(gè)shard有6個(gè)chunks。

每個(gè)表空間有一個(gè)datafile,大小是100M,這個(gè)是在創(chuàng)建tablespace set時(shí)設(shè)置的datafile 100M。

--檢查chunks

SQL> set linesize 140

SQL> column table_name format a20

SQL> column tablespace_name format a20

SQL> column partition_name format a20

SQL> show parameter db_unique_name

NAME                    TYPE  VALUE

------------------------------------ ----------- ------------------------------

db_unique_name                   string    sh2

SQL> select table_name, partition_name, tablespace_name from dba_tab_partitions

where tablespace_name like 'C%TSP_SET_1' order by tablespace_name;  2 

TABLE_NAME         PARTITION_NAME      TABLESPACE_NAME

-------------------- -------------------- --------------------

LINEITEMS      CUSTOMERS_P1    C001TSP_SET_1

CUSTOMERS      CUSTOMERS_P1    C001TSP_SET_1

ORDERS             CUSTOMERS_P1    C001TSP_SET_1

CUSTOMERS      CUSTOMERS_P2    C002TSP_SET_1

ORDERS             CUSTOMERS_P2    C002TSP_SET_1

LINEITEMS      CUSTOMERS_P2    C002TSP_SET_1

CUSTOMERS      CUSTOMERS_P3    C003TSP_SET_1

LINEITEMS      CUSTOMERS_P3    C003TSP_SET_1

ORDERS             CUSTOMERS_P3    C003TSP_SET_1

LINEITEMS      CUSTOMERS_P4    C004TSP_SET_1

CUSTOMERS      CUSTOMERS_P4    C004TSP_SET_1

ORDERS             CUSTOMERS_P4    C004TSP_SET_1

CUSTOMERS      CUSTOMERS_P5    C005TSP_SET_1

ORDERS             CUSTOMERS_P5    C005TSP_SET_1

LINEITEMS      CUSTOMERS_P5    C005TSP_SET_1

CUSTOMERS      CUSTOMERS_P6    C006TSP_SET_1

ORDERS             CUSTOMERS_P6    C006TSP_SET_1

LINEITEMS      CUSTOMERS_P6    C006TSP_SET_1

18 rows selected.

在sd2節(jié)點(diǎn)檢查表空間和chunks信息

--表空間

SQL> select TABLESPACE_NAME, BYTES/1024/1024 MB from sys.dba_data_files order by tablespace_name;

TABLESPACE_NAME               MB

------------------------------ ----------

C007TSP_SET_1                100

C008TSP_SET_1                100

C009TSP_SET_1                100

C00ATSP_SET_1                100

C00BTSP_SET_1                100

C00CTSP_SET_1                100

PRODUCTS_TSP                 100

SYSAUX                       480

SYSTEM                       810

TSP_SET_1                100

UNDOTBS1                  65

USERS                       5

12 rows selected.

創(chuàng)建了6個(gè)表空間,分別是C007TSP_SET_1 ~ 表空間C00CTSP_SET_1,因?yàn)樵O(shè)置chunks=12,每個(gè)shard有6個(gè)chunks。

每個(gè)表空間有一個(gè)datafile,大小是100M,這個(gè)是在創(chuàng)建tablespace set時(shí)設(shè)置的datafile 100M。

--檢查chunks

SQL> set linesize 140

SQL> column table_name format a20

SQL> column tablespace_name format a20

SQL> column partition_name format a20

SQL> select table_name, partition_name, tablespace_name from dba_tab_partitions

where tablespace_name like 'C%TSP_SET_1' order by tablespace_name;

TABLE_NAME         PARTITION_NAME      TABLESPACE_NAME

-------------------- -------------------- --------------------

ORDERS             CUSTOMERS_P7    C007TSP_SET_1

LINEITEMS      CUSTOMERS_P7    C007TSP_SET_1

CUSTOMERS      CUSTOMERS_P7    C007TSP_SET_1

ORDERS             CUSTOMERS_P8    C008TSP_SET_1

CUSTOMERS      CUSTOMERS_P8    C008TSP_SET_1

LINEITEMS      CUSTOMERS_P8    C008TSP_SET_1

LINEITEMS      CUSTOMERS_P9    C009TSP_SET_1

ORDERS             CUSTOMERS_P9    C009TSP_SET_1

CUSTOMERS      CUSTOMERS_P9    C009TSP_SET_1

LINEITEMS      CUSTOMERS_P10   C00ATSP_SET_1

ORDERS             CUSTOMERS_P10   C00ATSP_SET_1

CUSTOMERS      CUSTOMERS_P10   C00ATSP_SET_1

ORDERS             CUSTOMERS_P11   C00BTSP_SET_1

LINEITEMS      CUSTOMERS_P11   C00BTSP_SET_1

CUSTOMERS      CUSTOMERS_P11   C00BTSP_SET_1

LINEITEMS      CUSTOMERS_P12   C00CTSP_SET_1

CUSTOMERS      CUSTOMERS_P12   C00CTSP_SET_1

ORDERS             CUSTOMERS_P12   C00CTSP_SET_1

18 rows selected.

6.3 在catalog 數(shù)據(jù)庫(kù)檢查chunks 信息

SQL>  set echo off

SQL> select a.name Shard, count( b.chunk_number) Number_of_Chunks from

gsmadmin_internal.database a, gsmadmin_internal.chunk_loc b where

a.database_num=b.database_num group by a.name; 

SHARD                     NUMBER_OF_CHUNKS

------------------------------ ----------------


網(wǎng)站欄目:Oracle12CSharding部署和測(cè)試
鏈接地址:http://weahome.cn/article/gjddpp.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部