- 連接新分片主機,在其上註冊遠程調度程序代理,並在其上為oradata和fast_recovery_area創建目錄
#sd05、sd06 上
#如下配置文件,不同机器 HOSTNAME、UNQNAME、SID 不同
[oracle@sc05 ~]$ cat /home/oracle/scripts/setEnv.sh
-----------------------------------------------------------------------------------
# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=sd05
export ORACLE_UNQNAME=sh21
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/19.3.0/db_1
export ORACLE_SID=sh5
export PATH=/usr/sbin:/usr/local/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
-----------------------------------------------------------------------------------
$ schagent -start
$ schagent -status
--密码oracle和端口8080是在第7步创建shardcatalog时设置的(oracle 是指 agent_password):
$ echo oracle | schagent -registerdatabase sc01 8080
$ mkdir /u01/app/oracle/oradata
$ mkdir /u01/app/oracle/fast_recovery_area
2.创建系统管理的SDB
[gds@gsm01 ~]$ gdsctl
GDSCTL> set gsm -gsm sharddirector1
GDSCTL> connect mysdbadmin/oracle
GDSCTL> config shard
Name Shard Group Status State Region Availability
---- ----------- ------ ----- ------ ------------
sh1 primary_shgrp Ok Deployed region1 ONLINE
sh2 standby_shgrp Ok Deployed region2 READ ONLY
sh3 primary_shgrp Ok Deployed region1 ONLINE
sh4 standby_shgrp Ok Deployed region2 READ ONLY
#将每个分片的主机地址添加到有效节点,以检查目录中的注册(VNCR)列表,然后在主或备用分片组中创建分片
4. 将每个shard 地址添加到catalog 的 (VNCR) 列表,并且创建shard
GDSCTL> add invitednode sd05
GDSCTL> create shard -shardgroup primary_shgrp -destination sd05 -credential cre_reg1 -sys_password 123456
The operation completed successfully
DB Unique Name: sh21
GDSCTL>
GDSCTL> add invitednode sd06
GDSCTL> create shard -shardgroup standby_shgrp -destination sd06 -credential cre_reg1 -sys_password 123456
The operation completed successfully
DB Unique Name: sh22
GDSCTL> config shard
Name Shard Group Status State Region Availability
---- ----------- ------ ----- ------ ------------
sh1 primary_shgrp Ok Deployed region1 ONLINE
sh2 standby_shgrp Ok Deployed region2 READ ONLY
sh21 primary_shgrp U none region1 -
sh22 standby_shgrp U none region2 -
sh3 primary_shgrp Ok Deployed region1 ONLINE
sh4 standby_shgrp Ok Deployed region2 READ ONLY
GDSCTL> config chunks
Chunks
------------------------
Database From To
-------- ---- --
sh1 1 6
sh2 1 6
sh3 7 12
sh4 7 12
GDSCTL> config vncr
Name Group ID
---- --------
10.0.99.103
10.0.99.105
10.0.99.106
10.0.99.107
10.0.99.108
sd01
sd02
sd03
sd04
sd05
sd06
#运行DEPLOY命令以创建分片和副本。
#该DEPLOY命令需要一些时间才能运行,大约需要15到30分钟
GDSCTL> deploy
deploy: examining configuration...
deploy: deploying primary shard 'sh21' ...
deploy: network listener configuration successful at destination 'sd05'
deploy: starting DBCA at destination 'sd05' to create primary shard 'sh21' ...
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 'sd05' for shard 'sh21'
deploy: deploying standby shard 'sh22' ...
deploy: network listener configuration successful at destination 'sd06'
deploy: starting DBCA at destination 'sd06' to create standby shard 'sh22' ...
deploy: waiting for 1 DBCA standby creation job(s) to complete...
...
deploy: waiting for 1 DBCA standby creation job(s) to complete...
deploy: DBCA standby creation job succeeded at destination 'sd06' for shard 'sh22'
deploy: requesting Data Guard configuration on shards via GSM
deploy: shards configured; background operations in progress
The operation completed successfully
3.檢查
[gds@gsm01 ~]$ gdsctl config shard
Name Shard Group Status State Region Availability
---- ----------- ------ ----- ------ ------------
sh1 primary_shgrp Ok Deployed region1 ONLINE
sh2 standby_shgrp Ok Deployed region2 READ ONLY
sh21 primary_shgrp Ok Deployed region1 ONLINE
sh22 standby_shgrp Ok Deployed region2 READ ONLY
sh3 primary_shgrp Ok Deployed region1 ONLINE
sh4 standby_shgrp Ok Deployed region2 READ ONLY
[gds@gsm01 ~]$ gdsctl config chunks -show_Reshard
Chunks
------------------------
Database From To
-------- ---- --
sh1 1 4
sh2 1 4
sh21 5 6
sh22 5 6
sh3 7 12
sh4 7 12
Ongoing chunk movement
------------------------
Chunk Source Target status
----- ------ ------ ------
5 sh1 sh21 Moved
11 sh3 sh21 scheduled
12 sh3 sh21 scheduled
[gds@gsm01 ~]$ gdsctl databases
Database: "sh1" Registered: Y State: Ok ONS: N. Role: PRIMARY Instances: 1 Region: region1
Service: "oltp_ro_srvc" Globally started: Y Started: N
Scan: N Enabled: Y Preferred: Y
Service: "oltp_rw_srvc" Globally started: Y Started: Y
Scan: N Enabled: Y Preferred: Y
Registered instances:
cust_sdb%1
Database: "sh2" Registered: Y State: Ok ONS: N. Role: PH_STNDBY Instances: 1 Region: region2
Service: "oltp_ro_srvc" Globally started: Y Started: Y
Scan: N Enabled: Y Preferred: Y
Service: "oltp_rw_srvc" Globally started: Y Started: N
Scan: N Enabled: Y Preferred: Y
Registered instances:
cust_sdb%11
Database: "sh21" Registered: Y State: Ok ONS: N. Role: PRIMARY Instances: 1 Region: region1
Service: "oltp_ro_srvc" Globally started: Y Started: N
Scan: N Enabled: Y Preferred: Y
Service: "oltp_rw_srvc" Globally started: Y Started: Y
Scan: N Enabled: Y Preferred: Y
Registered instances:
cust_sdb%41
Database: "sh22" Registered: Y State: Ok ONS: N. Role: PH_STNDBY Instances: 1 Region: region2
Service: "oltp_ro_srvc" Globally started: Y Started: Y
Scan: N Enabled: Y Preferred: Y
Service: "oltp_rw_srvc" Globally started: Y Started: N
Scan: N Enabled: Y Preferred: Y
Registered instances:
cust_sdb%51
Database: "sh3" Registered: Y State: Ok ONS: N. Role: PRIMARY Instances: 1 Region: region1
Service: "oltp_ro_srvc" Globally started: Y Started: N
Scan: N Enabled: Y Preferred: Y
Service: "oltp_rw_srvc" Globally started: Y Started: Y
Scan: N Enabled: Y Preferred: Y
Registered instances:
cust_sdb%21
Database: "sh4" Registered: Y State: Ok ONS: N. Role: PH_STNDBY Instances: 1 Region: region2
Service: "oltp_ro_srvc" Globally started: Y Started: Y
Scan: N Enabled: Y Preferred: Y
Service: "oltp_rw_srvc" Globally started: Y Started: N
Scan: N Enabled: Y Preferred: Y
Registered instances:
cust_sdb%31
[gds@gsm01 ~]$ gdsctl services
Service "oltp_ro_srvc.cust_sdb.oradbcloud" has 3 instance(s). Affinity: ANYWHERE
Instance "cust_sdb%11", name: "sh2", db: "sh2", region: "region2", status: ready.
Instance "cust_sdb%31", name: "sh4", db: "sh4", region: "region2", status: ready.
Instance "cust_sdb%51", name: "sh22", db: "sh22", region: "region2", status: ready.
Service "oltp_rw_srvc.cust_sdb.oradbcloud" has 3 instance(s). Affinity: ANYWHERE
Instance "cust_sdb%1", name: "sh1", db: "sh1", region: "region1", status: ready.
Instance "cust_sdb%21", name: "sh3", db: "sh3", region: "region1", status: ready.
Instance "cust_sdb%41", name: "sh21", db: "sh21", region: "region1", status: ready.
[oracle@sc01 ~]$ sql app_schema/123456
SQL> SELECT table_name, partition_name, num_rows,ORA_SHARD_ID FROM SHARDS(dba_tab_partitions) p where p.table_name ='TEST_RANGE_TAB' order by 4,2;
TABLE_NAME PARTITION_NAME NUM_ROWS ORA_SHARD_ID
TEST_RANGE_TAB TEST_RANGE_TAB_P1 6 1
TEST_RANGE_TAB TEST_RANGE_TAB_P10 0 1
TEST_RANGE_TAB TEST_RANGE_TAB_P11 0 1
TEST_RANGE_TAB TEST_RANGE_TAB_P12 0 1
TEST_RANGE_TAB TEST_RANGE_TAB_P2 9 1
TEST_RANGE_TAB TEST_RANGE_TAB_P3 12 1
TEST_RANGE_TAB TEST_RANGE_TAB_P4 9 1
TEST_RANGE_TAB TEST_RANGE_TAB_P5 0 1
TEST_RANGE_TAB TEST_RANGE_TAB_P6 0 1
TEST_RANGE_TAB TEST_RANGE_TAB_P7 0 1
TEST_RANGE_TAB TEST_RANGE_TAB_P8 0 1
TEST_RANGE_TAB TEST_RANGE_TAB_P9 0 1
TEST_RANGE_TAB TEST_RANGE_TAB_P1 0 21
TEST_RANGE_TAB TEST_RANGE_TAB_P10 7 21
TABLE_NAME PARTITION_NAME NUM_ROWS ORA_SHARD_ID
TEST_RANGE_TAB TEST_RANGE_TAB_P11 0 21
TEST_RANGE_TAB TEST_RANGE_TAB_P12 0 21
TEST_RANGE_TAB TEST_RANGE_TAB_P2 0 21
TEST_RANGE_TAB TEST_RANGE_TAB_P3 0 21
TEST_RANGE_TAB TEST_RANGE_TAB_P4 0 21
TEST_RANGE_TAB TEST_RANGE_TAB_P5 0 21
TEST_RANGE_TAB TEST_RANGE_TAB_P6 0 21
TEST_RANGE_TAB TEST_RANGE_TAB_P7 7 21
TEST_RANGE_TAB TEST_RANGE_TAB_P8 9 21
TEST_RANGE_TAB TEST_RANGE_TAB_P9 7 21
TEST_RANGE_TAB TEST_RANGE_TAB_P1 0 41
TEST_RANGE_TAB TEST_RANGE_TAB_P10 0 41
TEST_RANGE_TAB TEST_RANGE_TAB_P11 11 41
TEST_RANGE_TAB TEST_RANGE_TAB_P12 11 41
TABLE_NAME PARTITION_NAME NUM_ROWS ORA_SHARD_ID
TEST_RANGE_TAB TEST_RANGE_TAB_P2 0 41
TEST_RANGE_TAB TEST_RANGE_TAB_P3 0 41
TEST_RANGE_TAB TEST_RANGE_TAB_P4 0 41
TEST_RANGE_TAB TEST_RANGE_TAB_P5 3 41
TEST_RANGE_TAB TEST_RANGE_TAB_P6 8 41
TEST_RANGE_TAB TEST_RANGE_TAB_P7 0 41
TEST_RANGE_TAB TEST_RANGE_TAB_P8 0 41
TEST_RANGE_TAB TEST_RANGE_TAB_P9 0 41
网友评论