asmcmd中cp文件的测试

联系:QQ(5163721)

标题:asmcmd中cp文件的测试

作者:Lunar©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.]

[grid@lunar ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Fri Aug 9 15:59:23 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 – 64bit Production
With the Automatic Storage Management option

SQL> set pages 999
SQL> set linesize 122
SQL> select group_number, name, state, type, total_mb/1024 total_gb, free_mb/1024 free_gb, offline_disks from gv$asm_diskgroup;

GROUP_NUMBER NAME                           STATE       TYPE     TOTAL_GB    FREE_GB OFFLINE_DISKS
———— —————————— ———– —— ———- ———- ————-
2 RECO                           MOUNTED     EXTERN          5 4.71386719             0
1 DATA                           MOUNTED     EXTERN         10 3.58300781             0

SQL>
[oracle@lunar ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Fri Aug 9 15:41:32 2013

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

Connected to an idle instance.

SQL>
SQL> show parameter db_create_file_dest

NAME                                 TYPE        VALUE
———————————— ———– ——————————
db_create_file_dest                  string      +DATA
SQL>
SQL> create tablespace lunartest datafile size 10M;

Tablespace created.

SQL> set pages 999
SQL> select file#,name,(bytes/1024/1024)MB from v$datafile;

FILE# NAME                                                            MB
———- ——————————————————- ———-
1 +DATA/LUNARBB/DATAFILE/system.261.818251295                    790
2 +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE        260
/system.262.818251355

3 +DATA/LUNARBB/DATAFILE/sysaux.263.818251381                    820
4 +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE        675
/sysaux.264.818251441

5 +DATA/LUNARBB/DATAFILE/undotbs1.265.818251465                  675
6 +DATA/LUNARBB/DATAFILE/users.268.818251547                       5
7 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE        260
/system.270.818261387

8 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE        705
/sysaux.271.818261387

9 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE          5
/users.273.818261503

10 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE        260
/system.275.819174909

11 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE        705
/sysaux.276.819174909

12 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE          5
/users.274.819174909

30 +DATA/LUNARBB/DATAFILE/lunartest.281.823017791                  10

13 rows selected.

SQL> alter system switch logfile;

System altered.

SQL> alter database datafile 30 offline;

Database altered.

SQL>

跟踪一下,看看它到底怎么来cp的,o(∩_∩)o 哈哈

ASMCMD> cp +DATA/LUNARBB/DATAFILE/lunartest.281.823017791 +RECO/LUNARBB/lunartest.dbf
    <- prepare(‘/* ASMCMD */ select group_number, state from v$asm_diskgroup_stat where name=’DATA”)= ( DBI::st=HASH(0x33e2a68) ) [1 items] at asmcmdshare.pm line 3003
    <- execute= ( ‘0E0’ ) [1 items] at asmcmdshare.pm line 3022
<- fetchrow_hashref= ( HASH(0x33e27f8)2keys ) [1 items] row1 at asmcmdshare.pm line 3055
<- finish= ( 1 ) [1 items] at asmcmdshare.pm line 3076
<- DESTROY(DBI::st=HASH(0x33f3648))= ( undef ) [1 items] at asmcmdshare.pm line 1633
   <- prepare(‘/* ASMCMD */ select reference_index from v$asm_alias where group_number=1 and parent_index=16777216 and upper(name)=’LUNARBB”)= ( DBI::st=HASH(0x33e2a20) ) [1 items] at asmcmdshare.pm line 3003
   
<- execute= ( ‘0E0’ ) [1 items] at asmcmdshare.pm line 3022
<- fetchrow_hashref= ( HASH(0x33e2708)1keys ) [1 items] row1 at asmcmdshare.pm line 3055
<- finish= ( 1 ) [1 items] at asmcmdshare.pm line 3076
<- DESTROY(DBI::st=HASH(0x33e2a80))= ( undef ) [1 items] at asmcmdshare.pm line 1469
   <- prepare(‘/* ASMCMD */ select reference_index from v$asm_alias where group_number=1 and parent_index=16777428 and upper(name)=’DATAFILE”)= ( DBI::st=HASH(0x33e28e8) ) [1 items] at asmcmdshare.pm line 3003
    <- execute= ( ‘0E0’ ) [1 items] at asmcmdshare.pm line 3022
<- fetchrow_hashref= ( HASH(0x33e26d8)1keys ) [1 items] row1 at asmcmdshare.pm line 3055
<- finish= ( 1 ) [1 items] at asmcmdshare.pm line 3076
<- DESTROY(DBI::st=HASH(0x33e29a8))= ( undef ) [1 items] at asmcmdshare.pm line 1469
<- prepare(‘/* ASMCMD */ select reference_index from v$asm_alias where group_number=1 and parent_index=16777587 and upper(name)=’LUNARTEST.281.823017791”)= ( DBI::st=HASH(0x33e2990) ) [1 items] at asmcmdshare.pm line 3003
    <- execute= ( ‘0E0’ ) [1 items] at asmcmdshare.pm line 3022
<- fetchrow_hashref= ( HASH(0x33e26c0)1keys ) [1 items] row1 at asmcmdshare.pm line 3055
<- finish= ( 1 ) [1 items] at asmcmdshare.pm line 3076
<- DESTROY(DBI::st=HASH(0x33e2978))= ( undef ) [1 items] at asmcmdshare.pm line 1469
<- prepare(‘/* ASMCMD */ select group_number, state from v$asm_diskgroup_stat where name=’RECO”)= ( DBI::st=HASH(0x33e2810) ) [1 items] at asmcmdshare.pm line 3003
    <- execute= ( ‘0E0’ ) [1 items] at asmcmdshare.pm line 3022
<- fetchrow_hashref= ( HASH(0x33e2678)2keys ) [1 items] row1 at asmcmdshare.pm line 3055
<- finish= ( 1 ) [1 items] at asmcmdshare.pm line 3076
<- DESTROY(DBI::st=HASH(0x33e2b10))= ( undef ) [1 items] at asmcmdshare.pm line 1633
<- prepare(‘/* ASMCMD */ select reference_index from v$asm_alias where group_number=2 and parent_index=33554432 and upper(name)=’LUNARBB”)= ( DBI::st=HASH(0x33e2840) ) [1 items] at asmcmdshare.pm line 3003
    <- execute= ( ‘0E0’ ) [1 items] at asmcmdshare.pm line 3022
<- fetchrow_hashref= ( HASH(0x33e2588)1keys ) [1 items] row1 at asmcmdshare.pm line 3055
<- finish= ( 1 ) [1 items] at asmcmdshare.pm line 3076
<- DESTROY(DBI::st=HASH(0x33e2c30))= ( undef ) [1 items] at asmcmdshare.pm line 1469
<- prepare(‘/* ASMCMD */ select reference_index from v$asm_alias where group_number=2 and parent_index=33554485 and upper(name)=’LUNARTEST.DBF”)= ( DBI::st=HASH(0x33e2708) ) [1 items] at asmcmdshare.pm line 3003
    <- execute= ( ‘0E0’ ) [1 items] at asmcmdshare.pm line 3022
<- fetchrow_hashref= ( undef ) [1 items] at asmcmdshare.pm line 3055
<- finish= ( 1 ) [1 items] at asmcmdshare.pm line 3076
<- DESTROY(DBI::st=HASH(0x33e26d8))= ( undef ) [1 items] at asmcmdshare.pm line 1469
<- prepare(‘
        begin
          dbms_diskgroup.getfileattr(:fileName, :fileType, :fileSz, :blkSz);
        end;
        ‘)= ( DBI::st=HASH(0x33e29f0) ) [1 items] at asmcmdbase.pm line 3588
    <- bind_param(‘:fileName’, ‘+DATA/LUNARBB/DATAFILE/lunartest.281.823017791’)= ( 1 ) [1 items] at asmcmdbase.pm line 3595
<- bind_param_inout(‘:fileType’, SCALAR(0x33e3260), …)= ( 1 ) [1 items] at asmcmdbase.pm line 3598
<- bind_param_inout(‘:fileSz’, SCALAR(0x33e33e0), …)= ( 1 ) [1 items] at asmcmdbase.pm line 3599
<- bind_param_inout(‘:blkSz’, SCALAR(0x33e88f0), …)= ( 1 ) [1 items] at asmcmdbase.pm line 3600
<- execute= ( 1 ) [1 items] at asmcmdbase.pm line 3603
    <- prepare(‘
        begin
        dbms_diskgroup.copy(”, ”, ”, :src_path, :src_ftyp, :src_blksz,
                            :src_fsiz, ”,”,”, :dst_path, 1);
        end;
       
‘)= ( DBI::st=HASH(0x33e28d0) ) [1 items] at asmcmdbase.pm line 3721
<- DESTROY(DBI::st=HASH(0x33e2a08))= ( undef ) [1 items] at asmcmdbase.pm line 3728
<- bind_param(‘:src_path’, ‘+DATA/LUNARBB/DATAFILE/lunartest.281.823017791’)= ( 1 ) [1 items] at asmcmdbase.pm line 3728
<- bind_param(‘:src_ftyp’, 12)= ( 1 ) [1 items] at asmcmdbase.pm line 3729
<- bind_param(‘:src_blksz’, 8192)= ( 1 ) [1 items] at asmcmdbase.pm line 3730
<- bind_param(‘:src_fsiz’, ‘1280’)= ( 1 ) [1 items] at asmcmdbase.pm line 3731
<- bind_param(‘:dst_path’, ‘+RECO/LUNARBB/lunartest.dbf’)= ( 1 ) [1 items] at asmcmdbase.pm line 3732
copying +DATA/LUNARBB/DATAFILE/lunartest.281.823017791 -> +RECO/LUNARBB/lunartest.dbf
<- execute= ( 1 ) [1 items] at asmcmdbase.pm line 3739
<- DESTROY(DBI::st=HASH(0x33e2a80))= ( undef ) [1 items] at asmcmdbase.pm line 2188
<- disconnect= ( 1 ) [1 items] at asmcmdbase.pm line 5169
-> DBI->connect(dbi:Oracle:, , ****, HASH(0x33e2ac8))
<- default_user(undef, undef, …)= ( undef undef ) [2 items] at DBI.pm line 653
<- DESTROY(DBI::st=HASH(0x33dd2e8))= ( undef ) [1 items] at Oracle.pm line 285
<- connect(”, undef, …)= ( DBI::db=HASH(0x33dd318) ) [1 items] at DBI.pm line 665
<- STORE(‘PrintError’, 0)= ( 1 ) [1 items] at DBI.pm line 717
<- STORE(‘AutoCommit’, 1)= ( 1 ) [1 items] at DBI.pm line 717
<- STORE(‘Username’, undef)= ( 1 ) [1 items] at DBI.pm line 720
$h->{‘ora_session_mode’}=32768 ignored for invalid driver-specific attribute
<- STORE(‘ora_session_mode’, 32768)= ( ” ) [1 items] at DBI.pm line 720
<- connected(‘dbi:Oracle:’, undef, …)= ( undef ) [1 items] at DBI.pm line 727
<- connect= DBI::db=HASH(0x33dd318)
<- STORE(‘dbi_connect_closure’, CODE(0x33e8440))= ( 1 ) [1 items] at DBI.pm line 736
<- prepare(‘/* ASMCMD */ select instance_name from v$instance’)= ( DBI::st=HASH(0x33dd018) ) [1 items] at asmcmdshare.pm line 3003
    <- execute= ( ‘0E0’ ) [1 items] at asmcmdshare.pm line 3022
<- fetchrow_hashref= ( HASH(0x33dce50)1keys ) [1 items] row1 at asmcmdshare.pm line 3055
<- finish= ( 1 ) [1 items] at asmcmdshare.pm line 3076
<- DESTROY(DBI::st=HASH(0x33dd300))= ( undef ) [1 items] at asmcmdbase.pm line 5143
<- DESTROY(DBI::db=HASH(0x33e32f0))= ( undef ) [1 items] at asmcmdcore line 1445
ASMCMD>
ASMCMD> pwd
+reco/lunarbb
ASMCMD> ls -lt
Type      Redund  Striped  Time             Sys  Name
Y    ONLINELOG/
Y    CONTROLFILE/
Y    AUTOBACKUP/
Y    ARCHIVELOG/
DATAFILE  UNPROT  COARSE   AUG 09 16:00:00  N    lunartest.dbf => +RECO/ASM/DATAFILE/lunartest.dbf.268.823018117
ASMCMD>
SQL> alter database rename file ‘+DATA/LUNARBB/DATAFILE/lunartest.281.8230177911’ to ‘+RECO/LUNARBB/lunartest.dbf’;
alter database rename file ‘+DATA/LUNARBB/DATAFILE/lunartest.281.8230177911’ to ‘+RECO/LUNARBB/lunartest.dbf’
*
ERROR at line 1:
ORA-01511: error in renaming log/data files
ORA-01516: nonexistent log file, data file, or temporary file
“+DATA/LUNARBB/DATAFILE/lunartest.281.8230177911”
SQL>

郁闷,看了下都有呀:

ASMCMD> ls -lt +DATA/LUNARBB/DATAFILE/lunartest.281.823017791
Type      Redund  Striped  Time             Sys  Name
DATAFILE  UNPROT  COARSE   AUG 09 16:00:00  Y    lunartest.281.823017791
ASMCMD>
ASMCMD>  ls -lt +RECO/LUNARBB/lunartest.dbf
Type      Redund  Striped  Time             Sys  Name
DATAFILE  UNPROT  COARSE   AUG 09 16:00:00  N    lunartest.dbf => +RECO/ASM/DATAFILE/lunartest.dbf.268.823018117
ASMCMD>

邪门。。
SQL> select file#,name,(bytes/1024/1024)MB,status from v$datafile;

FILE# NAME                                                            MB
———- ——————————————————- ———-
STATUS
——-
1 +DATA/LUNARBB/DATAFILE/system.261.818251295                    790
SYSTEM

2 +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE        260
/system.262.818251355
SYSTEM

3 +DATA/LUNARBB/DATAFILE/sysaux.263.818251381                    820
ONLINE

4 +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE        675
/sysaux.264.818251441
ONLINE

5 +DATA/LUNARBB/DATAFILE/undotbs1.265.818251465                  675
ONLINE

6 +DATA/LUNARBB/DATAFILE/users.268.818251547                       5
ONLINE

7 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE        260
/system.270.818261387
SYSTEM

8 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE        705
/sysaux.271.818261387
ONLINE

9 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE          5
/users.273.818261503
ONLINE

10 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE        260
/system.275.819174909
SYSTEM

11 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE        705
/sysaux.276.819174909
ONLINE

12 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE          5
/users.274.819174909
ONLINE

30 +DATA/LUNARBB/DATAFILE/lunartest.281.823017791                  10
RECOVER
13 rows selected.

SQL> recover datafile 30;
Media recovery complete.
SQL> select file#,name,(bytes/1024/1024)MB,status from v$datafile;

FILE# NAME                                                            MB
———- ——————————————————- ———-
STATUS
——-
1 +DATA/LUNARBB/DATAFILE/system.261.818251295                    790
SYSTEM

2 +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE        260
/system.262.818251355
SYSTEM

3 +DATA/LUNARBB/DATAFILE/sysaux.263.818251381                    820
ONLINE

4 +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE        675
/sysaux.264.818251441
ONLINE

5 +DATA/LUNARBB/DATAFILE/undotbs1.265.818251465                  675
ONLINE

6 +DATA/LUNARBB/DATAFILE/users.268.818251547                       5
ONLINE

7 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE        260
/system.270.818261387
SYSTEM

8 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE        705
/sysaux.271.818261387
ONLINE

9 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE          5
/users.273.818261503
ONLINE

10 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE        260
/system.275.819174909
SYSTEM

11 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE        705
/sysaux.276.819174909
ONLINE

12 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE          5
/users.274.819174909
ONLINE

30 +DATA/LUNARBB/DATAFILE/lunartest.281.823017791                  10
OFFLINE
13 rows selected.

SQL>

文件名写错了,把91,写成911了,汗。。。。
SQL> alter database rename file ‘+DATA/LUNARBB/DATAFILE/lunartest.281.823017791’ to ‘+RECO/ASM/DATAFILE/lunartest.dbf.268.823018117’;

Database altered.

SQL>
alert中:
alter database rename file ‘+DATA/LUNARBB/DATAFILE/lunartest.281.823017791’ to ‘+RECO/ASM/DATAFILE/lunartest.dbf.268.823018117’
Fri Aug 09 16:27:20 2013
Deleted Oracle managed file +DATA/LUNARBB/DATAFILE/lunartest.281.823017791
Completed: alter database rename file ‘+DATA/LUNARBB/DATAFILE/lunartest.281.823017791’ to ‘+RECO/ASM/DATAFILE/lunartest.dbf.268.823018117’
SQL> alter database datafile 30 online;
alter database datafile 30 online
*
ERROR at line 1:
ORA-01113: file 30 needs media recovery
ORA-01110: data file 30: ‘+RECO/ASM/DATAFILE/lunartest.dbf.268.823018117’
SQL> alter database recover datafile 30;

Database altered.

SQL> alter database datafile 30 online;

Database altered.

SQL>
SQL> select file#,name,(bytes/1024/1024)MB from v$datafile;

FILE# NAME                                                            MB
———- ——————————————————- ———-
1 +DATA/LUNARBB/DATAFILE/system.261.818251295                    790
2 +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE        260
/system.262.818251355

3 +DATA/LUNARBB/DATAFILE/sysaux.263.818251381                    820
4 +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE        675
/sysaux.264.818251441

5 +DATA/LUNARBB/DATAFILE/undotbs1.265.818251465                  675
6 +DATA/LUNARBB/DATAFILE/users.268.818251547                       5
7 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE        260
/system.270.818261387

8 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE        705
/sysaux.271.818261387

9 +DATA/LUNARBB/DF40E2A7FBA43CF9E0430100007FA44B/DATAFILE          5
/users.273.818261503

10 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE        260
/system.275.819174909

11 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE        705
/sysaux.276.819174909

12 +DATA/LUNARBB/E01585ADCBBD27D9E0430100007F8BF8/DATAFILE          5
/users.274.819174909

30 +RECO/ASM/DATAFILE/lunartest.dbf.268.823018117                  10

13 rows selected.

SQL>
[grid@lunar ~]$ asmcmd lsof
Use of uninitialized value in subroutine entry at /u01/app/12.1/grid/lib/asmcmdbase.pm line 571.
Use of uninitialized value in subroutine entry at /u01/app/12.1/grid/lib/asmcmdbase.pm line 571.
Use of uninitialized value in subroutine entry at /u01/app/12.1/grid/lib/asmcmdbase.pm line 571.
Use of uninitialized value $what_print[2] in sprintf at /u01/app/12.1/grid/lib/asmcmdbase.pm line 607.
Use of uninitialized value $what_print[2] in sprintf at /u01/app/12.1/grid/lib/asmcmdbase.pm line 607.
Use of uninitialized value $what_print[2] in sprintf at /u01/app/12.1/grid/lib/asmcmdbase.pm line 607.
DB_Name  Instance_Name  Path
+ASM     +ASM
+ASM     +ASM
+ASM     +ASM
lunarbb  lunarbb        +DATA/LUNARBB/CONTROLFILE/current.257.818251245
lunarbb  lunarbb        +DATA/LUNARBB/DATAFILE/sysaux.263.818251381
lunarbb  lunarbb        +DATA/LUNARBB/DATAFILE/system.261.818251295
lunarbb  lunarbb        +DATA/LUNARBB/DATAFILE/undotbs1.265.818251465
lunarbb  lunarbb        +DATA/LUNARBB/DATAFILE/users.268.818251547
lunarbb  lunarbb        +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE/sysaux.264.818251441
lunarbb  lunarbb        +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/DATAFILE/system.262.818251355
lunarbb  lunarbb        +DATA/LUNARBB/DF3E8911E1142763E0430100007FCDF1/TEMPFILE/temp.267.818251487
lunarbb  lunarbb        +DATA/LUNARBB/ONLINELOG/group_1.258.818251257
lunarbb  lunarbb        +DATA/LUNARBB/ONLINELOG/group_2.259.818251267
lunarbb  lunarbb        +DATA/LUNARBB/ONLINELOG/group_3.260.818251277
lunarbb  lunarbb        +DATA/LUNARBB/TEMPFILE/temp.266.818251485
lunarbb  lunarbb        +RECO/ASM/DATAFILE/lunartest.dbf.268.823018117                               
lunarbb  lunarbb        +RECO/LUNARBB/CONTROLFILE/current.256.818251251
lunarbb  lunarbb        +RECO/LUNARBB/ONLINELOG/group_1.257.818251261
lunarbb  lunarbb        +RECO/LUNARBB/ONLINELOG/group_2.258.818251273
lunarbb  lunarbb        +RECO/LUNARBB/ONLINELOG/group_3.259.818251283
[grid@lunar ~]$

/u01/app/12.1/grid/lib/asmcmdbase.pm对于asmcmd的N多至关重要

此条目发表在 ASM 分类目录,贴了 , , , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注