代码改变世界

测试12.2.0.1RAC PDB级别的Failover

2019-03-01 19:08  AlfredZhao  阅读(845)  评论(1编辑  收藏  举报

关键步骤:手工添加服务名A并启动(已验证默认的服务名测试验证无法实现Failover)

[oracle@db90 ~]$ srvctl add service -db orcl -service A -preferred cdb11,cdb12 -pdb pdb1
[oracle@db90 ~]$ srvctl start service -db orcl -service A

完整步骤:

1.确认环境信息

1.1 服务端信息:

SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cdb_cluster_name                     string      orcl
cell_offloadgroup_name               string
db_file_name_convert                 string
db_name                              string      orcl
db_unique_name                       string      orcl
global_names                         boolean     FALSE
instance_name                        string      cdb11
lock_name_space                      string
log_file_name_convert                string
pdb_file_name_convert                string
processor_group_name                 string

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      orcl
SQL> show con_id

CON_ID
------------------------------
1
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO

1.2 客户端tnsnames.ora配置:

PDB=
        (DESCRIPTION =
                (ADDRESS_LIST =
        (LOAD_BALANCE = off)
        (FAILOVER=on)
                (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.90)(PORT = 1521))
                (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.92)(PORT = 1521))
        )
        (CONNECT_DATA =
                (SERVER = DEDICATED)
                (SERVICE_NAME = A)
                (FAILOVER_MODE =
                        (TYPE = SELECT)
                        (METHOD = BASIC)
                        (RETRIES = 180)
                        (DELAY = 5)
                        )
                )
        )

2.手工添加服务并启动

[oracle@db90 ~]$ srvctl add service -db orcl -service A -preferred cdb11,cdb12 -pdb pdb1
[oracle@db90 ~]$ srvctl start service -db orcl -service A

查看服务状态,看到已经成功增加了ora.orcl.a.svc:

[grid@db90 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
ora.DATA.dg
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
ora.FRA.dg
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
ora.MGMT.dg
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
ora.OCRVT.dg
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
ora.chad
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
ora.net1.network
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
ora.ons
               ONLINE  ONLINE       db90                     STABLE
               ONLINE  ONLINE       db92                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db92                     STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       db92                     169.254.59.133 10.0.
                                                             0.92,STABLE
ora.asm
      1        ONLINE  ONLINE       db90                     Started,STABLE
      2        ONLINE  ONLINE       db92                     Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       db90                     STABLE
ora.db90.vip
      1        ONLINE  ONLINE       db90                     STABLE
ora.db92.vip
      1        ONLINE  ONLINE       db92                     STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       db92                     Open,STABLE
ora.orcl.a.svc
      1        ONLINE  ONLINE       db90                     STABLE
      2        ONLINE  ONLINE       db92                     STABLE
ora.orcl.db
      1        ONLINE  ONLINE       db90                     Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db_1,STABLE
      2        ONLINE  ONLINE       db92                     Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db_1,STABLE
ora.qosmserver
      1        ONLINE  ONLINE       db90                     STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       db92                     STABLE
--------------------------------------------------------------------------------

3.测试客户端连接到服务端

[oracle@db01 admin]$ sqlplus scott/tiger@pdb

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 1 17:35:08 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cdb_cluster_name                     string      orcl
cell_offloadgroup_name               string
db_file_name_convert                 string
db_name                              string      orcl
db_unique_name                       string      orcl
global_names                         boolean     FALSE
instance_name                        string      cdb11
lock_name_space                      string
log_file_name_convert                string
pdb_file_name_convert                string
processor_group_name                 string

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      orcl

4.关闭实例1的pdb1

[oracle@db90 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Mar 1 18:21:33 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
SQL> alter session set container=pdb1;

Session altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDB1                           READ WRITE NO
SQL> shutdown immediate;
Pluggable Database closed.
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDB1                           MOUNTED
SQL> 

5.客户端再次连接到服务端

[oracle@db01 admin]$ sqlplus scott/tiger@pdb

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 1 18:23:48 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cdb_cluster_name                     string      orcl
cell_offloadgroup_name               string
db_file_name_convert                 string
db_name                              string      orcl
db_unique_name                       string      orcl
global_names                         boolean     FALSE
instance_name                        string      cdb12
lock_name_space                      string
log_file_name_convert                string
pdb_file_name_convert                string
processor_group_name                 string

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      orcl
SQL> 

6.测试完成重新启动实例1的pdb1

启动节点1的服务就会拉起实例1的pdb1:
[oracle@db90 ~]$ srvctl start service -db orcl -service A -node db90

整个测试过程已完成。