Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » Oracle 12c+

12c 安装、配置和使用GDS/GSM

GDS/GSM是Oracle Database 12c特有的、新的可扩展性和可用性特性。是针对复制数据库(使用Active Data Guard、Oracle GoldenGate等复制技术)的全面的自动负载管理解决方案。客户端可以通过Global Service可以连接到配置在GDS Catalog中的多个数据库,这些数据库可以是RAC或者单实例。它提高了系统利用率,并为复制数据库上运行的应用程序负载提供更高的性能、可扩展性和可用性,也是最高可用性架构 (MAA) 必备的重要组件。我们可以通过GDSCTL命令行工具去创建GDS的配置和Global Service。

Oracle GDS为分布在全球各地或位于同一数据中心的一组复制数据库提供以下重要功能:
基于区域的负载路由
连接时负载平衡
为 Oracle 集成客户端提供运行时负载平衡建议
数据库间服务故障切换
适用于 Active Data Guard 的基于复制延迟的负载路由
适用于 Active Data Guard 的基于角色的全局服务

集中负载管理框架



上面的图片来自官方文档,可以这样理解

在两个数据中心(APAC,EMEA 这是region),配置了2个全局数据服务池(SALES POOL,HR POOL,这是gdspool,每套业务相关的主备库用一个gds pool),每个数据服务池里注册了很多数据库(通过add dataase/add brokerconfig注册到gdspool),可能是RAC + DG + OGG的架构,然后在这些gdspool中创建Global Service(通过add service),然后可以启动这些全局服务。这些相关信息(gdspool,region,database,service)存放在GDS Catalog(类似于rman的Catalog的功能)中,管理这些东西的是GSM(Global Service Manager)。其中GSM也可以做灾备。GDS中默认的region为regionora,默认的gdspool是dbpoolora。


什么是GDS Catalog?

这个有点类似于rman的catalog,主要用于存放GDS的配置信息。数据库必须是12c之后的版本

什么是GSM

是Global Service Manager的缩写,即全局服务管理器,是GDS的主要组成部分。GSM的职责如下

提供客户端连接时的负载均衡

提供service级别的负载均衡、故障转移等

创建run time LBA(load balancing advisory),并分发到所有的客户端
监控数据库实例的可用性和全局服务的可用性,并在失败的时候通知客户端

作为区域的监听,用于客户端连接global service


12c后新增了几个用户,下面这些用户用于GDS

SQL> select username,account_status from dba_users where username like '%GSM%';
USERNAME                                 ACCOUNT_STATUS
---------------------------------------- --------------------------------
GSMCATUSER                               EXPIRED & LOCKED
GSMADMIN_INTERNAL                        EXPIRED & LOCKED
GSMUSER                                  EXPIRED & LOCKED
SQL>

本文通过在ohs6上安装GSM,然后创建GDS Catalog DB,增加GSM管理器,增加GDS Pool,Region,增加数据库配置信息,创建服务,启动服务,这些是基本的操作步骤,更多复杂的配置请参考官方文档,下面是配置信息。

GSM和Catalog DB信息

Hosts ohs6.ohsdba.cn
GSM_HOME ORACLE_BASE=/pgold/ordb/oracle/product
ORACLE_HOME=/pgold/ordb/oracle/product/121/gsm
ORACLE_HOME(Catalog DB) ORACLE_SID=pgsm
Listener Port=1521
ORACLE_BASE=/pgold/ordb/oracle/product
ORACLE_HOME=/pgold/ordb/oracle/product/121/db
Active DataGuard信


gdsctl config


安装GSM软件

以下操作需满足的条件

Oracle GSM已经安装好

GDS Catalog DB数据库已安装好(数据库名字pgsm,数据库监听端口1521)

创建GDS Catalog

[oracle@ohs6 bin]$ pwd
/usr/local/bin
[oracle@ohs6 bin]$
[oracle@ohs6 bin]$ cat db
export ORACLE_HOME=/pgold/ordb/oracle/product/121/db
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export ORACLE_SID=pgsm
[oracle@ohs6 bin]$ cat gsm
export ORACLE_HOME=/pgold/ordb/oracle/product/121/gsm
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
[oracle@ohs6 bin]$
[root@ohs6 ~]# su - oracle
[oracle@ohs6 ~]$ . db
[oracle@ohs6 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jan 13 11:21:07 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> create user mygsm identified by mygsm default tablespace users;

User created.
SQL> grant gsmadmin_role to mygsm;
Grant succeeded.

SQL>
SQL> alter user gsmcatuser identified by gsmcatuser account unlock;

[oracle@ohs6 ~]$ . gsm
[oracle@ohs6 ~]$ gdsctl
GDSCTL: Version 12.1.0.2.0 - Production on Fri Jan 13 11:22:30 EST 2017

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

Welcome to GDSCTL, type "help" for information.

Current GSM is set to GSMORA
GDSCTL>connect mygsm/mygsm@ohs6.ohsdba.cn:1521/pgsm
Catalog connection is established
GDSCTL>exit
[oracle@ohs6 ~]$ gdsctl
GDSCTL: Version 12.1.0.2.0 - Production on Fri Jan 13 11:23:34 EST 2017

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

Welcome to GDSCTL, type "help" for information.

Current GSM is set to GSMORA
GDSCTL>create catalog -database ohs6.ohsdba.cn:1521/pgsm -user mygsm/mygsm
Catalog is created
GDSCTL>
为GDS Catalog增加一个GSM
GDSCTL>add gsm -gsm gsmohs -listener 12000 -catalog ohs6.ohsdba.cn:1521/pgsm
"gsmcatuser" password:
Create credential oracle.security.client.connect_string1
GSM successfully added
GDSCTL>set gsm -gsm gsmohs
GDSCTL>
GDSCTL>config gsm -gsm gsmohs
Name: gsmohs
Endpoint 1: (ADDRESS=(HOST=ohs6.ohsdba.cn)(PORT=12000)(PROTOCOL=tcp))
Local ONS port: 6123
Remote ONS port: 6234
ORACLE_HOME path: /pgold/ordb/oracle/product/121/gsm
GSM Host name: ohs6.ohsdba.cn
Region: regionora

Buddy
------------------------

GDSCTL>start gsm -gsm gsmohs
GSM is started successfully
GDSCTL>status gsm
Alias                     GSMOHS
Version                   12.1.0.2.0
Start Date                13-JAN-2017 11:26:26
Trace Level               off
Listener Log File         /pgold/ordb/oracle/product/diag/gsm/ohs6/gsmohs/alert/log.xml
Listener Trace File       /pgold/ordb/oracle/product/diag/gsm/ohs6/gsmohs/trace/ora_30347_140206217676224.trc
Endpoint summary          (ADDRESS=(HOST=ohs6.ohsdba.cn)(PORT=12000)(PROTOCOL=tcp))
GSMOCI Version            0.1.11
Mastership                Y
Connected to GDS catalog  Y
Process Id                30349
Number of reconnections   0
Pending tasks.     Total  0
Tasks in  process. Total  0
Regional Mastership       TRUE
Total messages published  0
Time Zone                 -05:00
Orphaned Buddy Regions:
     None
GDS region                regionora

GDSCTL>
增加GDS Pool,region
GDSCTL>add gdspool -gdspool sales
GDSCTL>add region -region apac,emea
GDSCTL>config region
Name                          Buddy
----                          -----
regionora
apac
emea

GDSCTL>modify region -region apac -buddy emea
GDSCTL>modify region -region emea -buddy apac
GDSCTL>config region
Name                          Buddy
----                          -----
regionora
apac                          emea
emea                          apac

GDSCTL>
增加database/brokerconfig到gdspool
在主库上unlock数据库用户gsmuser
SQL> alter user gsmuser identified by gsmuser account unlock;

User altered.

SQL> select username,account_status from dba_users where username like '%GSM%';

USERNAME                                 ACCOUNT_STATUS
---------------------------------------- --------------------------------
GSMCATUSER                               EXPIRED & LOCKED
GSMADMIN_INTERNAL                        EXPIRED & LOCKED
GSMUSER                                  OPEN

SQL> conn sys/oracle@stdby as sysdba
Connected.
SQL> select instance_name,instance_role from gv$instance;

INSTANCE_NAME    INSTANCE_ROLE
---------------- ------------------
stdby2           PRIMARY_INSTANCE
stdby1           PRIMARY_INSTANCE

SQL> select username,account_status from dba_users where username like '%GSM%';

USERNAME                                 ACCOUNT_STATUS
---------------------------------------- --------------------------------
GSMUSER                                  OPEN
GSMADMIN_INTERNAL                        EXPIRED & LOCKED
GSMCATUSER                               EXPIRED & LOCKED

SQL> select open_mode from gv$database;

OPEN_MODE
--------------------
READ ONLY WITH APPLY
READ ONLY WITH APPLY

SQL>
完成以上步骤,然后添加数据库
GDSCTL>add brokerconfig -connect prod-scan:10010/prod -region apac -gdspool sales
"gsmuser" password:
DB Unique Name: prod
GDSCTL>config database
Name                          Pool                          Status         Region
----                          ----                          ------         ------
prod                          sales                         Ok             apac
stdby                         sales                         Ok

GDSCTL>modify database -database stdby -region emea -gdspool sales
GDSCTL>config database
Name                          Pool                          Status         Region
----                          ----                          ------         ------
prod                          sales                         Ok             apac
stdby                         sales                         Ok             emea

GDSCTL>status database
Database: "prod" Registered: Y State: Ok ONS: Y. Role: PRIMARY Instances: 2 Region: apac
   Registered instances:
     sales%1
     sales%2
Database: "stdby" Registered: Y State: Ok ONS: Y. Role: PH_STNDBY Instances: 2 Region: emea
   Registered instances:
     sales%11
     sales%12

GDSCTL>

注意:如果配置了DG Broker,可以通过add brokerconfig添加数据库,如果没有,可以通过add database添加

为gdspoo创建服务,并启动服务

GDSCTL>add service -service prod_srv -gdspool sales -preferred_all -role PRIMARY
GDSCTL>
GDSCTL>config service

Name                          Network name                  Pool                          Started Preferred all
----                          ------- ----                  ----                          ------- --------- ---
prod_srv                      prod_srv.sales.oradbcloud     sales                         No      Yes

GDSCTL>
GDSCTL>start service -service prod_srv -gdspool sales

配置客户端连接字符串
prod_srv =
 (DESCRIPTION=
    (FAILOVER=on)
     (ADDRESS_LIST=
        (LOAD_BALANCE=ON)
        (ADDRESS=(PROTOCOL = TCP)(host=ohs6.ohsdba.cn)(port=12000)))
        (CONNECT_DATA=
        (SERVICE_NAME=prod_srv.sales.oradbcloud)
        (REGION=apac)
     )
 )

注意:这里的host为GSM服务器的信息,port为GSM的端口,service_name的格式为:服务名.gdspool名称.oradbcloud(这个是默认的)。然后通过这个TNS信息就可以连接数据库了。


BugGDSCTL ADD SERVICE Fails w/ NET-40063 and PRKH-1014 When Grid Infrastructure Setup is Role Separated (Doc ID 2009820.1)

GDSCTL>add service -service prod_srv -role primary -preferred_all -gdspool sales
GSM Errors:
NET-40063: Failed to create global service. Transaction rollbacked
prod:ORA-45540: Call to SRVCTL failed with status 1, errors: PRCD-1288 : User is not authorized to create service prodsrv for database prod
PRKH-1014 : Current user "orgrid" is not the oracle owner user "oracle" of oracle home "/pgold/ordb/oracle/product/121"
.
ORA-06512: at "GSMADMIN_INTERNAL.DBMS_GSM_DBADMIN", line 1371
ORA-06512: at line 1 (ngsmoci_execute)
stdby:ORA-45540: Call to SRVCTL failed with status 1, errors: PRCD-1288 : User is not authorized to create service prodsrv for database stdby
PRKH-1014 : Current user "orgrid" is not the oracle owner user "oracle" of oracle home "/pgold/ordb/oracle/product/121"
.
ORA-06512: at "GSMADMIN_INTERNAL.DBMS_GSM_DBADMIN", line 1371
ORA-06512: at line 1 (ngsmoci_execute)

GDSCTL>
注意:这个bug的意思就是说,安装RAC时,用了oracle,grid两个用户,才出现这样的情况。



Reference

http://docs.oracle.com/database/121/GSMUG/intro.htm#GSMUG108

http://docs.oracle.com/database/121/GSMUG/toc.htm

http://www.oracle.com/technetwork/cn/database/features/availability/global-data-services-1949717-zhs.html
http://www.oracle.com/technetwork/database/features/availability/demo-7-gds-2120625.html

http://www.oracle.com/technetwork/database/availability/global-data-services-12c-wp-1964780.pdf



关键词:gds gsm 12c 

相关文章

How to generate AWR on PDB and ADG(12.2 afterwards)
在12c上使用wm_concat
Exadata with database 12.2
如何在oracle 12c中正确的应用补丁?
在OEL6.8上安装12.2 RAC
Oracle Database 12.2 Hands-On Lab
How to create single physical standby for RAC
12c 安装、配置和使用GDS/GSM
12c 如何通过DG Broker配置far_sync
Upgrade 11gR2 RAC database to 12.1.0.2 with DBUA
Upgrade 11gR2 RAC Grid Infrastructure to 12.1.0.2
12c RAC和RAC One Node之间相互转换

联系我们

韩朝阳



    Phone:186-9589-1286

    E-mail:ohsdba@qq.com

    微  信: ohsdba


电话(186-9589-1286)

QQ(375349564)

微信(ohsdba)


常用链接

Oracle Database Upgrade

Oracle

eDelivery
My Oracle Support

Exadata 12.1 Document

Exadata 12.2 Document

Oracle 11gR2 Document

Oracle 12cR1 Document

Oracle 12cR2 Document

GoldenGate 12c

Oracle Fusion Middleware

Mysql Document

PostgreSQL

Python

github

sourceforge



Top
Cell186-9589-1286
QQ 375349564
E-mail ohsdba@qq.com