溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何進行asmcmd的分析

發(fā)布時間:2021-11-30 10:01:15 來源:億速云 閱讀:181 作者:柒染 欄目:關(guān)系型數(shù)據(jù)庫

如何進行asmcmd的分析,相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。

在ASM實例中,所有的存儲于ASM磁盤組中的文件對于操作系統(tǒng)命令而言是不可訪問的,因此 也無法使用常規(guī)的命令來操縱ASM磁盤中的文件。所幸的是,我們有ASMCMD工具來代替操作系統(tǒng)命令來完成這部分工作。ASMCMD工具提供了類似于操 作系統(tǒng)的常用命令,如ls , du ,find,cd ,rm ,mkdir等等。借助這些工具可以更輕松的完成ASM實例的相關(guān)管理工作。
ASMCMD使用實例 
啟動前要設(shè)定ORACLE_SID環(huán)境變量
$ export ORACLE_SID=+ASM    
$ asmcmd

ASMCMD> help                 --在asmcmd命令提示符下,輸入help [命令] ,則顯示該命令幫助信息
        asmcmd [-p] [command]           --該方式可以直接完成相應(yīng)的功能而不需要進入到ASMCMD提示符下
        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
        mkalias
        mkdir
        pwd
        rm
        rmalias
ASMCMD> help lsct     --查看命令的具體用法,本例為lsct 
        lsct [-H] [group]
        List all clients and their attributes from V$ASM_CLIENT.  If group is 
        specified, then return only information on that group.
        The -H flag suppresses the column headers from the output.

$ asmcmd -p ls -l        --無需進入到ASMCMD命令提示符下完成相應(yīng)的功能
    State    Type    Rebal  Unbal  Name
    MOUNTED  NORMAL  N      N      DG1/
    MOUNTED  NORMAL  N      N      DG2/
    MOUNTED  EXTERN  N      N      REV/

ASMCMD> ls -l                          --查看磁盤組的基本信息
    State    Type    Rebal  Unbal  Name
    MOUNTED  NORMAL  N      N      DG1/
    MOUNTED  NORMAL  N      N      DG2/
    MOUNTED  EXTERN  N      N      REV/
ASMCMD> ls -s                          --查看磁盤組的詳細信息,如磁盤大小,可用空間,扇區(qū)大小等
    Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name
       512   4096  1048576      3058     1498                0             749              0  DG1/
       512   4096  1048576       200       98                0              49              0  DG2/
       512   4096  1048576      3074     2949                0            2949              0  REV/ 
ASMCMD> ls -ld     --查看目錄信息

Type  Redund  Striped  Time             Sys  Name
                                        Y    czmmiao/ 
ASMCMD> du                             --查看當(dāng)前目錄磁盤已使用的容量
    Used_MB      Mirror_used_MB
       804                1541
    ASMCMD> pwd                            --顯示當(dāng)前路徑
    + 
ASMCMD> cd DG1            --cd 命令改變當(dāng)前目錄
ASMCMD> pwd
    +DG1 
ASMCMD> find -t datafile +DG1/asmdb sys*     --find 用于查找對象,-t參數(shù)指定對象類型,對象類型必須是v$asm_file.type中的對象類型
    +DG1/asmdb/DATAFILE/SYSAUX.261.734885459
    +DG1/asmdb/DATAFILE/SYSTEM.259.734885389 
ASMCMD> cd +DG1/asmdb/DATAFILE/
ASMCMD> mkalias EXAMPLE.264.800386585 aaa    --給對象創(chuàng)建別名 
ASMCMD> ls
EXAMPLE.264.800386585
SYSAUX.257.800386397
SYSTEM.256.800386395
UNDOTBS1.258.800386397
UNDOTBS2.265.800386713
USERS.259.800386397
aaa
ASMCMD> ls -a            --查看別名信息,該信息來自v$asm_alias

+DATA/CZMMIAO/DATAFILE/aaa => EXAMPLE.264.800386585
none => SYSAUX.257.800386397
none => SYSTEM.256.800386395
none => UNDOTBS1.258.800386397
none => UNDOTBS2.265.800386713
none => USERS.259.800386397
aaa
ASMCMD> rmalias aaa        --刪除對象別名

ASMCMD> ls -a
none => EXAMPLE.264.800386585
none => SYSAUX.257.800386397
none => SYSTEM.256.800386395
none => UNDOTBS1.258.800386397
none => UNDOTBS2.265.800386713
none => USERS.259.800386397 
ASMCMD> lsdg             --查看磁盤組信息
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      3815     2529                0            2529              0  DATA/
ASMCMD> lsct              --查看asm客戶端信息
DB_Name   Status        Software_Version  Compatible_version  Instance_Name
czmmiao   CONNECTED           10.2.0.1.0          10.2.0.1.0  czmmiao1

ASMCMD> mkdir bbb ccc           -- 創(chuàng)建bbb和ccc目錄 

ASMCMD> ls
EXAMPLE.264.800386585
SYSAUX.257.800386397
SYSTEM.256.800386395
UNDOTBS1.258.800386397
UNDOTBS2.265.800386713
USERS.259.800386397
bbb/
ccc/
ASMCMD> rmdir bbb ccc           --刪除bbb和ccc目錄,rm命令有-r和-f兩個參數(shù),用法同linux的rm命令

11g R2新增命令

cp:不僅可以在ASM和OS之間復(fù)制文件,也可以在不同的ASM Instance和Diskgroup之間復(fù)制文件;

cp +dgtest/test/datafile/USERS.264.646186565 users.dbf 
md_backup: 將disk group中的metadata備份到文件; 
md_backup /tmp/backupfile -G DATAGP 
md_restore: 將備份文件中的metadata恢復(fù)到disk group; 
md_restore -full -G data --silent /tmp/file 
lsattr: 列出disk group的屬性;
lsattr -l -G DATAGP 
setattr: 設(shè)置disk group的屬性;
setattr -G DATAGP compataible.asm 11.2.0.0.0 
lsof: 顯示local clients的open files;
lsof -G DATAGP 
chdg: 修改disk group, add或drop disk;
chdg DATAGP_config.xml 
chkdg: check 或 repair disk group 的metadata;
chkdg --repair DATAGP 
dropdg: drop disk group; 
dropdg -r -f DATAGP 
iostat: 查看I/O statics通過v$asm_disk_iostat;
iostat -G DATAGP 
lsdsk: list ASM disks;
lsdsk -p -G DATAGP /dev/raw/* ; 
lsdsk --candidate -p 
lsod: list open ASM disks; 
lsod -G DATAGP 
mkdg: create disk group based on a xml file; 
mkdg DATAGP_config.xml 
mount: mount a disk group;
mount -f DATAGP;
mount --restrict DATAGP; 
mount -a 
offline: offline disks or failure groups that belong to disk group.
offline -G DATAGP -F FG1 
online: online disks or a failure group; 
online -G DATAGP -D data_0001 --power=3 
rebal: rebalance a disk group;
rebal --power 4 DATAGP 
remap: mark blocks as unusable on the disk and relocates data; 
remap DATAGP data_0001 500-700 
umount: dismount a disk group;
unmount -f DATAGP 
pwcopy: copy password file;
pwcopy --asm +DG/mydir/mypwfile +DG1/mypwfile 
pwcreate: create password file for sys; 
pwcreate --asm +DG/mdir/mypwfile 'welcome' 
pwdelete: delete password file;
pwdelete --asm +DG/mydir/mypwfile 
pwget: get the location of password file; 
pwget --asm 
pwmove: move password file; 
pwmove --asm +DG/mydir/mypwfile +DG1/mypwfile 
pwset: set the location of password file; 
pwset -dbuniquename aime1 +DG/mydir/mypwfile 
dsget: get the discovery disk string; 
dsget 
dsset: set the discovery disk string;
dsset /dev/raw/* 
lsop: list current operations on disk group from v$asm_operation; 
lsop 
shutdown: shutdown ASM instance; 
shut immediate 
spbackup: backup ASM Spfile; 
spbackup +DATA/asm/asmprameterfile/register.323.234 +DATA/spf.bak 
spcopy: copy spfile; 
spcopy +DATA/asm/asmprameterfile/register.323.234 +DATA/spf.ora 
spget: get the spfile location; 
spget 
spmove: move spfile; 
spmove +DATA/spf.ora +DATA1/spf.ora 
spset: set the location of spfile; 
spset +DATA/spf.ora 
startup: start up ASM instance;
startup --nomount --pfile asm.ora 
chtmpl:改變template的屬性;
chtmpl -G DATAGP --redundancy high --striping fine mytemplate 
lstmpl: list templates; 
ls -l -G DATAGP 
mktmpl: add template to disk group; 
mktmpl -G DATA --redundancy mirror --striping coarse 
rmtmpl: remove template from disk group;
rmtmpl -G DATAGP mytp 
chgrp: change user group of files;  
chgrp asm-data +data/mydir/a.f 
chmod: change permissions of files;
chmod 640 a.f 
chown: change owner of files; 
chown user:usergroup a.f 
groups: list all user groups of a user; 
groups DATAGP user 
grpmod: add or remove OS users to ASM user group;
grpmod --add fra asm_fra oracle1 oracle2 
lsgrp: list all ASM user groups; 
lsgrp -a 
lspwusr: list users from ASM password file;
lspwusr 
lsusr: list users in a disk group; 
lsusr -G DATAGP 
mkgrp: create new ASM user group; 
mkgrp DATAGP asm_data oracle1 oracle2 
mkusr: add OS user to a disk group; 
mkusr DATA oracle1 
orapwusr: add, drop, modify ASM password file user;  
orapwusr --add --privilege sysdba hrusr 
passwd: change password of a user; 
passwd oracle2
rmgrp: remove a user group from disk group; 
rmgrp DATAGP asm_data 
rmusr: remove a OS user from disk group; 
rmusr DATAGP oracle2 
rpusr: replace OS user1 with OS user2; 
rpusr DATAGP oracle1 oracle2 
volcreate: create an ADVM volume in disk group; 
volcreate -G DATA -s 10G --width 64K --column 8 volume1 
voldelete: delete an ADVM volume; 
voldelete -G DATAGP volume1 
voldisable: disable an ADVM volumes in mounted disk groups and remove the volume device on the local node; 
voldisable -G DATAGP volume1 
volenable: enable ADVM volume in mounted disk groups; 
volenable -G DATAGP volume1 
volinfo: display information of ADVM volumes; 
volinfo -G DATAGP volume1 
volresize: resize an ADVM volume; 
volresize -G DATAGP -s 20G volume1 
volset: set attributes of ADVM volume; 
volset -G DATA --usagestring 'no file system attached'  volume1 
volstat: report I/O statistics of ADVM volume; 
volstat -G DATAGP

看完上述內(nèi)容,你們掌握如何進行asmcmd的分析的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI