※ 참고
- 프롬프트로 현재 접속 인스턴스 구분하기
SQL> set sqlprompt "_connect_identifier> "
+ASM>


기본

ASM인스턴스로 접속하기

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba 

 











[1] ASM관리하기
 
 
1. ASM disk 내용 확인

+ASM>
set line 200
col disk_group for a10
col label for a10
col state for a10
select a.name as disk_group, d.name "Label", a.state
from v$asm_disk d, v$asm_diskgroup a
where d.group_number=a.group_number
order by 2;


 
 
 
2. ASM 인스턴스에 현재 연결되어 있는 disk group 확인하기.

+ASM>
set line 200
col group_number for 99
col name for a10
col type for a10
col state for a10
select group_number, name, type, state from v$asm_diskgroup;


 
 
 
 
3. 각 디스크 그룹별 세부 상세 정보 보기

+ASM>
col group_number for 999
col disk_number for 999
col name for a10
col mount_status for a10
col path for a15
select group_number, disk_number, name, mount_status, path, total_mb from v$asm_disk;


 
 
 
 
 
4. 각 디스크 그룹 별 파일 내역

+ASM>
set line 200
set pagesize 50
col group_number for 99
col file_number for 999
col type for a15
select group_number, file_number, round((bytes/1024/1024),1) MB, redundancy, type from v$asm_file;


 

 
 


  
[2] 디스크 추가 & 삭제하기
 

1. 디스크 추가
 

◎ 작업순서
1) 리눅스 종료후 5G 디스크 추가
2) fdisk linux LVM으로 파티셔닝
3) pvcreate
4) vgcreate
5) lvcreate
6) oracleasm createdisk 수행
7) asm 명령으로 디스크 추가



 
1) 리눅스 종료후 5G 디스크 추가
2) fdisk linux LVM으로 파티셔닝
 

# fdisk -l
Disk /dev/sdd: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/sdd doesn't contain a valid partition table
 
 
# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1): (엔터)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): (엔터)
Using default value 652
 
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.


 
 
3) pvcreate
4) vgcreate
5) lvcreate
 

# pvcreate /dev/sdd1
  Physical volume "/dev/sdd1" successfully created
 
# vgcreate asm2 /dev/sdd1
  Volume group "asm2" successfully created
 
# lvcreate -L 2G -n asm3 asm2
  Logical volume "asm3" created
 
# lvcreate -L 2.5G -n asm4 asm2
  Logical volume "asm4" created


 
 
 
6) oracleasm createdisk 수행
 

# /etc/init.d/oracleasm createdisk asm2 /dev/asm2/asm3
Marking disk "asm2" as an ASM disk:                        [  OK  ]
 
# /etc/init.d/oracleasm createdisk asm3 /dev/asm2/asm4
Marking disk "asm3" as an ASM disk:                        [  OK  ]


 
 
 
7) asm 명령으로 디스크 추가
 

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba;
SQL> set sqlprompt "_connect_identifier> "


 
 
① asm disk중 사용 안하는 것 조회

+ASM>
set line 200
col path for a15
select group_number, mount_status, path, total_mb
from v$asm_disk where mount_status='CLOSED';

 
GROUP_NUMBER MOUNT_STATUS   PATH              TOTAL_MB
------------ -------------- --------------- ----------
           0 CLOSED         ORCL:ASM3             2560
           0 CLOSED         ORCL:ASM2             2048


 



② ORCL:ASM2 추가
 

+ASM> alter diskgroup data add disk 'ORCL:ASM2' rebalance power 5;


 


 
③ asm disk 상태 조회
 

+ASM>
select group_number, disk_number, name, mount_status, path, total_mb
from v$asm_disk;

 
GROUP_NUMBER DISK_NUMBER NAME                                                         MOUNT_STATUS   PATH              TOTAL_MB
------------ ----------- ------------------------------------------------------------ -------------- --------------- ----------
           0           1                                                              CLOSED         ORCL:ASM3             2560
           1           0 ASM1                                                         CACHED         ORCL:ASM1             7161
           2           0 FRA1                                                         CACHED         ORCL:FRA1             3074
           1           1 ASM2                                                         CACHED         ORCL:ASM2             2048

▶ ORCL:ASM3 사용 안되고 있음
 
 


④ ORCL:ASM3 추가하기
 

+ASM> alter diskgroup data add disk 'ORCL:ASM3' rebalance power 10;


 
 

⑤ asm disk 상태 조회
 

+ASM>
select group_number, disk_number, name, mount_status, path, total_mb
from v$asm_disk;

 
GROUP_NUMBER DISK_NUMBER NAME                                                         MOUNT_STATUS   PATH              TOTAL_MB
------------ ----------- ------------------------------------------------------------ -------------- --------------- ----------
           1           0 ASM1                                                         CACHED         ORCL:ASM1             7161
           2           0 FRA1                                                         CACHED         ORCL:FRA1             3074
           1           1 ASM2                                                         CACHED         ORCL:ASM2             2048
           1           2 ASM3                                                         CACHED         ORCL:ASM3             2560


 
 
 

 
2. 디스크 삭제하기
 

1) 현재 상태 조회
 

+ASM>
set line 200
col group_name for a10
col disk_name for a10
select b.name as group_name, a.name as disk_name, a.header_status, a.state, a.free_mb
from v$asm_disk a, v$asm_diskgroup b
where a.group_number=b.group_number;

 
 
GROUP_NAME DISK_NAME  HEADER_STATUS            STATE               FREE_MB
---------- ---------- ------------------------ ---------------- ----------
DATA       ASM1       MEMBER                   NORMAL                 6626
FRA        FRA1       MEMBER                   NORMAL                 2847
DATA       ASM2       MEMBER                   NORMAL                 1892
DATA       ASM3       MEMBER                   NORMAL                 2366


 
 

 
2) 디스크 삭제
 

+ASM> alter diskgroup data drop disk asm3;


 
 

3) 상태 확인하기
 

+ASM>
set line 200
col group_name for a10
col disk_name for a10
select b.name as group_name, a.name as disk_name, a.header_status, a.state, a.free_mb
from v$asm_disk a, v$asm_diskgroup b
where a.group_number=b.group_number;
 


GROUP_NAME DISK_NAME  HEADER_STATUS            STATE               FREE_MB
---------- ---------- ------------------------ ---------------- ----------
DATA       ASM1       MEMBER                   NORMAL                 6477
FRA        FRA1       MEMBER                   NORMAL                 2847
DATA       ASM2       MEMBER                   NORMAL                 1849

▶ ASM3 삭제 완료
 
 
 

 
3. Disk Group 추가 / 삭제
 
1) 디스크 그룹 내역 조회

+ASM> select group_number, name, state from v$asm_diskgroup;
 
GROUP_NUMBER NAME                                                         STATE
------------ ------------------------------------------------------------ ----------------------
           1 DATA                                                         MOUNTED
           2 FRA                                                          MOUNTED


 
 
2) 디스크 그룹 추가 (이름 : new_asm)
 

+ASM>
col path for a10
select name, path, state
from v$asm_disk;

 
NAME                                                         PATH       STATE
------------------------------------------------------------ ---------- ----------------
                                                             ORCL:ASM3  NORMAL
ASM1                                                         ORCL:ASM1  NORMAL
FRA1                                                         ORCL:FRA1  NORMAL
ASM2                                                         ORCL:ASM2  NORMAL


  

+ASM>
create diskgroup new_asm external redundancy
disk 'ORCL:ASM3';

 
Diskgroup created.


 

 
3) 디스크 그룹 내역 조회

+ASM> select group_number, name, state from v$asm_diskgroup;
 
GROUP_NUMBER NAME                                                         STATE
------------ ------------------------------------------------------------ ----------------------
           1 DATA                                                         MOUNTED
           2 FRA                                                          MOUNTED
           3 NEW_ASM                                                      MOUNTED

  

+ASM>
col path for a10
select name, path, state
from v$asm_disk;
 
 
NAME                                                         PATH       STATE
------------------------------------------------------------ ---------- ----------------
ASM1                                                         ORCL:ASM1  NORMAL
FRA1                                                         ORCL:FRA1  NORMAL
ASM2                                                         ORCL:ASM2  NORMAL
ASM3                                                         ORCL:ASM3  NORMAL


 
 
 
 





 
[3] asmcmd 로 asm 관리하기
Asmcmd : 유닉스의 명령어와 유사한 명령어들로 구성되어 있는 asm 관리 방법
 

$ export ORACLE_SID=+ASM
$ asmcmd


 

ASMCMD> help
        asmcmd [-p] [command]
 
        The environment variables ORACLE_HOME and ORACLE_SID determine the
        instance to which the program connects, and ASMCMD establishes a
        bequeath connection to it, in the same manner as a SQLPLUS / AS
        SYSDBA.  The user must be a member of the SYSDBA group.
 
        Specifying the -p option allows the current directory to be displayed
        in the command prompt, like so:
 
        ASMCMD [+DATAFILE/ORCL/CONTROLFILE] >
 
        [command] specifies one of the following commands, along with its
        parameters.
 
        Type "help [command]" to get help on a specific ASMCMD command.
 
        commands:
        --------
        cd
        du    ← 사용 용량 확인
        find  ← 특정 파일 찾기
        help
        ls
        lsct
        lsdg  ← disk group 정보 보여주기
        mkalias
        mkdir
        pwd
        rm
        rmalias
 
※ 그외 11g 부터 지원하는 명령
cp  ←  OS와 ASM간 파일 복사 기능. ASM과 ASM간 파일 복사도 가능.
lsdsk  ← ASM 디스크 헤더를 읽어서 요약 정보를 보여줌.
remap  ← ASM Disk가 장애 났을 때 다른 디스크로 remapping 해주고 기존 장애 디스크를 unusable 로 변경하는 명령어.


 
 
 
이것저것 해보기

ASMCMD> ls
DATA/
FRA/
NEW_ASM/
 
ASMCMD> cd /data
ASMCMD> ls
TESTDB/
 
ASMCMD> cd testdb
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfiletestdb.ora
 
ASMCMD> cd controlfile
ASMCMD> pwd
+data/testdb/controlfile
 
ASMCMD> ls
Current.256.776365293


 
 

ASMCMD> lsdg  ← disk group 정보 보여주기
State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name
MOUNTED  EXTERN  N      N         512   4096  1048576      9209     8326                0            8326              0  DATA/
MOUNTED  EXTERN  N      N         512   4096  1048576      3074     2847                0            2847              0  FRA/
MOUNTED  EXTERN  N      N         512   4096  1048576      2560     2510                0            2510              0  NEW_ASM/


 
 
Posted by 딩구르
,