Oracle 12c Sharding学习(二)-安装

这里我使用三台虚拟机来完成Sharding的安装。主要是Sharding-Catalog,Shard1和Shard2。

节点

IP地址

Home

Ports

DB Name

Schedule Agent

Shard Catalog

192.168.56.141

Oracle Home/u01/app/oracle/product/12.2.0.1/db_1
GSM HOME:/u01/app/oracle/product/12.2.0.1/gsm_1/

DB Listener:1521
GSM Listener:1522

SCAT

 

Shard1

192.168.56.142

Oracle Home/u01/app/oracle/product/12.2.0.1/db_1

DB Listener:1521

sh1

Schedule Agent-

Shard2

192.168.56.143

Oracle Home/u01/app/oracle/product/12.2.0.1/db_1

DB Listener:1521

sh2

Schedule Agent-

安装步骤如下:1.先在三台Linux主机上安装Oracle数据库软件,注意选择只安装软件(install database software only)

创建安装目录
[root@localhost ~]# mkdir -p /u01/app/oracle/product/12.2.0.1/db_1
[root@localhost ~]# chown -R oracle:oinstall /u01
[root@localhost ~]# chmod -R 775 /u01

安装Oracle Database软件,在安装的过程中选择install database software only,其余都和安装单机版数据库一致。

2.在sharding-catalog主机上安装GSM软件

安装过程如下面截图所示:

3.在sharding-catalog上创建数据库(Shard Catalog Database)

4.主机上的Oracle共享管理和路由层的建立

4.1 设置 catalog database 环境和启动监听

[oracle@sharding-catalog ~]$ . oraenv
ORACLE_SID = [oracle] ? scat     
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@sharding-catalog ~]$ lsnrctl start 

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 07-SEP-2018 16:08:58

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

Starting /u01/app/oracle/product/12.2.0.1/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/sharding-catalog/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sharding-catalog)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                07-SEP-2018 16:08:58
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/sharding-catalog/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sharding-catalog)(PORT=1521)))
The listener supports no services
The command completed successfully

4.2 调整open_links和open_links_per_instance参数

SQL> show parameter open

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
open_cursors                         integer     300
open_links                           integer     4
open_links_per_instance              integer     4
read_only_open_delayed               boolean     FALSE
session_max_open_files               integer     10
SQL> alter system set open_links=16 scope=spfile;
System altered.

SQL> alter system set open_links_per_instance=16 scope=spfile;
System altered.

SQL> shutdown immediate; 
SQL> startup

4.3在scat数据库上授予相关角色和权限

SQL> alter user gsmcatuser account unlock;
SQL> alter user gsmcatuser identified by welcome1;
SQL> create user mysdbadmin identified by welcome1;
SQL> grant connect, create session, gsmadmin_role to mysdbadmin;
SQL> grant inherit privileges on user SYS to GSMADMIN_INTERNAL;

4.4连接sharding-catalog主机,并使用GDSCTL创建shard catalog,并配置远程调度代理程序

[oracle@sharding-catalog ~]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/gsm_1/
[oracle@sharding-catalog ~]$ export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

[oracle@sharding-catalog ~]$ gdsctl
GDSCTL: Version 12.2.0.1.0 - Production on Fri Sep 07 16:26:02 CST 2018
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 sharding-catalog:1521:scat -chunks 12 -user mysdbadmin/welcome1 -sdb orasdb -region region1, region2
Catalog is created

4.5创建和启动shard director,设置操作系统凭证(credentials)

GDSCTL>add gsm -gsm sharddirector1 -listener 1522 -pwd welcome1 -catalog sharding-catalog:1521:scat -region region1
GSM successfully added
GDSCTL>start gsm -gsm sharddirector1
GSM is started successfully
GDSCTL>add credential -credential region1_cred -osaccount oracle -ospassword oracle
The operation completed successfully

4.6连接catalog database scat,设置调度端口和密码

[oracle@sdb1 ~]$ . oraenv
ORACLE_SID = [scat] ? scat
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@sdb1 ~]$ sqlplus / as sysdba
SQL> exec DBMS_XDB.sethttpport(8080);
SQL> commit;
SQL> exec DBMS_SCHEDULER.SET_AGENT_REGISTRATION_PASS('welcome1');
SQL> alter system register;

4.7连接每一个分片主机,在上面注册远程调度程序代理。并创建数据库目录和fast_recovery_area

[root@sharding-catalog gsm_1]# ssh oracle@shard1
oracle@shard1's password: 
Last failed login: Fri Sep  7 16:36:09 CST 2018 from 192.168.56.141 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Fri Sep  7 16:35:07 2018 from 192.168.56.141
[oracle@shard1 ~]$ schagent -start
Scheduler agent started using port 57133

[oracle@shard1 ~]$ schagent -status
Agent running with PID 6878

Agent_version:12.2.0.1.2
Running_time:00:00:13
Total_jobs_run:0
Running_jobs:0
Platform:Linux
ORACLE_HOME:/u01/app/oracle/product/12.2.0.1/db_1
ORACLE_BASE:/u01/app/oracle
Port:57133
Host:shard1

[oracle@shard1 ~]$ echo welcome1 | schagent -registerdatabase sharding-catalog 8080
Agent Registration Password ?  
Oracle Scheduler Agent Registration for 12.2.0.1.2 Agent
Agent Registration Successful!

[oracle@shard1 ~]$ mkdir /u01/app/oracle/oradata
[oracle@shard1 ~]$ mkdir /u01/app/oracle/fast_recovery_area


[root@sharding-catalog gsm_1]# ssh oracle@shard2
oracle@shard2's password: 
Last login: Fri Sep  7 16:45:51 2018 from 192.168.56.141

[oracle@shard2 ~]$ schagent -start

Scheduler agent started using port 32779
[oracle@shard2 ~]$ schagent -status
Agent running with PID 6227

Agent_version:12.2.0.1.2
Running_time:00:00:06
Total_jobs_run:0
Running_jobs:0
Platform:Linux
ORACLE_HOME:/u01/app/oracle/product/12.2.0.1/db_1
ORACLE_BASE:/u01/app/oracle
Port:32779
Host:shard2

[oracle@shard2 ~]$ echo welcome1 | schagent -registerdatabase sharding-catalog 8080
Agent Registration Password ?  
Oracle Scheduler Agent Registration for 12.2.0.1.2 Agent
Agent Registration Successful!

[oracle@shard2 ~]$ mkdir /u01/app/oracle/oradata
[oracle@shard2 ~]$ mkdir /u01/app/oracle/fast_recovery_area

5.部署SDB

5.1准备

[oracle@sharding-catalog ~]$ export ORACLE_BASE=/u01/app/oracle
[oracle@sharding-catalog ~]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/gsm_1/
[oracle@sharding-catalog ~]$ export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
[oracle@sharding-catalog ~]$ gdsctl
GDSCTL: Version 12.2.0.1.0 - Production on Fri Sep 07 16:50:44 CST 2018

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

Welcome to GDSCTL, type "help" for information.

Current GSM is set to SHARDDIRECTOR1
GDSCTL>
GDSCTL>set gsm -gsm sharddirector1
GDSCTL>connect mysdbadmin/welcome1
Catalog connection is established
GDSCTL>add shardgroup -shardgroup primary_shardgroup -deploy_as primary -region region1
The operation completed successfully
GDSCTL>create shard -shardgroup primary_shardgroup -destination shard1 -credential region1_cred -sys_password welcome1
The operation completed successfully
DB Unique Name: sh1
GDSCTL>create shard -shardgroup primary_shardgroup -destination shard2 -credential region1_cred -sys_password welcome1
The operation completed successfully
DB Unique Name: sh2
GDSCTL>config shard
Name                Shard Group         Status    State       Region    Availability 
----                -----------         ------    -----       ------    ------------ 
sh1                 primary_shardgroup  U         none        region1   -            
sh2                 primary_shardgroup  U         none        region1   -

5.2部署

GDSCTL>deploy
deploy: examining configuration...
deploy: deploying primary shard 'sh1' ...
deploy: network listener configuration successful at destination 'shard1'
deploy: starting DBCA at destination 'shard1' to create primary shard 'sh1' ...
deploy: deploying primary shard 'sh2' ...
deploy: network listener configuration successful at destination 'shard2'
deploy: starting DBCA at destination 'shard2' to create primary shard 'sh2' ...
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 'shard1' for shard 'sh1'
deploy: DBCA primary creation job succeeded at destination 'shard2' for shard 'sh2'
deploy: requesting Data Guard configuration on shards via GSM
deploy: shards configured successfully
The operation completed successfully

部署的过程会在shard主机上静默使用dbca程序,创建shard数据库,所以我们可以登陆到shard主机上查看dbca日志,如下所示:

[oracle@shard1 dbca]$ tail -200f silent.log_2018-09-07_04-54-22-PM
[ 2018-09-07 16:54:33.928 CST ] Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 2%
DBCA_PROGRESS : 16%
DBCA_PROGRESS : 30%
[ 2018-09-07 16:56:04.451 CST ] Creating and starting Oracle instance
DBCA_PROGRESS : 32%
DBCA_PROGRESS : 36%
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 44%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 48%
DBCA_PROGRESS : 50%
[ 2018-09-07 16:57:51.528 CST ] Completing Database Creation
DBCA_PROGRESS : 51%
DBCA_PROGRESS : 52%
DBCA_PROGRESS : 53%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 59%
DBCA_PROGRESS : 60%
[ 2018-09-07 16:59:33.584 CST ] Executing Post Configuration Actions
DBCA_PROGRESS : 90%
[ 2018-09-07 16:59:33.584 CST ] Running Custom Scripts
DBCA_PROGRESS : 100%
[ 2018-09-07 17:01:09.900 CST ] Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/sh1.
Database Information:
Global Database Name:sh1
System Identifier(SID):sh1

5.3 验证安装结果

GDSCTL>status gsm
Alias                     SHARDDIRECTOR1
Version                   12.2.0.1.0
Start Date                07-SEP-2018 16:32:41
Trace Level               off
Listener Log File         /u01/app/oracle/diag/gsm/sharding-catalog/sharddirector1/alert/log.xml
Listener Trace File       /u01/app/oracle/diag/gsm/sharding-catalog/sharddirector1/trace/ora_12204_140704565936512.trc
Endpoint summary          (ADDRESS=(HOST=sharding-catalog)(PORT=1522)(PROTOCOL=tcp))
GSMOCI Version            2.2.1
Mastership                Y
Connected to GDS catalog  Y
Process Id                12207
Number of reconnections   0
Pending tasks.     Total  0
Tasks in  process. Total  0
Regional Mastership       TRUE
Total messages published  2
Time Zone                 +08:00
Orphaned Buddy Regions:   
     None
GDS region                region1

关注dbDao.com的新浪微博

扫码加入微信Oracle小密圈,了解Oracle最新技术下载分享资源

TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569