使用表空间组来管理多个临时表空间

使用表空间组来管理多个临时表空间

表空间组能让用户使用来自多个临时表空间中的临时空间。使用表空间组,而不是单个临时表空间,可以减少由于一个临时表空间没有足够的空间来处理排序而引发的问题。表空间组能让单个并行操作的并行执行服务器进程使用多个临时表空间。表空间组有以下特性:
.它包含至少一个临时表空间。对于一个表空间组可以包含的临时表空间数量没有限制。
.它共享命名空间,所以表空间组的名字不能与任何表空间名相同。
.当对数据库或用户指定缺省临时表空间时可以使用表空间组来代替。

我们不能显示创建一个表空间组,但可以在创建第一临时表空间时隐式来创建表空间组。当表空间组中的最后一个临时表空间被删除后,表空间组也会被删除。查询dba_tablespace_groups可以查看相关表空间组与相关的临时表空间。

创建表空间组
当执行create temporary tablespace或alter tablespace语句时通过指定tablespace group子句来隐式创建表空间组并且所指定的表空间组要在当前数据库中并不存在。例如,如果表空间组group1,group2不存在,那么下面的语句将会创建这两个表空间组,并且每个表空间组只有一个临时表空间存在。

SQL> create temporary tablespace temp2 tempfile '+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/TEMPFILE/temp2.dbf' size 50M tablespace group group1;

Tablespace created.

SQL> alter tablespace temp tablespace group group2;

Tablespace altered.


SQL> select * from dba_tablespace_groups;

GROUP_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
GROUP2                         TEMP
GROUP1                         TEMP2

更改表空间组成员
可以向现有表空间组增加临时表空间,这可以通过执行包含有tablespace group子句的create temporary tablespace或alter tablespace语句来完成。

下面的语句将向现有表空间组group1中增加一个临时表空间temp3,因些表空间组group1包含临时表空间temp2与temp3。

SQL> create temporary tablespace temp3 tempfile '+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/TEMPFILE/temp3.dbf' size 50M tablespace group group1;

Tablespace created.

SQL> select * from dba_tablespace_groups;

GROUP_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
GROUP2                         TEMP
GROUP1                         TEMP2
GROUP1                         TEMP3

下面的语句将向现有表空间组group2中增加一个临时表空间temp2,但因为临时表空间temp2已经存在,语句只是将临时表空间temp2从表空间组group1移到表空间组group2中。

SQL> select * from dba_tablespace_groups;

GROUP_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
GROUP2                         TEMP
GROUP2                         TEMP2
GROUP1                         TEMP3

现在表空间组group2包含临时表空间temp,temp2,表空间组group1只包含临时表空间temp3。

下面的语句将从表空间组group1中删除临时表空间temp3

SQL> alter tablespace temp3 tablespace group '';

Tablespace altered.

SQL> select * from dba_tablespace_groups;

GROUP_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
GROUP2                         TEMP
GROUP2                         TEMP2

临时表空间temp3不再属于任何表空间组。因此表空间组group1不包含任何临时表空间,因此隐式地删除了表空间组group1。

指定表空间组作为数据库的缺省临时表空间
通过执行alter database … default temporary tablespace语句来指定一个表空间组作为数据库的临时表空间。

SQL> SELECT PROPERTY_NAME, PROPERTY_VALUE FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';

PROPERTY_NAME                                       PROPERTY_VALUE
--------------------------------------------------  --------------------------------------------------
DEFAULT_TEMP_TABLESPACE                             TEMP



SQL> alter database default temporary tablespace group2;

Database altered.


SQL> SELECT PROPERTY_NAME, PROPERTY_VALUE FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';

PROPERTY_NAME                                       PROPERTY_VALUE
--------------------------------------------------  --------------------------------------------------
DEFAULT_TEMP_TABLESPACE                             GROUP2

任何没有显示指定临时表空间的用户,将可以使用临时表空间temp,temp2中的空间。当表空间组被指定作为数据库的临时表空间时,不能删除表空间组中的任何成员。要删除临时表空间必须首先要删除表空间组。同样不能删除作为数据库的缺省临时表空间。

Oracle 12CR2 Install the Sample Schemas

在Oracle 12CR2中在创建数据库时不能安装sample schemas,Oracle将sample schemas的安装脚本存储在GitHub上了,可以通过以下链接地址进行下载

https://github.com/oracle/db-sample-schemas/releases/latest

下载到的是一个zip文件,例如我下载的文件名为db-sample-schemas-12.2.0.1.zip,将其解压

[oracle@jytest1 schema]$ unzip db-sample-schemas-12.2.0.1.zip

[oracle@jytest1 schema]$ ls -lrt
total 36584
-rw-r--r--  1 oracle oinstall     2322 Apr  3  2009 drop_sch.sql
-rw-r--r--  1 oracle oinstall    16894 Jul  1  2014 sted_mkplug.sql.dbl
-rw-r--r--  1 oracle oinstall    27570 Jul  1  2014 mkplug.sql
-rw-r--r--  1 oracle oinstall     1685 Nov  6  2015 mk_dir.sql.sbs
drwxr-xr-x  2 oracle oinstall        6 Mar 20 19:50 log
-rw-r--r--  1 oracle oinstall     1824 Mar 20 19:51 mk_dir.sql
drwxr-xr-x  2 oracle oinstall     4096 May 18 17:12 human_resources
-rw-r--r--  1 oracle oinstall 37389564 May 18 17:48 db-sample-schemas-12.2.0.1.zip
drwxrwxrwx 10 oracle oinstall     4096 May 18 18:46 db-sample-schemas-12.2.0.1

创建sample schemas只需执行db-sample-schemas-12.2.0.1目录下的mksample.sql脚本,其语法如下:

mksample          EXAMPLE TEMP $ORACLE_HOME/demo/schema/log/ localhost:1521/pdb

其参数分别指system,sys,hr,oe,pm,ix,sh,bi用户的密码,与缺省表空间,临时表空间名,以及存储生成日志文件的目录和连接数据库的连接串

[oracle@jytest1 db-sample-schemas-12.2.0.1]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu May 18 18:01:54 2017

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

SQL> @mksample.sql xxzx7817600 xxzx7817600 hr oe pm id sh bi users temp /u01/app/oracle/product/12.2.0/db/demo/schema/db-sample-schemas-12.2.0.1/log/ jypdb

specify password for SYSTEM as parameter 1:

specify password for SYS as parameter 2:

specify password for HR as parameter 3:

specify password for OE as parameter 4:

specify password for PM as parameter 5:

specify password for IX as parameter 6:

specify password for  SH as parameter 7:

specify password for  BI as parameter 8:

specify default tablespace as parameter 9:

specify temporary tablespace as parameter 10:

specify log file directory (including trailing delimiter) as parameter 11:

specify connect string as parameter 12:

Sample Schemas are being created ...

mkdir: cannot create directory 鈥u01/app/oracle/product/12.2.0/db/demo/schema/db-sample-schemas-12.2.0.1鈥 File exists

Connected.
DROP USER hr CASCADE
          *
ERROR at line 1:
ORA-01918: user 'HR' does not exist


DROP USER oe CASCADE
          *
ERROR at line 1:
ORA-01918: user 'OE' does not exist


DROP USER pm CASCADE
          *
ERROR at line 1:
ORA-01918: user 'PM' does not exist


DROP USER ix CASCADE
          *
ERROR at line 1:
ORA-01918: user 'IX' does not exist


DROP USER sh CASCADE
          *
ERROR at line 1:
ORA-01918: user 'SH' does not exist


DROP USER bi CASCADE
          *
ERROR at line 1:
ORA-01918: user 'BI' does not exist


Connected.
SP2-0310: unable to open file "__SUB__CWD__/human_resources/hr_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/order_entry/oe_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/product_media/pm_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/info_exchange/ix_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/sales_history/sh_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/bus_intelligence/bi_main.sql"
Connected.
not spooling currently
SP2-0310: unable to open file "__SUB__CWD__/mkverify.sql"

上面的错误显示不能打开__SUB__CWD__/目录下的相关脚本文件,这里我们需要将__SUB__CWD__/目录使用相关脚本存储的目录的绝对路径来替,下面执行替换

[oracle@jytest1 db-sample-schemas-12.2.0.1]$ perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat

重新执行

[oracle@jytest1 ~]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu May 18 19:05:33 2017

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

SQL>@mksample.sql xxzx7817600 xxzx7817600 hr oe pm id sh bi users temp /u01/app/oracle/product/12.2.0/db/demo/schema/db-sample-schemas-12.2.0.1/log/ jypdb

specify password for SYSTEM as parameter 1:

specify password for SYS as parameter 2:

specify password for HR as parameter 3:

specify password for OE as parameter 4:

specify password for PM as parameter 5:

specify password for IX as parameter 6:

specify password for  SH as parameter 7:

specify password for  BI as parameter 8:

specify default tablespace as parameter 9:

specify temporary tablespace as parameter 10:

specify log file directory (including trailing delimiter) as parameter 11:

specify connect string as parameter 12:

Sample Schemas are being created ...
....省略....

Index cardinality (without  LOB indexes)

OWNER  INDEX_NAME                DISTINCT_KEYS   NUM_ROWS
------ ------------------------- ------------- ----------
HR     COUNTRY_C_ID_PK                      25         25
HR     DEPT_ID_PK                           27         27
HR     DEPT_LOCATION_IX                      7         27
HR     EMP_DEPARTMENT_IX                    11        106
HR     EMP_EMAIL_UK                        107        107
HR     EMP_EMP_ID_PK                       107        107
HR     EMP_JOB_IX                           19        107
HR     EMP_MANAGER_IX                       18        106
HR     EMP_NAME_IX                         107        107
HR     JHIST_DEPARTMENT_IX                   6         10
HR     JHIST_EMPLOYEE_IX                     7         10
HR     JHIST_EMP_ID_ST_DATE_PK              10         10
HR     JHIST_JOB_IX                          8         10
HR     JOB_ID_PK                            19         19
HR     LOC_CITY_IX                          23         23
HR     LOC_COUNTRY_IX                       14         23
HR     LOC_ID_PK                            23         23
HR     LOC_STATE_PROVINCE_IX                17         17
HR     REG_ID_PK                             4          4
IX     AQ$_STREAMS_QUEUE_TABLE_Y             0          0
OE     ACTION_TABLE_MEMBERS                132        132
OE     CUSTOMERS_PK                        319        319
OE     CUST_ACCOUNT_MANAGER_IX               4        319
OE     CUST_EMAIL_IX                       319        319
OE     CUST_LNAME_IX                       176        319
OE     CUST_UPPER_NAME_IX                  319        319
OE     INVENTORY_IX                       1112       1112
OE     INV_PRODUCT_IX                      208       1112
OE     ITEM_ORDER_IX                       105        665
OE     ITEM_PRODUCT_IX                     185        665
OE     LINEITEM_TABLE_MEMBERS              132        132
OE     ORDER_ITEMS_PK                      665        665
OE     ORDER_ITEMS_UK                      665        665
OE     ORDER_PK                            105        105
OE     ORD_CUSTOMER_IX                      47        105
OE     ORD_ORDER_DATE_IX                   105        105
OE     ORD_SALES_REP_IX                      9         70
OE     PRD_DESC_PK                        8640       8640
OE     PRODUCT_INFORMATION_PK              288        288
OE     PROD_NAME_IX                       3727       8640
OE     PROD_SUPPLIER_IX                     62        288
OE     PROMO_ID_PK                           2          2
OE     WAREHOUSES_PK                         9          9
OE     WHS_LOCATION_IX                       9          9
PM     ONLINEMEDIA_PK                        9          9
PM     PRINTMEDIA_PK                         4          4
SH     CHANNELS_PK                           5          5
SH     COSTS_PROD_BIX                        0          0
SH     COSTS_TIME_BIX                        0          0
SH     COUNTRIES_PK                         23         23
SH     CUSTOMERS_GENDER_BIX                  2          5
SH     CUSTOMERS_MARITAL_BIX                11         18
SH     CUSTOMERS_PK                      55500      55500
SH     CUSTOMERS_YOB_BIX                    75         75
SH     DR$SUP_TEXT_IDX$RC
SH     DR$SUP_TEXT_IDX$X                     0          0
SH     FW_PSC_S_MV_CHAN_BIX                  4          4
SH     FW_PSC_S_MV_PROMO_BIX                 4          4
SH     FW_PSC_S_MV_SUBCAT_BIX               21         21
SH     FW_PSC_S_MV_WD_BIX                  210        210
SH     PRODUCTS_PK                          72         72
SH     PRODUCTS_PROD_CAT_IX                  5         72
SH     PRODUCTS_PROD_STATUS_BIX              1          1
SH     PRODUCTS_PROD_SUBCAT_IX              21         72
SH     PROMO_PK                            503        503
SH     SALES_CHANNEL_BIX                     4         92
SH     SALES_CUST_BIX                     7059      35808
SH     SALES_PROD_BIX                       72       1074
SH     SALES_PROMO_BIX                       4         54
SH     SALES_TIME_BIX                     1460       1460
SH     SUP_TEXT_IDX
SH     TIMES_PK                           1826       1826

72 rows selected.

SQL> select username from dba_users;

USERNAME
------------------------------------------------------------------------------------------
SYS
SYSTEM
XS$NULL
LBACSYS
OUTLN
DBSNMP
APPQOSSYS
DBSFWUSER
GGSYS
ANONYMOUS
CTXSYS
SI_INFORMTN_SCHEMA
DVSYS
DVF
GSMADMIN_INTERNAL
ORDPLUGINS
MDSYS
OLAPSYS
ORDDATA
XDB
WMSYS
ORDSYS
GSMCATUSER
MDDATA
SYSBACKUP
REMOTE_SCHEDULER_AGENT
PDBADMIN
GSMUSER
SYSRAC
HR
BI
OJVMSYS
AUDSYS
DIP
JY
OE
PM
SYSKM
ORACLE_OCM
SYS$UMF
QS_ADM
IX
SYSDG
SPATIAL_CSW_ADMIN_USR
SH

45 rows selected.

相关sample schemas创建成功。

Oracle 12CR2 Oracle Restart – ASM Startup fails with PRCR-1079

操作系统Oracle Linux 7.1,数据库版本为12.2.0.1 Oracle Restart在重启之后不能正常启动ASM实例

[grid@jytest3 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  OFFLINE      jytest3                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest3                  STABLE
ora.asm
               ONLINE  OFFLINE      jytest3                  STABLE
ora.ons
               OFFLINE OFFLINE      jytest3                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.driver.afd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.evmd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.jy.db
      1        ONLINE  OFFLINE                               Instance Shutdown,ST
                                                             ABLE
--------------------------------------------------------------------------------

尝试手动启动ASM实例,提示无效的用户与密码

[grid@jytest3 ~]$ srvctl start asm -startoption MOUNT -f
PRKO-2002 : Invalid command line option: -f
[grid@jytest3 ~]$ srvctl start asm -startoption MOUNT 
PRCR-1079 : Failed to start resource ora.asm
CRS-5017: The resource action "ora.asm start" encountered the following error: 
ORA-01017: invalid username/password; logon denied
. For details refer to "(:CLSN00107:)" in "/u01/app/grid/diag/crs/jytest3/crs/trace/ohasd_oraagent_grid.trc".

CRS-2674: Start of 'ora.asm' on 'jytest3' failed
ORA-01017: invalid username/password; logon denied

如果尝试使用SQL*PLUS来启动ASM实例,仍然提示无效的用户与密码

[grid@jytest3 ~]$ sqlplus / as sysasm

SQL*Plus: Release 12.2.0.1.0 Production on Tue May 2 20:30:15 2017

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

ERROR:
ORA-01017: invalid username/password; logon denied

检查错误跟踪文件内容如下:

2017-05-02 21:47:39.181 :    AGFW:380081920: {0:0:169} Agent received the message: RESOURCE_START[ora.asm jytest3 1] ID 4098:1530
2017-05-02 21:47:39.181 :    AGFW:380081920: {0:0:169} Preparing START command for: ora.asm jytest3 1
2017-05-02 21:47:39.181 :    AGFW:380081920: {0:0:169} ora.asm jytest3 1 state changed from: OFFLINE to: STARTING
2017-05-02 21:47:39.181 :    AGFW:380081920: {0:0:169} RECYCLE_AGENT attribute not found
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] (:CLSN00107:) clsn_agent::start {
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::start 000 { 
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::start stopConnection 020
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::stopConnection
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::broadcastEvent 000 entry { OHSid:/u01/app/grid/product/12.2.0/crs+ASM 

s_ohSidEventMapLock:0x139e930 action:2
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::removeConnection connection count 0
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::removeConnection freed 0
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::stopConnection sid +ASM status  1
2017-05-02 21:47:39.182 : USRTHRD:388486912: {0:0:169} ConnectionPool::~ConnectionPool  destructor this:f4061e90 m_oracleHome:/u01/app/grid/product/12.2.0/crs, 

m_oracleSid:+ASM,  m_usrOraEnv:  m_pResState:0x7f10f4049000
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent::refresh
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent::refresh ORACLE_HOME = /u01/app/grid/product/12.2.0/crs
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnUtils::cmdIdIsStart CmdId:257
2017-05-02 21:47:39.182 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnUtils::cmdIdIsStart CmdId:257
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent:getOracleSidAttrib 2 getResAttrib USR_ORA_INST_NAME oracleSid:+ASM
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent:getOracleSidAttrib oracleSid:+ASM
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent::refresh ORACLE_SID = +ASM
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::ConnectionPool 2 constructor this:406d700 

m_oracleHome:/u01/app/grid/product/12.2.0/crs, m_oracleSid:+ASM, m_usrOraEnv: m_instanceType:2 m_instanceVersion:12.2.0.1.0
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::ConnectionPool 2 constructor m_pResState:0x7f1104033540
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent::setOracleSidAttrib updating GEN_USR_ORA_INST_NAME to +ASM
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnUtils::setResAttrib nonPerX current value GEN_USR_ORA_INST_NAME value +ASM
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Utils::setResAttrib clsagfw_modify_attribute attr GEN_USR_ORA_INST_NAME value +ASM retCode 0
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sModifyConfig entry resversion:12.2.0.1.0 compId:+ASM comment:StartOption[1] {
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sInitFile entry pathname:/etc finename:oratab
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sclsnInstAgent::sInitFile pathname:/etc 

backupPath:/u01/app/grid/product/12.2.0/crs/srvm/admin/ filename:oratab pConfigF:0x7f11040752d8
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::ConfigFile constructor name:oratab
2017-05-02 21:47:39.183 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] CssLock::lock s_siha_mtex, got lock CLSN.oratab.jytest3
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse parseLine name: value: comment:
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse mmap name:+asm nameWithCase:+ASM value:/u01/app/grid/product/12.2.0/crs:N 

comment:
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse mmap name:jy nameWithCase:jy value:/u01/app/oracle/product/12.2.0/db:N 

comment:
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] CssLock::unlock s_siha_mtex, released lock CLSN.oratab.jytest3
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::setAltName this:0x7f11040d80e0 altName:+ASM
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::setAltValue altValue:/u01/app/grid/product/12.2.0/crs:N
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sclsnInstAgent::sInitFile resType:ora.asm.type setAltName(compId):+ASM setAltValue

(oracleHome):/u01/app/grid/product/12.2.0/crs:N
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnUtils::cmdIdIsStart CmdId:257
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnUtils::cmdIdIsStart CmdId:257
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent:getOracleSidAttrib 2 getResAttrib USR_ORA_INST_NAME oracleSid:+ASM
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent:getOracleSidAttrib oracleSid:+ASM
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::getAltName this:0x7f11040d80e0
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile:getAltName altName:+asm
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sclsnInstAgent::sInitFile dbname:+ASM altName:+asm
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::getComment name:+asm comment:
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::getAltName this:0x7f11040d80e0
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile:getAltName altName:+asm
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::getAltName this:0x7f11040d80e0
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile:getAltName altName:+asm
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::getComment name:+asm comment:
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sclsnInstAgent::sInitFile exit dbname:+ASM startup comment: startup altName:+asm comment:
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::start pConfigF:40d80e0
2017-05-02 21:47:39.184 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] CssLock::lock s_siha_mtex, got lock CLSN.oratab.jytest3
2017-05-02 21:47:39.185 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse parseLine name: value: comment:
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse mmap name:+asm nameWithCase:+ASM value:/u01/app/grid/product/12.2.0/crs:N 

comment:
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse mmap name:jy nameWithCase:jy value:/u01/app/oracle/product/12.2.0/db:N 

comment:
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sclsnInstAgent::sCleanEntry - delete alt(sid) entry
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnUtils::cmdIdIsStart CmdId:257
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnUtils::cmdIdIsStart CmdId:257
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent:getOracleSidAttrib 2 getResAttrib USR_ORA_INST_NAME oracleSid:+ASM
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] AsmAgent:getOracleSidAttrib oracleSid:+ASM
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sclsnInstAgent::sCleanEntry - key = +ASM
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse parseLine name: value: comment:
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse mmap name:+asm nameWithCase:+ASM value:/u01/app/grid/product/12.2.0/crs:N 

comment:
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::parse mmap name:jy nameWithCase:jy value:/u01/app/oracle/product/12.2.0/db:N 

comment:
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConfigFile::updateInPlace file /etc/oratab is not modified
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] CssLock::unlock s_siha_mtex, released lock CLSN.oratab.jytest3
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sclsnInstAgent::sCleanEntry - key[+ASM] is cleaned
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] sModifyConfig exit for compId:+ASM }
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Utils::getResAttrib entry attribName:USR_ORA_OPI required:0 loglevel:1
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Utils::getResAttrib: attribname USR_ORA_OPI value false len 5
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Utils::getResAttrib attribname:USR_ORA_OPI value:false exit
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Agent::valueOfAttribIs attrib: REASON compare value: user attribute value: user
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Agent::valueOfAttribIs returns 1
2017-05-02 21:47:39.186 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::start 100 getGenRestart
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::getGenRestart exit GEN_RESTART:StartOption[1] }
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::start 120 comment:StartOption[1]
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Agent::valueOfAttribIs attrib: REASON compare value: failure attribute value: user
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Agent::valueOfAttribIs returns 0
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::checkState 030 new gimh oracleSid:+ASM
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Gimh::constructor ohome:/u01/app/grid/product/12.2.0/crs sid:+ASM
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::resetConnection  s_statusOfConnectionMap:0x139ea20
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::resetConnection sid +ASM status  2
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Gimh::check condition changes to (GIMH_NEXT_NUM) 0(Abnormal Termination) exists
2017-05-02 21:47:39.187 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] CLS_DRUID_REF(CLSN00006) AsmAgent::gimhChecks 100 failed gimh state 0
2017-05-02 21:47:39.188 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] (:CLSN00006:)InstAgent::checkState 110 return unplanned offline
2017-05-02 21:47:39.188 : USRTHRD:388486912: {0:0:169} Gimh::destructor gimh_dest_query_ctx rc=0
2017-05-02 21:47:39.188 : USRTHRD:388486912: {0:0:169} Gimh::destructor gimh_dest_inst_ctx rc=0
2017-05-02 21:47:39.188 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::stopConnection
2017-05-02 21:47:39.188 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::broadcastEvent 000 entry { OHSid:/u01/app/grid/product/12.2.0/crs+ASM 

s_ohSidEventMapLock:0x139e930 action:2
2017-05-02 21:47:39.188 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::removeConnection connection count 0
2017-05-02 21:47:39.188 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::removeConnection freed 0
2017-05-02 21:47:39.188 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ConnectionPool::stopConnection sid +ASM status  1
2017-05-02 21:47:39.188 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::checkState 200 prev clsagfw_res_status 3 current clsagfw_res_status 1
2017-05-02 21:47:39.188 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::start 180 startOption:StartOption[1]
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnUtils::setResAttrib nonPerX current value GEN_RESTART value StartOption[1]
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Utils::setResAttrib clsagfw_modify_attribute attr GEN_RESTART value StartOption[1] retCode 0
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::setGenRestart updating GEN_RESTART to StartOption[1] retcode:0 ohasd resource:1
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::start 200 StartInstance with startoption:1 pfile:null 
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::start 400 startInstance
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::startInstance 000 { startOption:1
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstConnection:InstConnection: init:040d5ef0 oracleHome:/u01/app/grid/product/12.2.0/crs 

oracleSid:+ASM instanceType:2 instanceVersion:12.2.0.1.0 
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnInstConnection::makeConnectStr UsrOraEnv  m_oracleHome /u01/app/grid/product/12.2.0/crs 

Crshome /u01/app/grid/product/12.2.0/crs
2017-05-02 21:47:39.189 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] clsnInstConnection::makeConnectStr = (DESCRIPTION=(ADDRESS=(PROTOCOL=beq)

(PROGRAM=/u01/app/grid/product/12.2.0/crs/bin/oracle)(ARGV0=oracle+ASM)(ENVS='ORACLE_HOME=/u01/app/grid/product/12.2.0/crs,ORACLE_SID=+ASM')(ARGS='(DESCRIPTION=

(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))')(CONNECT_DATA=(SID=+ASM))))
2017-05-02 21:47:39.191 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] Container:start oracle home /u01/app/grid/product/12.2.0/crs
2017-05-02 21:47:39.191 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstAgent::startInstance 020 connect logmode:8008
2017-05-02 21:47:39.191 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] InstConnection::connectInt 020 server not attached
2017-05-02 21:47:39.694 :  CLSDMC:357324544: command 0 failed with status 1
2017-05-02 21:47:39.695 :CLSDYNAM:357324544: [ora.evmd]{0:0:2} [check] DaemonAgent::check returned 0
2017-05-02 21:47:39.695 :CLSDYNAM:357324544: [ora.evmd]{0:0:2} [check] Deep check returned 1
2017-05-02 21:47:40.210 :CLSDYNAM:388486912: [ ora.asm]{0:0:169} [start] ORA-01017: invalid username/password; logon denied

关于ASM启动报无效用户名与密码的问题在MOS上有一篇相关文档”ASM not Starting With: ORA-01017: invalid username/password; logon denied (Doc ID 1918617.1)”,说原因是因为修改了sqlnet.ora文件,正确设置应该如下:

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

但我这里并不是这种情况,从另一篇文档”Oracle Restart – ASM Startup fails with PRCR-1079 (Doc ID 1904942.1)”找到类似的错误信息,说原因是因为ASM资源的ACL(访问控制列表)的权限发生了改变。

检查asm资源的访问控制列表权限

[grid@jytest3 dbs]$  crsctl stat res ora.asm -p
NAME=ora.asm
TYPE=ora.asm.type
ACL=owner:grid:rwx,pgrp:asmdba:r-x,other::r--
ACTIONS=
ACTION_SCRIPT=
ACTION_TIMEOUT=60
AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX%
ASM_DISKSTRING=AFD:*
AUTO_START=restore
CHECK_INTERVAL=1
CHECK_TIMEOUT=30
CLEAN_TIMEOUT=60
CSS_CRITICAL=no
DEGREE=1
DELETE_TIMEOUT=60
DESCRIPTION=Oracle ASM resource
ENABLED=1
GEN_RESTART=StartOption[1]
GEN_USR_ORA_INST_NAME=+ASM
IGNORE_TARGET_ON_FAILURE=no
INSTANCE_FAILOVER=1
INTERMEDIATE_TIMEOUT=0
LOAD=1
LOGGING_LEVEL=1
MODIFY_TIMEOUT=60
NLS_LANG=
OFFLINE_CHECK_INTERVAL=0
OS_CRASH_THRESHOLD=0
OS_CRASH_UPTIME=0
PRESENCE=standard
PWFILE=+DATA/orapwasm
PWFILE_BACKUP=
REGISTERED_TYPE=srvctl
RESOURCE_GROUP=
RESTART_ATTEMPTS=5
RESTART_DELAY=0
SCRIPT_TIMEOUT=60
SERVER_CATEGORY=
SPFILE=+DATA/ASM/ASMPARAMETERFILE/registry.253.938201547
START_CONCURRENCY=0
START_DEPENDENCIES=hard(ora.cssd) weak(ora.LISTENER.lsnr)
START_DEPENDENCIES_RTE_INTERNAL=
START_TIMEOUT=900
STOP_CONCURRENCY=0
STOP_DEPENDENCIES=hard(ora.cssd)
STOP_DEPENDENCIES_RTE_INTERNAL=
STOP_TIMEOUT=600
TARGET_DEFAULT=default
TYPE_VERSION=1.2
UPTIME_THRESHOLD=1d
USER_WORKLOAD=no
USR_ORA_ENV=
USR_ORA_INST_NAME=+ASM
USR_ORA_OPEN_MODE=mount  
USR_ORA_OPI=false
USR_ORA_STOP_MODE=immediate
WORKLOAD_CPU=0
WORKLOAD_CPU_CAP=0
WORKLOAD_MEMORY_MAX=0
WORKLOAD_MEMORY_TARGET=0

从上面的信息ACL=owner:grid:rwx,pgrp:asmdba:r-x,other::r–,可知组名(pgrp)变为了asmdba组,正常来说应该是grid用户的oinstall组,如果尝试修改:

[grid@jytest3 dbs]$ crsctl setperm resource ora.asm -g oinstall
CRS-4995:  The command 'Setperm  resource' is invalid in crsctl. Use srvctl for this command.

修改时出错了,在12.2.0.1中crsctl setperm命令是一种无效的crsctl,建议使用srvctl命令,但srvctl没有setperm命令,如是加上-unsupported参数再次执行修改:

[grid@jytest3 dbs]$ crsctl setperm resource ora.asm -g oinstall -unsupported

重启Oracle Restart,ASM实例正常启动

[grid@jytest3 lib]$ crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'jytest3'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'jytest3'
CRS-2673: Attempting to stop 'ora.evmd' on 'jytest3'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'jytest3' succeeded
CRS-2677: Stop of 'ora.evmd' on 'jytest3' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'jytest3'
CRS-2677: Stop of 'ora.cssd' on 'jytest3' succeeded
CRS-2673: Attempting to stop 'ora.driver.afd' on 'jytest3'
CRS-2677: Stop of 'ora.driver.afd' on 'jytest3' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'jytest3' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[grid@jytest3 ~]$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[grid@jytest3 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       jytest3                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest3                  STABLE
ora.asm
               ONLINE  ONLINE       jytest3                  Started,STABLE
ora.ons
               OFFLINE OFFLINE      jytest3                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.driver.afd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.evmd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.jy.db
      1        ONLINE  ONLINE       jytest3                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
--------------------------------------------------------------------------------

Oracle 12CR2 using create database command for create non-CDB rac database on Oracle Linux

在Oracle Linux7,数据库版本为12.2中使用create database来创建non-CDB数据库
1.设置实例标识符(SID)

[root@jytest1 ~]# su - oracle
Last login: Fri Apr 21 11:24:50 CST 2017
[oracle@jytest1 ~]$ export ORACLE_SID=orcl1

2.创建相关目录

ASMCMD [+data] > mkdir orcl
ASMCMD [+data] > ls
jy/
orcl/
ASMCMD [+data] > mkdir +data/orcl/CONTROLFILE
ASMCMD [+data] > mkdir +data/orcl/DATAFILE
ASMCMD [+data] > mkdir +data/orcl/ONLINELOG
ASMCMD [+data] > mkdir +data/orcl/TEMPFILE
ASMCMD [+data] > mkdir +data/orcl/PASSWORD
ASMCMD [+data] > mkdir +data/orcl/PARAMETERFILE

3.创建密码文件

[oracle@jytest1 dbs]$ orapwd file='/u01/app/oracle/product/12.2.0/db/dbs/orapworcl1'  force=y password=xxzx#7817600

4.创建参数文件,参数文件至少要包含db_name,control_files与memory_target参数

[oracle@jytest1 dbs]$ vi initorcl1.ora
db_name=orcl
control_files='+data/orcl/controlfile/control01.ctl','+data/orcl/controlfile/control02.c tl'
memory_target=1G

5.连接实例

[oracle@jytest1 dbs]$ sqlplus sys/xxzx#7817600 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Apr 19 19:15:50 2017

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

Connected to an idle instance.

6.启动实例

SQL> startup nomount pfile='/u01/app/oracle/product/12.2.0/db/dbs/initorcl1.ora'
ORACLE instance started.

Total System Global Area 1073741824 bytes
Fixed Size                  8628936 bytes
Variable Size             750781752 bytes
Database Buffers          306184192 bytes
Redo Buffers                8146944 bytes

7.创建服务器参数文件spfile

SQL>create spfile='+DATA/orcl/PARAMETERFILE/spfileorcl.ora' from pfile='/u01/app/oracle/product/12.2.0/db/dbs/initorcl1.ora';

8.执行create database语句

SQL> CREATE DATABASE orcl
  2  USER SYS IDENTIFIED BY xxzx#7817600
  3  USER SYSTEM IDENTIFIED BY xxzx#7817600
  4  LOGFILE GROUP 1 ('+data/orcl/onlinelog/redo01.log') SIZE 100M BLOCKSIZE 512,
  5  GROUP 2 ('+data/orcl/onlinelog/redo02.log') SIZE 100M BLOCKSIZE 512,
  6  GROUP 3 ('+data/orcl/onlinelog/redo03.log') SIZE 100M BLOCKSIZE 512
  7  MAXLOGHISTORY 1
  8  MAXLOGFILES 16
  9  MAXLOGMEMBERS 3
 10  MAXDATAFILES 1024
 11  CHARACTER SET ZHS16GBK
 12  NATIONAL CHARACTER SET AL16UTF16
 13  EXTENT MANAGEMENT LOCAL
 14  DATAFILE '+data/orcl/datafile/system01.dbf'
 15  SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
 16  SYSAUX DATAFILE '+data/orcl/datafile/sysaux01.dbf'
 17  SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
 18  DEFAULT TABLESPACE users
 19  DATAFILE '+data/orcl/datafile/users01.dbf'
 20  SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
 21  DEFAULT TEMPORARY TABLESPACE tempts1
 22  TEMPFILE '+data/orcl/tempfile/temp01.dbf'
 23  SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
 24  UNDO TABLESPACE undotbs1
 25  DATAFILE '+data/orcl/datafile/undotbs01.dbf'
 26  SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
 27  USER_DATA TABLESPACE usertbs
 28  DATAFILE '+data/orcl/datafile/usertbs01.dbf'
 29  SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

Database created.

9.运行脚本来创建数据字典视图
用sys用户执行以下脚本

SQL> @$ORACLE_HOME/rdbms/admin/catalog.sql

Session altered.

SQL>@$ORACLE_HOME/rdbms/admin/catproc.sql

SQL> Rem END catproc.sql

SQL>@$ORACLE_HOME/rdbms/admin/utlrp.sql

SQL> Rem END utlrp.sql

使用system用户执行以下脚本

SQL>@$ORACLE_HOME/sqlplus/admin/pupbld.sql

SQL> alter session set "_ORACLE_SCRIPT" = false;

Session altered.

10.将数据库注册为RAC数据库,在节点2配置实例orcl2的参数文件

[oracle@jytest2 dbs]$ vi initorcl2.ora
SPFILE='+DATA/orcl/PARAMETERFILE/spfileorcl.ora'

设置RAC数据库所需要的相关参数

SQL> alter system set thread=1 scope=spfile sid='orcl1';

System altered.

SQL> alter system set thread=2 scope=spfile sid='orcl2';

System altered.

SQL> alter system set instance_number=1 scope=spfile sid='orcl1';

System altered.

SQL> alter system set instance_number=2 scope=spfile sid='orcl2';

System altered.

SQL> alter system set cluster_database=true scope=sfpile sid='*';

System altered.

SQL> alter system set cluster_database_instances=2 scope=sfpile sid='*';

System altered.

添加重做线程

SQL> alter database add logfile thread 2 group 4('+data/orcl/onlinelog/redo04.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database add logfile thread 2 group 5('+data/orcl/onlinelog/redo05.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database add logfile thread 2 group 6('+data/orcl/onlinelog/redo06.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database enable thread 2;

Database altered.

向crs注册数据库

[oracle@jytest1 dbs]$ srvctl add database -db orcl -oraclehome  /u01/app/oracle/product/12.2.0/db/  -dbtype RAC -spfile  +DATA/orcl/PARAMETERFILE/spfileorcl.ora -diskgroup 'data'


[oracle@jytest1 dbs]$ srvctl add instance -db orcl -instance orcl1 -node jytest1
[oracle@jytest1 dbs]$ srvctl add instance -db orcl -instance orcl2 -node jytest2
[oracle@jytest1 dbs]$ srvctl config database -db orcl
Database unique name: orcl
Database name:
Oracle home: /u01/app/oracle/product/12.2.0/db/
Oracle user: oracle
Spfile: +DATA/orcl/PARAMETERFILE/spfileorcl.ora
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: orcl1,orcl2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

11.将密码文件存储在ASM磁盘组中

[oracle@jytest1 dbs]$ orapwd file='+data/orcl/password/pwdorcl' dbuniquename='orcl'

Enter password for SYS:

ASMCMD [+data/orcl/password] > ls -lt
Type      Redund  Striped  Time             Sys  Name
PASSWORD  UNPROT  COARSE   APR 21 11:00:00  Y    pwdorcl.294.941886275
PASSWORD  UNPROT  COARSE   APR 21 11:00:00  N    pwdorcl =>  +DATA/orcl/PASSWORD/pwdorcl.294.941886275

Enter password for SYS:
[oracle@jytest1 dbs]$ srvctl config database -db orcl
Database unique name: orcl
Database name:
Oracle home: /u01/app/oracle/product/12.2.0/db/
Oracle user: oracle
Spfile: +DATA/orcl/PARAMETERFILE/spfileorcl.ora
Password file: +DATA/orcl/password/pwdorcl
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: orcl1,orcl2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

12.检查crs状态信息

[grid@jytest2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.CRS.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.DATA.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.TEST.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.chad
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.net1.network
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.ons
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.proxy_advm
               OFFLINE OFFLINE      jytest1                  STABLE
               OFFLINE OFFLINE      jytest2                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       jytest1                  169.254.123.145 88.8
                                                             8.88.1,STABLE
ora.asm
      1        ONLINE  ONLINE       jytest1                  Started,STABLE
      2        ONLINE  ONLINE       jytest2                  Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.jy.db
      1        ONLINE  ONLINE       jytest1                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
      2        ONLINE  ONLINE       jytest2                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
ora.jytest1.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.jytest2.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       jytest1                  Open,STABLE
ora.orcl.db
      1        ONLINE  ONLINE       jytest1                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db/,STABLE
      2        ONLINE  ONLINE       jytest2                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db/,STABLE
ora.qosmserver
      1        ONLINE  INTERMEDIATE jytest1                  CHECK TIMED OUT,STAB
                                                             LE
ora.scan1.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
--------------------------------------------------------------------------------

到此操作完成!

Oracle 12CR2 RAC ORA-01033

在12C RAC中登录pdb时出现了ORA-01033错误

[oracle@jytest1 ~]$ sqlplus  hr/hr@JYPDB

SQL*Plus: Release 12.2.0.1.0 Production on Tue Apr 11 18:15:26 2017

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

ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
Process ID: 0
Session ID: 0 Serial number: 0

如是查看pdb数据库的状态,从以下信息来看pdb是正常的

[grid@jytest1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 11-APR-2017 18:03:18

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                21-MAR-2017 19:13:39
Uptime                    20 days 22 hr. 49 min. 38 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/12.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/jytest1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.171)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.175)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=jytest1.jydba.net)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/12.2.0/db/admin/jy/xdb_wallet))

(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_CRS" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_TEST" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "4b2c6373ae2547cce053ab828a0a7ca3" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
Service "jy" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
Service "jyXDB" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
Service "jypdb" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
The command completed successfully



[grid@jytest2 ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 11-APR-2017 18:16:50

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                21-MAR-2017 19:11:40
Uptime                    20 days 23 hr. 5 min. 10 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/12.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/jytest2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.172)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.176)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=jytest2.jydba.net)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/12.2.0/db/admin/jy/xdb_wallet))

(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_CRS" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_TEST" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "4b2c6373ae2547cce053ab828a0a7ca3" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
Service "jy" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
Service "jyXDB" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
Service "jypdb" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
The command completed successfully



[grid@jytest1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.CRS.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.DATA.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.TEST.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.chad
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.net1.network
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.ons
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.proxy_advm
               OFFLINE OFFLINE      jytest1                  STABLE
               OFFLINE OFFLINE      jytest2                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       jytest2                  169.254.237.250 88.8
                                                             8.88.2,STABLE
ora.asm
      1        ONLINE  ONLINE       jytest1                  Started,STABLE
      2        ONLINE  ONLINE       jytest2                  Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.jy.db
      1        ONLINE  ONLINE       jytest1                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
      2        ONLINE  ONLINE       jytest2                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
ora.jytest1.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.jytest2.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       jytest2                  Open,STABLE
ora.qosmserver
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
--------------------------------------------------------------------------------


[grid@jytest2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.CRS.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.DATA.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.TEST.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.chad
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.net1.network
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.ons
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.proxy_advm
               OFFLINE OFFLINE      jytest1                  STABLE
               OFFLINE OFFLINE      jytest2                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       jytest2                  169.254.237.250 88.8
                                                             8.88.2,STABLE
ora.asm
      1        ONLINE  ONLINE       jytest1                  Started,STABLE
      2        ONLINE  ONLINE       jytest2                  Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.jy.db
      1        ONLINE  ONLINE       jytest1                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
      2        ONLINE  ONLINE       jytest2                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
ora.jytest1.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.jytest2.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       jytest2                  Open,STABLE
ora.qosmserver
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
--------------------------------------------------------------------------------

虽然,从监听与集群资源来看是正常,但因为这里pdb数据库(jypdb)使用的服务名与pdb数据库名相同,还有就是因为是RAC数据库,因为在RAC环境中,当PDB被mount时,实例将使用pdb数据库名向SCAN与本地监听程序注册PDB,如果使用SCAN IP来登录pdb数据库,就可能将连接请求指派给PDB只被mounted的实例(没有open),如是检查pdb是否open,发现果然pdb在节点2上的实例没有被open,如是执行以下
命令:

[root@jytest2 ~]# su - oracle
Last login: Tue Apr 11 17:37:14 CST 2017
[oracle@jytest2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Apr 11 18:17:44 2017

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


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

SQL> alter session set container=jypdb;

Session altered.

SQL> alter pluggable database jypdb open;

Pluggable database altered.
[oracle@jytest1 ~]$ sqlplus  hr/hr@JYPDB

SQL*Plus: Release 12.2.0.1.0 Production on Tue Apr 11 18:18:18 2017

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


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

SQL> conn system/xxzx7817600@JYPDB
Connected.

在RAC所有节点上open pdb数据库jypdb后,登录就恢复正常了。

服务器时间异常造成ORA-00600 [2252]的故障处理

数据库服务器重启之后,检查Oracle集群资源发现四个实例启动了两个,还有两个没有启动(wu,rl)

[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.CWDATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DADATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.LISTENER.lsnr
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.OCR.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.KDATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.asm
               ONLINE  ONLINE       db1                      Started             
               ONLINE  ONLINE       db2                      Started             
ora.gsd
               OFFLINE OFFLINE      db1                                          
               OFFLINE OFFLINE      db2                                          
ora.net1.network
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.ons
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db1                                          
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       db2                                          
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       db2                                          
ora.wu.db
      1        ONLINE  OFFLINE                               Instance Shutdown   
      2        ONLINE  ONLINE       db2                      Open                
ora.dyl.db
      1        ONLINE  OFFLINE                                                   
      2        ONLINE  ONLINE       db2                      Open                
ora.cvu
      1        ONLINE  ONLINE       db2                                          
ora.da.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.db1.vip
      1        ONLINE  ONLINE       db1                                          
ora.db2.vip
      1        ONLINE  ONLINE       db2                                          
ora.oc4j
      1        ONLINE  ONLINE       db2                                          
ora.rl.db
      1        ONLINE  OFFLINE                               Instance Shutdown   
      2        ONLINE  ONLINE       db2                      Open                
ora.scan1.vip
      1        ONLINE  ONLINE       db1                                          
ora.scan2.vip
      1        ONLINE  ONLINE       db2                                          
ora.scan3.vip
      1        ONLINE  ONLINE       db2                               

查看rlzy实例的alert.log文件,可以看到以下错误信息“ORA-00600: internal error code, arguments: [2252], [3418], [573259345], [1594], [50675712]”,关于这个ORA-00600 2252在MOS上有相关bug描述,但我这并不是bug引起的,查看信息时我们也是需要关注时间的,这里时间显示为2001年1月1号了,与当前时间相差了16年2个多月。

Picked broadcast on commit scheme to generate SCNs
Mon Jan 01 08:23:50 2001
Errors in file /u01/app/oracle/diag/rdbms/rl/RL1/trace/RL1_dbw0_19789.trc  (incident=544328):
ORA-00600: internal error code, arguments: [2252], [3418], [573259345], [1594], [50675712], [], [], [], [], [], [], []
Incident details in: /u01/app/oracle/diag/rdbms/rl/RL1/incident/incdir_544216/RL1_diag_19753_i544216.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Errors in file /u01/app/oracle/diag/rdbms/rl/RL1/trace/RL1_dbw0_19789.trc:
ORA-01186: file 2 failed verification tests
ORA-00600: internal error code, arguments: [2252], [3418], [573259345], [1594], [50675712], [], [], [], [], [], [], []
DBW0 (ospid: 19789): terminating the instance due to error 1186
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Mon Jan 01 08:23:56 2001
ORA-1092 : opitsk aborting process
Mon Jan 01 08:23:56 2001

查看系统当前时间,居然变成了2001年1月1号,而且奇怪的是并不是重启时时间就被修改了,因为有两个实例在重启之后正常启动了

[root@db1 ~]# date
Mon Jan  1 08:25:34 CST 2001

手工更新为当前时间后并手动启动实例(caiwu,rlzy),就能正常启动

[root@db1 ~]# date
Fri Mar 24 11:26:44 CST 2017

[grid@db1 ~]$ srvctl start database -d caiwu

[grid@db1 ~]$ srvctl start database -d rlzy

[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.CWDATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DADATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.LISTENER.lsnr
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.OCR.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.KDATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.asm
               ONLINE  ONLINE       db1                      Started             
               ONLINE  ONLINE       db2                      Started             
ora.gsd
               OFFLINE OFFLINE      db1                                          
               OFFLINE OFFLINE      db2                                          
ora.net1.network
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.ons
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db1                                          
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       db2                                          
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       db2                                          
ora.wu.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.dyl.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.cvu
      1        ONLINE  ONLINE       db2                                          
ora.da.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.db1.vip
      1        ONLINE  ONLINE       db1                                          
ora.db2.vip
      1        ONLINE  ONLINE       db2                                          
ora.oc4j
      1        ONLINE  ONLINE       db2                                          
ora.rl.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.scan1.vip
      1        ONLINE  ONLINE       db1                                          
ora.scan2.vip
      1        ONLINE  ONLINE       db2                                          
ora.scan3.vip
      1        ONLINE  ONLINE       db2       

问题虽然解决了,但是为什么服务器会在启动两个实例后,系统时间发生改变还是不得而知,需要找浪潮服务器的工程师来检查。

Oracle ASM Renaming Disks Groups

renamedg工具可以用来改变一个磁盘组的名称。在对磁盘组执行renamedg之前,磁盘组必须在所有节点中dismounted。renamedg工具重命名磁盘组由两个阶段组成:
1.步骤一会生成一个配置文件供步骤二使用
2.步骤二会使用步骤一生成的配置文件来重命名磁盘组

renamedg的语法如下:

[grid@jyrac1 ~]$ renamedg -help
NOTE: No asm libraries found in the system

Parsing parameters..
phase                           Phase to execute, 
                                (phase=ONE|TWO|BOTH), default BOTH

dgname                          Diskgroup to be renamed

newdgname                       New name for the diskgroup

config                          intermediate config file

check                           just check-do not perform actual operation,
                                (check=TRUE/FALSE), default FALSE

confirm                         confirm before committing changes to disks,
                                (confirm=TRUE/FALSE), default FALSE

clean                           ignore errors,
                                (clean=TRUE/FALSE), default TRUE

asm_diskstring                  ASM Diskstring (asm_diskstring='discoverystring',
                                'discoverystring1' ...)

verbose                         verbose execution, 
                                (verbose=TRUE|FALSE), default FALSE

keep_voting_files               Voting file attribute, 
                                (keep_voting_files=TRUE|FALSE), default FALSE


phase=(ONE|TWO|BOTH):指定被执行的阶段。它的取值为one,two或both。这个参数是一个可选参数,它的缺省值为both。通过使用both。如果在第二个阶段出现问题,那么可以使用生成的配

置文件来重新执行two(第二个)阶段。

dgname=diskgroup:指定要被重新命名的磁盘组

newdgname=newdiskgroup:指定新磁盘组名

config=configfile:指定在第一阶段所生成的的配置文件路径或在第二阶段所使用的配置文件路径。这个参数是一个可选参数。缺省的配置文件名为renamedg_config并且它存储在执行

renamedg命令的目录中。在有些平台上配置文件可能需要使用单引号。

asm_diskstring=discoverystring,discoverystrig…:指定Oracle ASM发现字符串。如果Oracle ASM磁盘不是在操作系统的缺省位置,就必须指定asm_diskstring参数。在有些平台上配置文件可能需要使用单引号,当指定通配符时通常需要使用单引号。

clean=(true|false):指定是否容忍错误,否则将会忽略。缺省值是true。

check=(true|false):指定一个boolean值将用在第二阶段。如果为true,那么renamedg工具将打印对磁盘所使用的改变信息列表。没有写操作被执行,这是一个可选参数,缺省值为false。

confirm=(true|false):指定一个boolean值将
用在第二阶段。如果为false,那么renamedg工具将打印所执行的改变并且在实际执行改变之前进行确认。这是一个可选参数,缺省值为false。

如果check参数被设置为true,那么这个参数值是多余的。

verbose=(true|false):当verbose=true时指定verbose执行。缺省值为false。

keep_voting_files=(true|false):指定voting文件是否被保留在被重命名的磁盘组中。它的缺省值为false,它将从被重命名的磁盘组中删除voting文件。

renamedg工具不会更新集群资源,也不会更新数据库所使用的任何文件路径。因为这个原因,在完成第二阶段操作之后,原来的磁盘组资源不会自动删除。旧磁盘组资源的状态可以通过Oracle Clusterware Control(crsctl)的crsctl stat res -t命令来进行检查,并且然后使用Server Control Utility(srvctl)的srvctl remove diskgroup命令来进行删除。

下面将使用两个例子来演示renamedg工具的使用方法
1.将创建一个test磁盘组,并将test磁盘组使用带有asm_diskstring,verbose参数的renamedg命令重命名为new_test磁盘组。

SQL> create diskgroup test normal redundancy disk '/dev/raw/raw12','/dev/raw/raw13';

Diskgroup created.

SQL> select group_number,name from v$asm_diskgroup;

GROUP_NUMBER NAME
------------ ------------------------------
           1 ACFS
           2 ARCHDG
           3 CRSDG
           4 DATADG
           5 TEST

SQL> select group_number,disk_number,name,path from v$asm_disk;

GROUP_NUMBER DISK_NUMBER NAME                           PATH
------------ ----------- ------------------------------ ------------------------------
           0           3                                /dev/raw/raw14
           1           2 ACFS_0002                      /dev/raw/raw7
           5           1 TEST_0001                      /dev/raw/raw13
           5           0 TEST_0000                      /dev/raw/raw12
           4           0 DATADG_0001                    /dev/raw/raw11
           1           0 ACFS_0000                      /dev/raw/raw5
           4           3 DATADG_0000                    /dev/raw/raw10
           2           1 ARCHDG_0001                    /dev/raw/raw9
           3           1 CRSDG_0001                     /dev/raw/raw8
           1           1 ACFS_0001                      /dev/raw/raw6
           2           0 ARCHDG_0000                    /dev/raw/raw2
           4           1 DATADG_0003                    /dev/raw/raw4
           4           2 DATADG_0002                    /dev/raw/raw3
           3           0 CRSDG_0000                     /dev/raw/raw1

14 rows selected.

在两节点上将磁盘组test执行dismout

SQL> alter diskgroup test dismount;

Diskgroup altered.

SQL> alter diskgroup test dismount;

Diskgroup altered.

将磁盘组test重命名为new_test

[grid@jyrac1 ~]$ renamedg  phase=both dgname=test newdgname=new_test asm_diskstring='/dev/raw/raw*' verbose=true
NOTE: No asm libraries found in the system

Parsing parameters..

Parameters in effect:

         Old DG name       : TEST 
         New DG name          : NEW_TEST 
         Phases               :
                 Phase 1
                 Phase 2
         Discovery str        : (null) 
         Clean              : TRUE
         Raw only           : TRUE
renamedg operation: phase=both dgname=test newdgname=new_test asm_diskstring='/dev/raw/raw*' verbose=true
Executing phase 1
Discovering the group
Performing discovery with string:
Identified disk UFS:/dev/raw/raw12 with disk number:0 and timestamp (33048873 -682272768)
Identified disk UFS:/dev/raw/raw13 with disk number:1 and timestamp (33048873 -682272768)
Checking for hearbeat...
Re-discovering the group
Performing discovery with string:
Identified disk UFS:/dev/raw/raw12 with disk number:0 and timestamp (33048873 -682272768)
Identified disk UFS:/dev/raw/raw13 with disk number:1 and timestamp (33048873 -682272768)
Checking if the diskgroup is mounted or used by CSS 
Checking disk number:0
Checking disk number:1
Generating configuration file..
Completed phase 1
Executing phase 2
Looking for /dev/raw/raw12
Modifying the header
Looking for /dev/raw/raw13
Modifying the header
Completed phase 2
Terminating kgfd context 0x2b0307e120a0

检查生成的配置文件

[grid@jyrac1 ~]$ ls -lrt
total 58
-rw-r--r-- 1 grid oinstall       58 Feb  9 10:04 renamedg_config
[grid@jyrac1 ~]$ cat renamedg_config
/dev/raw/raw12 TEST NEW_TEST
/dev/raw/raw13 TEST NEW_TEST

在两节点上将命名为new_test的磁盘组执行mount操作

SQL> alter diskgroup new_test mount;

Diskgroup altered.


SQL> alter diskgroup new_test mount;

Diskgroup altered.


ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  NORMAL  N         512   4096  1048576     15360     8763             5120            1821              0             N  ACFS/
MOUNTED  NORMAL  N         512   4096  1048576     10240     2152                0            1076              0             N  ARCHDG/
MOUNTED  EXTERN  N         512   4096  1048576     10240     9842                0            9842              0             Y  CRSDG/
MOUNTED  NORMAL  N         512   4096  1048576     20480    12419             5120            3649              0             N  DATADG/
MOUNTED  NORMAL  N         512   4096  1048576     10240    10054                0            5027              0             N  NEW_TEST/

检查资源状态信息,可以看到原来的磁盘组test还存在,但处于offline状态,需要使用srvctl remove diskgroup命令将其删除

[grid@jyrac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ACFS.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ARCHDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.CRSDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.DATADG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.LISTENER.lsnr
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.NEW_TEST.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.TEST.dg
               OFFLINE OFFLINE      jyrac1                                       
               OFFLINE OFFLINE      jyrac2                                       
ora.asm
               ONLINE  ONLINE       jyrac1                   Started             
               ONLINE  ONLINE       jyrac2                   Started             
ora.gsd
               OFFLINE OFFLINE      jyrac1                                       
               OFFLINE OFFLINE      jyrac2                                       
ora.net1.network
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ons
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.registry.acfs
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jyrac1                                       
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.cvu
      1        ONLINE  ONLINE       jyrac2                                       
ora.jyrac.db
      1        ONLINE  ONLINE       jyrac1                   Open                
      2        ONLINE  ONLINE       jyrac2                   Open                
ora.jyrac1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.jyrac2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.oc4j
      1        ONLINE  ONLINE       jyrac2                                       
ora.scan1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.scan2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.scan3.vip
      1        ONLINE  ONLINE       jyrac2                       

使用srvctl remove diskgroup命令将资源ora.TEST.dg(磁盘组test)删除

[grid@jyrac1 ~]$ srvctl remove diskgroup -g test

再次检查资源状态信息,可以看到原来的磁盘组test不存在了。

[grid@jyrac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ACFS.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ARCHDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.CRSDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.DATADG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.LISTENER.lsnr
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.NEW_TEST.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.asm
               ONLINE  ONLINE       jyrac1                   Started             
               ONLINE  ONLINE       jyrac2                   Started             
ora.gsd
               OFFLINE OFFLINE      jyrac1                                       
               OFFLINE OFFLINE      jyrac2                                       
ora.net1.network
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ons
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.registry.acfs
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jyrac1                                       
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.cvu
      1        ONLINE  ONLINE       jyrac2                                       
ora.jyrac.db
      1        ONLINE  ONLINE       jyrac1                   Open                
      2        ONLINE  ONLINE       jyrac2                   Open                
ora.jyrac1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.jyrac2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.oc4j
      1        ONLINE  ONLINE       jyrac2                                       
ora.scan1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.scan2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.scan3.vip
      1        ONLINE  ONLINE       jyrac2           

2.下面的例子将new_test磁盘组使用带有asm_diskstring,verbose参数的renamedg命令分两个阶段操作重命名为test磁盘组。

只生成第二阶段操作需要的配置文件

[grid@jyrac1 ~]$ renamedg phase=one dgname=new_test newdgname=test asm_diskstring='/dev/raw/raw*' config=/home/grid/new_test.conf verbose=true
NOTE: No asm libraries found in the system

Parsing parameters..

Parameters in effect:

         Old DG name       : NEW_TEST 
         New DG name          : TEST 
         Phases               :
                 Phase 1
         Discovery str        : /dev/raw/raw* 
         Clean              : TRUE
         Raw only           : TRUE
renamedg operation: phase=one dgname=new_test newdgname=test asm_diskstring=/dev/raw/raw* config=/home/grid/new_test.conf verbose=true
Executing phase 1
Discovering the group
Performing discovery with string:/dev/raw/raw*
Identified disk UFS:/dev/raw/raw12 with disk number:0 and timestamp (33048873 -682272768)
Identified disk UFS:/dev/raw/raw13 with disk number:1 and timestamp (33048873 -682272768)
Checking for hearbeat...
Re-discovering the group
Performing discovery with string:/dev/raw/raw*
Identified disk UFS:/dev/raw/raw12 with disk number:0 and timestamp (33048873 -682272768)
Identified disk UFS:/dev/raw/raw13 with disk number:1 and timestamp (33048873 -682272768)
Checking if the diskgroup is mounted or used by CSS 
Checking disk number:0
KFNDG-00405: file not found; arguments: [NEW_TEST]

出现了KFNDG-00405错误,这是因为在执行renamedg操作之前忘记了将磁盘组new_test在所有节点上执行dismount

在两节点上将磁盘组new_test执地dismount

SQL> alter diskgroup new_test dismount;

Diskgroup altered.


SQL> alter diskgroup new_test dismount;

Diskgroup altered.

Terminating kgfd context 0x2b34496f80a0
[grid@jyrac1 ~]$ renamedg phase=one dgname=new_test newdgname=test asm_diskstring='/dev/raw/raw*' config=/home/grid/new_test.conf verbose=true
NOTE: No asm libraries found in the system

Parsing parameters..

Parameters in effect:

         Old DG name       : NEW_TEST 
         New DG name          : TEST 
         Phases               :
                 Phase 1
         Discovery str        : /dev/raw/raw* 
         Clean              : TRUE
         Raw only           : TRUE
renamedg operation: phase=one dgname=new_test newdgname=test asm_diskstring=/dev/raw/raw* config=/home/grid/new_test.conf verbose=true
Executing phase 1
Discovering the group
Performing discovery with string:/dev/raw/raw*
Identified disk UFS:/dev/raw/raw12 with disk number:0 and timestamp (33048873 -682272768)
Identified disk UFS:/dev/raw/raw13 with disk number:1 and timestamp (33048873 -682272768)
Checking for hearbeat...
Re-discovering the group
Performing discovery with string:/dev/raw/raw*
Identified disk UFS:/dev/raw/raw12 with disk number:0 and timestamp (33048873 -682272768)
Identified disk UFS:/dev/raw/raw13 with disk number:1 and timestamp (33048873 -682272768)
Checking if the diskgroup is mounted or used by CSS 
Checking disk number:0
Checking disk number:1
Generating configuration file..
Completed phase 1
Terminating kgfd context 0x2b1c202a80a0

执行重命名磁盘组的第二阶段操作

[grid@jyrac1 ~]$ renamedg phase=two dgname=new_test newdgname=test config=/home/grid/new_test.conf verbose=true
NOTE: No asm libraries found in the system

Parsing parameters..

Parameters in effect:

         Old DG name       : NEW_TEST 
         New DG name          : TEST 
         Phases               :
                 Phase 2
         Discovery str        : (null) 
         Clean              : TRUE
         Raw only           : TRUE
renamedg operation: phase=two dgname=new_test newdgname=test config=/home/grid/new_test.conf verbose=true
Executing phase 2
Looking for /dev/raw/raw12
Modifying the header
Looking for /dev/raw/raw13
Modifying the header
Completed phase 2
Terminating kgfd context 0x2b8da14950a0

检查磁盘组new_test是否成功被重命名为test

SQL> select group_number,name from v$asm_diskgroup;

GROUP_NUMBER NAME
------------ ------------------------------
           1 ACFS
           2 ARCHDG
           3 CRSDG
           4 DATADG
           0 TEST

在两节点上将磁盘组test执行mount操作

SQL> alter diskgroup test mount;

Diskgroup altered.


SQL> alter diskgroup test mount;

Diskgroup altered.

ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  NORMAL  N         512   4096  1048576     15360     8763             5120            1821              0             N  ACFS/
MOUNTED  NORMAL  N         512   4096  1048576     10240     1958                0             979              0             N  ARCHDG/
MOUNTED  EXTERN  N         512   4096  1048576     10240     9842                0            9842              0             Y  CRSDG/
MOUNTED  NORMAL  N         512   4096  1048576     20480    12419             5120            3649              0             N  DATADG/
MOUNTED  NORMAL  N         512   4096  1048576     10240    10054                0            5027              0             N  TEST/

检查资源状态信息,可以看到原磁盘组new_test还存在,但为offline状态,重命名后的磁盘组test状态为online

                              
[grid@jyrac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ACFS.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ARCHDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.CRSDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.DATADG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.LISTENER.lsnr
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.NEW_TEST.dg
               OFFLINE OFFLINE      jyrac1                                       
               OFFLINE OFFLINE      jyrac2                                       
ora.TEST.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.asm
               ONLINE  ONLINE       jyrac1                   Started             
               ONLINE  ONLINE       jyrac2                   Started             
ora.gsd
               OFFLINE OFFLINE      jyrac1                                       
               OFFLINE OFFLINE      jyrac2                                       
ora.net1.network
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ons
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.registry.acfs
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jyrac1                                       
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.cvu
      1        ONLINE  ONLINE       jyrac2                                       
ora.jyrac.db
      1        ONLINE  ONLINE       jyrac1                   Open                
      2        ONLINE  ONLINE       jyrac2                   Open                
ora.jyrac1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.jyrac2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.oc4j
      1        ONLINE  ONLINE       jyrac2                                       
ora.scan1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.scan2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.scan3.vip
      1        ONLINE  ONLINE       jyrac2                  

将原来的磁盘组new_test从资源信息中删除

[grid@jyrac1 ~]$ srvctl remove diskgroup -g new_test

再将检查资源状态信息,可以看到原磁盘组new_test不存在了

[grid@jyrac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ACFS.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ARCHDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.CRSDG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.DATADG.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.LISTENER.lsnr
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.TEST.dg
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.asm
               ONLINE  ONLINE       jyrac1                   Started             
               ONLINE  ONLINE       jyrac2                   Started             
ora.gsd
               OFFLINE OFFLINE      jyrac1                                       
               OFFLINE OFFLINE      jyrac2                                       
ora.net1.network
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.ons
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
ora.registry.acfs
               ONLINE  ONLINE       jyrac1                                       
               ONLINE  ONLINE       jyrac2                                       
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jyrac1                                       
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jyrac2                                       
ora.cvu
      1        ONLINE  ONLINE       jyrac2                                       
ora.jyrac.db
      1        ONLINE  ONLINE       jyrac1                   Open                
      2        ONLINE  ONLINE       jyrac2                   Open                
ora.jyrac1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.jyrac2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.oc4j
      1        ONLINE  ONLINE       jyrac2                                       
ora.scan1.vip
      1        ONLINE  ONLINE       jyrac1                                       
ora.scan2.vip
      1        ONLINE  ONLINE       jyrac2                                       
ora.scan3.vip
      1        ONLINE  ONLINE       jyrac2                        

Oracle Find block in ASM

为了更容易的从ASM定位与抽取Oracle数据文件,可以创建一个Perl脚本find_block.pl来自动进行处理,只需要提供数据文件名与块号。脚本find_block.pl是一个Perl脚本,它由dd或kfed命令组成。它可以与所有的Linux和Unix ASM版本与单实例的ASM或RAC环境中使用。

这个脚本必须以ASM/Grid Infrastructure用户来执行,在RAC环境中,脚本可以在任何一个节点上执行,在运行脚本之前,设置ASM环境变量并且确保ORACLE_SID,ORACLE_HOME,LD_LIBRARY_PATH等等设置正确。对于ASM 10g与11gr1来说,也可以设置环境变量PERL5LIB,比如:

export PERL5LIB=$ORACLE_HOME/perl/lib/5.8.3:$ORACLE_HOME/perl/lib/site_perl

运行脚本例子如下:

$ORACLE_HOME/perl/bin/perl find_block.pl filename block

命令中的filename是指要抽取的数据块所在文件的文件名。对于数据文件,文件名可以通过在数据库实例上执行select name from v$datafile来获得。block是要从ASM中抽取数据块的块号

输出结果类似如:

dd if=[ASM disk path] ... of=block_N.dd

或Exadata中的

kfed read dev=[ASM disk path] ... > block_N.txt

如果磁盘组是外部冗余,这个脚本将生成单个命令。对于normal冗余磁盘组文件来说,这个脚本将生成两个命令,对于high冗余磁盘组文件来说,这个脚本将生成三个命令。

下面将对于oracle 10g rac来通过find_block.pl脚来从ASM中抽取数据块

SQL> select name from v$tablespace;

NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
EXAMPLE
UNDOTBS2
YB
TEST

9 rows selected.

SQL> create table t1 (name varchar2(16)) tablespace TEST;

Table created.

SQL> insert into t1 values ('CAT');

1 row created.

SQL> insert into t1 values ('DOG');

1 row created.

SQL> commit;

Commit complete.

SQL> select rowid,name from t1;

ROWID              NAME
------------------ ----------------
AAAN8qAAIAAAAAUAAA CAT
AAAN8qAAIAAAAAUAAB DOG

SQL> select dbms_rowid.rowid_block_number('AAAN8qAAIAAAAAUAAA') "block" from dual;

     block
----------
        20

SQL> select t.name "Tablespace", f.name "Datafile" from v$tablespace t, v$datafile f where t.ts#=f.ts# and t.name='TEST';

Tablespace                     Datafile
------------------------------ --------------------------------------------------
TEST                           +DATADG/test/datafile/test.269.930512093

切换到ASM环境,设置PERL5LIB,运行脚本

[oracle@jyrac3 bin]$ export ORACLE_SID=+ASM1
[oracle@jyrac3 bin]$ export PERL5LIB=$ORACLE_HOME/perl/lib/5.8.3:$ORACLE_HOME/perl/lib/site_perl

[oracle@jyrac3 bin]$ $ORACLE_HOME/perl/bin/perl find_block.pl +DATADG/test/datafile/test.269.930512093 20
dd if=/dev/raw/raw3 bs=8192 count=1 skip=266260 of=block_20.dd
dd if=/dev/raw/raw4 bs=8192 count=1 skip=266260 of=block_20.dd

从上面的输出可以看到指定的文件是normal冗余,脚本生成了两个dd命令,下面我们来运行:

[root@jyrac3 ~]# dd if=/dev/raw/raw3 bs=8192 count=1 skip=266260 of=block_20.dd
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 0.00608323 seconds, 1.3 MB/s

下面查看block_20.dd文件的内容,使用od工具,我们可以看到插入表中的数据:

[root@jyrac3 ~]# od -c block_20.dd | tail -3
0017740   S   O   R   T   =   '   B   I   N   A   R   Y   '  \b   , 001
0017760 001 003   D   O   G   , 001 001 003   C   A   T 001 006  \r 203
0020000

可以看到DOG与CAT

Example with ASM version 12.1.0.1 in Exadata
在Exadata中,不可以使用dd命令来抽取数据块,因为磁盘对数据库服务器不可见。为了得到数据库的数据块,可以使用kfed工具,因为find_block.pl将由kfed命令组成。


$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on [date]

SQL> alter pluggable database BR_PDB open;

Pluggable database altered.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE   RESTRICTED
------ -------- ----------- ----------
       2 PDB$SEED READ ONLY   NO
...
       5 BR_PDB   READ WRITE  NO

SQL>

$ sqlplus bane/welcome1@BR_PDB

SQL*Plus: Release 12.1.0.1.0 Production on [date]

SQL> create table TAB1 (n number, name varchar2(16)) tablespace USERS;

Table created.

SQL> insert into TAB1 values (1, 'CAT');

1 row created.

SQL> insert into TAB1 values (2, 'DOG');

1 row created.

SQL> commit;

Commit complete.

SQL> select t.name "Tablespace", f.name "Datafile"
from v$tablespace t, v$datafile f
where t.ts#=f.ts# and t.name='USERS';

Tablespace Datafile
---------- ---------------------------------------------
USERS      +DATA/CDB/054.../DATAFILE/users.588.860861901

SQL> select ROWID, NAME from TAB1;

ROWID              NAME
------------------ ----
AAAWYEABfAAAACDAAA CAT
AAAWYEABfAAAACDAAB DOG

SQL> select DBMS_ROWID.ROWID_BLOCK_NUMBER('AAAWYEABfAAAACDAAA') "Block number" from dual;

Block number
------------
       131

SQL>

切换到ASM环境执行脚本

$ $ORACLE_HOME/perl/bin/perl find_block.pl +DATA/CDB/0548068A10AB14DEE053E273BB0A46D1/DATAFILE/users.588.860861901 131
kfed read dev=o/192.168.1.9/DATA_CD_03_exacelmel05 ausz=4194304 aunum=16212 blksz=8192 blknum=131 | grep -iv ^kf > block_131.txt
kfed read dev=o/192.168.1.11/DATA_CD_09_exacelmel07 ausz=4194304 aunum=16267 blksz=8192 blknum=131 | grep -iv ^kf > block_131.txt

注意find_block.pl将生成两个脚本,数据文件是normal冗余,执行以下命令:

$ kfed read dev=o/192.168.1.9/DATA_CD_03_exacelmel05 ausz=4194304 aunum=16212 blksz=8192 blknum=131 | grep -iv ^kf > block_131.txt
$

检查block_131文件的内容,可以看到DOG与CAT

$ more block_131.txt
...
FD5106080 00000000 00000000 ...  [................]
      Repeat 501 times
FD5107FE0 00000000 00000000 ...  [........,......D]
FD5107FF0 012C474F 02C10202 ...  [OG,......CAT..,-]
$

Find any block
find_block.pl脚本可以用来从存储在ASM中的任何文件抽取数据块。执行下面的命令来抽取控制文件与随机数据块

$ $ORACLE_HOME/perl/bin/perl find_block.pl +DATA/CDB/CONTROLFILE/current.289.843047837 5
kfed read dev=o/192.168.1.9/DATA_CD_10_exacelmel05 ausz=4194304 aunum=73 blksz=16384 blknum=5 | grep -iv ^kf > block_5.txt
kfed read dev=o/192.168.1.11/DATA_CD_01_exacelmel07 ausz=4194304 aunum=66 blksz=16384 blknum=5 | grep -iv ^kf > block_5.txt
kfed read dev=o/192.168.1.10/DATA_CD_04_exacelmel06 ausz=4194304 aunum=78 blksz=16384 blknum=5 | grep -iv ^kf > block_5.txt
$

可以看到脚本显示了正确的控制文件块大小(16K),并且生成三个不同的命令。当磁盘组data是normal冗余磁盘组时,控制文件会为high冗余(ASM中控制文件缺省为冗余)。

小结:
find_block.pl是perl脚本,它由dd或kfed命令组成用来从ASM中的文件中抽取数据块。在大多数情况下我们想要从数据文件中抽取数据块,但脚本也能从控制文件,重做日志或任何其它文件中抽取数据块。

如果文件存储在外部冗余磁盘组中,那么脚本将会生成单个命令,这可以用来从ASM磁盘中抽取数据块。

如果文件存储在normal冗余磁盘组,那么脚本将会生成两个命令,它们用来从两个不同的ASM磁盘来抽取数据块(相同副本)。

如果文件存储在high冗余磁盘组,那么脚本将会生成三个命令。

Oracle ASM REQUIRED_MIRROR_FREE_MB

REQUIRED_MIRROR_FREE_MB与USABLE_FILE_MB是V$ASM_DISKGROUP[_STAT]视图中两个非常有意义的列。关于这两个字段有很多问题与及如何计算它们。

How much space can I use
ASM不能阻止你使用外部冗余磁盘组的所有可用空间,normal冗余磁盘组总空间的一半,high冗余磁盘组总空间的三分之一。但如果你想填满磁盘组直到溢出,使它没有足够空间来增长或增加任何文件,在磁盘故障情况下,直到故障磁盘被替换与rebalance操作完成之前,将没有空间来还原一些数据的冗余.

11gr2 ASM in Exadata
在Exadata ASM 11gr2中,required_mirror_free_mb作为磁盘组中的最大故障组的大小被显示。下面是Exadata中的11.2.0.4 ASM的例子进行说明。

[grid@exadb01 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on [date]

SQL> select NAME, GROUP_NUMBER from v$asm_diskgroup_stat;

NAME      GROUP_NUMBER
--------- ------------
DATA                 1
DBFS_DG              2
RECO                 3

SQL>

下面将查看磁盘组DBFS_DG。正常来说对于磁盘组DBFS_DG的每个故障组有10块磁盘。为了说明REQUIRED_MIRROR_FREE_MB对于最大故障组所显示的大小删除了几块磁盘。

SQL> select FAILGROUP, count(NAME) "Disks", sum(TOTAL_MB) "MB"
from v$asm_disk_stat
where GROUP_NUMBER=2
group by FAILGROUP
order by 3;

FAILGROUP       Disks         MB
---------- ---------- ----------
EXACELL04           7     180096
EXACELL01           8     205824
EXACELL02           9     231552
EXACELL03          10     257280

SQL>

可以看到最大故障组中的总空间大小为257280MB。

最后我们来查看最大故障组的required_mirror_free_mb大小

SQL> select NAME, TOTAL_MB, FREE_MB, REQUIRED_MIRROR_FREE_MB, USABLE_FILE_MB
from v$asm_diskgroup_stat
where GROUP_NUMBER=2;

NAME         TOTAL_MB    FREE_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB
---------- ---------- ---------- ----------------------- --------------
DBFS_DG        874752     801420                  257280         272070

ASM计算USABLE_FILE_MB使用以下公式:

USABLE_FILE_MB=(FREE_MB-REQUIRED_MIRROR_FREE_MB)/2
              =(801420-257280)/2=544140/2=272070 

Exadata with ASM version 12cR1
在使用ASM 12cr1的exadata中,required_mirror_free_mb作为磁盘组中最大的大小被显示

[grid@exadb03 ~]$ sqlplus / as sysasm

SQL*Plus: Release 12.1.0.2.0 Production on [date]

SQL> select NAME, GROUP_NUMBER from v$asm_diskgroup_stat;

NAME     GROUP_NUMBER
-------- ------------
DATA                1
DBFS_DG             2
RECO                3

SQL> select FAILGROUP, count(NAME) "Disks", sum(TOTAL_MB) "MB"
from v$asm_disk_stat
where GROUP_NUMBER=2
group by FAILGROUP
order by 3;

FAILGROUP       Disks         MB
---------- ---------- ----------
EXACELL05           8     238592
EXACELL07           9     268416
EXACELL06          10     298240

最大故障组中的总空间为298240MB,但这时required_mirror_free_mb显示的大小为29824MB。

SQL> select NAME, TOTAL_MB, FREE_MB, REQUIRED_MIRROR_FREE_MB, USABLE_FILE_MB
from v$asm_diskgroup_stat
where GROUP_NUMBER=2;  2    3

NAME         TOTAL_MB    FREE_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB
---------- ---------- ---------- ----------------------- --------------
DBFS_DG        805248     781764                   29824         375970

下面查看磁盘组中最大磁盘的大小

SQL> select max(TOTAL_MB) from v$asm_disk_stat where GROUP_NUMBER=2;

MAX(TOTAL_MB)
-------------
        29824

ASM计算usable_file_mb的公式如下:

USABLE_FILE_MB = (FREE_MB - REQUIRED_MIRROR_FREE_MB) / 2
               =(781764-29824)/2=375970

小结:
required_mirror_free_mb与usable_file_mb用来帮助dba与存储管理员来规划磁盘组容量与冗余。这只是一个报告,ASM并不执行。在ASM为12cr1的exadata中,required_mirror_free_mb的大小就是磁盘组中最大磁盘的大小。通过这种设计,从这个字段就能反映出实践经验,它显示了磁盘出现故障,而不是整个存储单元。

Oracle ASM Disk Group Attributes

磁盘组属性是在ASM 11.1中引入的,它们属于磁盘组,不是属于ASM实例。有一些属性只能在磁盘组创建时设置,有一些只能在磁盘组创建之后设置,而有些属性可以在任何时候设置。

ACCESS_CONTROL.ENABLED
这个属性决定了对磁盘组是否启用ASM文件访问控制。它的参数值可以设置为TRUE或FALSE(缺省值)。如果属性被设置为TRUE,访问ASM文件受制于访问控制。如果为FALSE,任何用户都可以访问磁盘组中的文件。所有其它操作不依赖这个属性。这个属性只能在执行修改磁盘组时才能设置。

ACCESS_CONTROL.UMASK
这个属性决定了那些权限掩盖了创建ASM文件的所有者,组与用户组中的其它信息。这个属性应用于磁盘组中的所有文件。这个属性值可以是三个数字的组合 {0|2|6} {0|2|6} {0|2|6},缺省值是066。设置为’0’表示不掩盖任何信息。设置为’2’掩盖写权限,设置为’6’掩盖读写权限。在设置ACCESS_CONTROL.UMASK磁盘组属性之前,ACCESS_CONTROL.ENABLED必须被设置为TRUE。

AU_SIZE
这个属性控制着AU大小并且只能在创建磁盘组时进行设置。每个磁盘组可以有不同的AU大小。

CELL.SMART_SCAN_CAPABLE[Exadata]
这个属性在exadata中对storage cells中的grid disks创建磁盘组时使用。它能对存储在磁盘组中的对象启用smart scan功能。

COMPATIBLE.ASM
磁盘组的compatible.asm属性决定了可以使用这些磁盘组的ASM实例的最低软件版本。这个设置也会影响ASM元数据结构的格式。compatible.asm的缺省值为10.1,当使用create diskgroup语句时,ASMCMD的mkdg命令与EM的Create Disk Group page时会使用。当使用ASMCA创建磁盘组时,在ASM 11gr2中它的缺省值为11.2,在ASM 12c中它的缺省值为12.1。

COMPATIBLE.RDBMS
这个属性决定了使用磁盘组的任何数据库实例的compatible参数的最小值。在推进compatible.rdbms属性之前,确保访问磁盘组的所有数据库的compatible参数被设置为新的compatible.rdbms所允许的最小值。

COMPATIBLE.ADVM
这个属性值决定了是否磁盘组可以创建ASM卷。这个属性必须设置为11.2或更高版本。在设置这个属性之前,compatible.asm值必须被设置为11.2或更高版本,ADVM卷驱动必须被加载到所支持的环境中。缺省情况下,compatible.advm属性为空。

CONTENT.CHECK[12c]
当对磁盘组执行rebalance时,这个属性决定了是否启用或禁用内容检查。这个属性可以设置为TRUE或FALSE。内容检查包括对用户数据的硬件辅助弹性数据(HARD)检查,验证文件目录中的文件类型,文件目录信息与镜像比较。当这个属性设置为TRUE时,会对所有rebalance操作执行内容检查。内容检查也可以当作磁盘清除功能。

CONTENT.TYPE[11.2.0.3,Exadata]
这个属性标识磁盘组类型,它可以是DATA,RECOVERY或SYSTEM。它决定了最近的伙伴磁盘/故障磁盘组的距离。缺省值是DATA,它指定了距离为1,RECOVERY指定距离为3,SYSTEM指定距离为5。距离为1,意味着ASM会将所有磁盘考虑为伙伴关系。距离为3意味着每3个磁盘将被考虑为伙伴关系,距离为5意味着每5个磁盘将考虑为伙伴关系。

这个属性可以在创建或修改磁盘组时可以设置。如果content.type属性被设置或使用alter diskgroup被改变,新的配置直到磁盘组rebalance显式完成之前不会生效。

content.type属性只对normal与high冗余磁盘组有效。compatible.asm属性必须被设置为11.2.0.3或更高版本来启用content.type属性。

DISK_REPAIR_TIME
DISK_REPAIR_TIME属性决定了在磁盘删除之前,ASM将其它保持脱机状态的时间。这个属性与快速镜像重新同步功能相关,并且compatible.asm属性必须设置为11.1或更高版本。而且只能在修改磁盘组时才能设置。

FAILGROUP_REPAIR_TIME[12c]
这个属性指定了磁盘组中的故障磁盘组的缺省修复时间。故障磁盘组的修复时间在ASM判断整个故障磁盘组出现故障时会被用到。它的缺省值是24小时。如果对磁盘指定了修复时间,比如执行alter diskgroup offline disk drop after语句,那么磁盘修复时间将会覆盖故障磁盘组的修复时间。

这个属性只能对normal与high冗余磁盘组执行修改时进行设置。

IDP.BOUNDARY and IDP.TYPE[Exadata]
这两个属性被用来配置Exadata存储,并且与智能数据存储功能相关。

PHYS_META_REPLICATED[12c]
这个属性用来跟踪磁盘组的复制状态。当一个磁盘组的ASM的compatible被设置为12.1或更高版本时,每块磁盘的物理元数据会被复制。这些元数据包含磁盘头,可用空间表块与分配表块。复制操作是以联机异步方式执行。这个属性值被设置为true时,磁盘组中的每个磁盘中的物理元数据会被复制。

这个属性只能在compatible.asm被设置为12.1或更高版本才能对磁盘组进行定义。这个属性是只读状态并且用户不能设置或修改它。它的参数值为true或false。

SECTOR_SIZE
这个属性指定磁盘组中磁盘的sector size,并且只能在创建磁盘组时设置。SECTOR_SIZE的值可以是512,4094或4K(提供的磁盘支持这些参数值)。缺省值依赖于平台。compatible.asm与compatible.rdbms属性必须被设置为11.2或更高版本才能将sector size设置为非缺省值。ACFS不支持4KB的sector驱动。

STORAGE.TYPE
这个属性指定了磁盘组中的磁盘类型。它的参数值有:exadata,pillar,zfsas与other。如果属性被设置为exadata|pillar|zfsas,那么磁盘组中的所有磁盘必须是这种类型。如果属性被设置为other,磁盘组中的磁盘的类型可以是任何类型。

如果storage.type磁盘组属性被设置为pillar或zfsas,Hybrid Columnar Compression(HCC)混合列压缩功能可以对磁盘组中的对象启用。Exadata支持HCC。

注意:ZFS存储必须通过Direct NFS(dNFS)提供来使用,Pillar Axiom存储必须通过SCSI或光纤通道接口提供来使用。

为了设置storage.type属性,compatible.asm与compatible.rdbms磁盘组属性必须设置为11.2.0.3或更高版本。为了对ZFS存储提供最大化支持,将compatible.asm与compatible.rdbms磁盘组属性设置为11.2.0.4或更高版本。

storage.type属性可以在创建或修改磁盘组时进行设置。当客户端连接到磁盘组时不能进行设置。例如,当磁盘组使用ADVM卷时,这个属性不能进行设置。

这个属性在v$asm_attribute视图或ASMCMD lsattr命令中直到它被设置之前是不可见的。

THIN_PROVISIONED[12c]
这个属性在磁盘组完成rebalance操作之后用来启用或禁用丢弃没有使用的空间。这个属性值可以设置为true或false(缺省值)

存储厂商产品支持thin provisioning的能力来更用效率的重用丢弃的存储空间

APPLIANCE.MODE[11.2.0.4,Exadatga]
APPLIANCE.MODE属性提供了在删除一个或多个ASM磁盘时,磁盘rebalance完成时间。这意味着在磁盘故障后冗余会被快速还原。当在Exadata中创建新磁盘组时这个属性会自动被启用。现有磁盘组必须使用alter diskgroup命令来显式设置。这个功能叫作固定伙伴。

这个属性在满足以下条件时可以对磁盘组启用:
Oracle ASM磁盘组属性compatible.asm被设置为11.2.0.4或更高版本,CELL.SMART_SCAN_CAPABLE属性被设置为TRUE。磁盘组中的所有磁盘是相同的磁盘类型,比如都是磁盘或闪存磁盘。磁盘组中的所有磁盘是相同大小。磁盘组中的所有故障组有相同磁盘数。磁盘组中没有磁盘脱机。

最小化软件:Oracle Exadata Storage Server Software release 11.2.3.3 运行Oracle Database 11g Release 2(11.2) release 11.2.0.4

注意:这个功能在Oracle Database version 12.1.0.1中不可用。

Hidden disk group attributes

_REBALANCE_COMPACT
这个属性与rebalance的compacting阶段有关。这个属性可以为TRUE(缺省值)或FALSE。将这个属性设置为FALSE,会对磁盘组的rebalance禁用compacting阶段。

_EXTENT_COUNTS
_EXTENT_COUNTS这个属性,与可变区大小有关,它决定了那个区大小将会增加。这个属性的值为”20000 20000 214748367″,这意味着前20000个区大小将是1个AU,接下来的20000区大小将由_extent_sizes属性的第二个值决定,并且剩余的区大小将由_extent_sizes的第三个值决定。

_EXTENT_SIZES
这个属性是与可变区大小有关的第二个隐藏参数,并且它决定了区大小的增长,也就是AU的数量。

在ASM 11.1中,属性值为”1 8 64″。在ASM 11.2与以后版本中,属性值为”1 4 16″。

v$asm_attribute视图与ASMCMD lsattr命令
磁盘组属性可以通过v$asm_attribute视图与asmcmd lsattr命令。

下面是显示磁盘组DATADG属性的一种方法:

[grid@jyrac1 ~]$ asmcmd lsattr -G DATADG -l
Name                     Value       
access_control.enabled   FALSE       
access_control.umask     066         
au_size                  1048576     
cell.smart_scan_capable  FALSE       
compatible.asm           11.2.0.0.0  
compatible.rdbms         11.2.0.0.0  
disk_repair_time         3.6h        
sector_size              512         

磁盘组属性可以通过alter diskgroup set attribute语句,ASMCMD setattr命令与ASMCA来进行修改。下面是使用ASMCMD setattr命令来修改disk_repair_time属性的一个例子:

[grid@jyrac1 ~]$ asmcmd setattr -G DATADG disk_repair_time '4.5 H'

检查新属性:

[grid@jyrac1 ~]$ asmcmd lsattr -G DATADG -l disk_repair_time
Name              Value  
disk_repair_time  4.5 H  

小结:
磁盘组属性,在ASM 11.1中引入,它是优化磁盘组能力的一种很好方式。有些属性是Exadata特定的,有些只能在特定版本中使用。大多数磁盘组属性可以通过v$asm_attribute视图来查看。

查询